Skip to content

Commit

Permalink
Merge pull request #2 from masatake/elm-import-handling
Browse files Browse the repository at this point in the history
elm: replace pattern matches for import with appropriate handling
  • Loading branch information
bitterjug authored Jan 5, 2017
2 parents 65baebb + e22d55e commit c9cc975
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions Units/simple-elm.d/expected.tags
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Main input.elm /^port module Main exposing (..)$/;" m
Je input.elm /^import Json.Encode as Je$/;" x
Thing input.elm /^type Thing$/;" t
One input.elm /^ = One$/;" c type:Thing
Two Int input.elm /^ | Two Int$/;" c type:Thing
Expand Down
6 changes: 6 additions & 0 deletions optlib/elm.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ extern parserDefinition* ElmParser (void)
static tagRegexTable ElmTagRegexTable [] = {
{"^(port[[:blank:]]+)?module[[:blank:]]+([[:upper:]][[:alnum:]_.]*)", "\\2",
"m,module,Module", "{scope=push}{exclusive}"},
{"^import[[:blank:]]+[[:alnum:]_.]+[[:blank:]]+as[[:blank:]]+([[:alnum:]]+)", "\\1",
"x,unknown,Unknown objects", "{scope=clear}{exclusive}"},
{"^import[[:blank:]]+([[:alnum:]_.]+)[[:blank:]]exposing", "",
"", "{scope=clear}{exclusive}"},
{"^import[[:blank:]]+([[:alnum:]_.]+)", "",
"", "{scope=clear}{exclusive}"},
{"^port[[:blank:]]+([[:lower:]][[:alnum:]_]*).*", "\\1",
"p,port,Port", "{scope=clear}{exclusive}"},
{"^type +([[:upper:]][[:alnum:]_]*.*)", "\\1",
Expand Down
7 changes: 7 additions & 0 deletions optlib/elm.ctags
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
--langdef=elm
--map-elm=+.elm
--regex-elm=/^(port[[:blank:]]+)?module[[:blank:]]+([[:upper:]][[:alnum:]_.]*)/\2/m,module,Module/{scope=push}{exclusive}
--regex-elm=/^import[[:blank:]]+[[:alnum:]_.]+[[:blank:]]+as[[:blank:]]+([[:alnum:]]+)/\1/x,unknown,Unknown objects/{scope=clear}{exclusive}
#
# Following two patterns are just for clearing scope stack.
# X in "import X" should be captured as a reference tag in the future.
#
--regex-elm=/^import[[:blank:]]+([[:alnum:]_.]+)[[:blank:]]exposing///{scope=clear}{exclusive}
--regex-elm=/^import[[:blank:]]+([[:alnum:]_.]+)///{scope=clear}{exclusive}
--regex-elm=/^port[[:blank:]]+([[:lower:]][[:alnum:]_]*).*/\1/p,port,Port/{scope=clear}{exclusive}
--regex-elm=/^type +([[:upper:]][[:alnum:]_]*.*)/\1/t,type,Type Definition/{scope=set}{exclusive}
--regex-elm=/^[[:blank:]]+[|=][[:blank:]]+([[:upper:]][[:alnum:]_]*.*)$/\1/c,constructor,Type Constructor/{scope=ref}{exclusive}
Expand Down

0 comments on commit c9cc975

Please sign in to comment.