Skip to content

Commit

Permalink
Merge pull request #73 from Bogdanp/72-keywords-in-names
Browse files Browse the repository at this point in the history
Closes #72 keywords in names
  • Loading branch information
wende committed Jul 4, 2017
2 parents 0d8bb54 + d3d5620 commit 77e1e90
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dev:
cd example && make elm.js && open index.html
4 changes: 2 additions & 2 deletions src/Ast/Expression.elm
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ letExpression ops =
lazy <|
\() ->
Let
<$> (symbol "let" *> many1 (letBinding ops))
<$> (symbol_ "let" *> many1 (letBinding ops))
<*> (symbol "in" *> expression ops)


Expand Down Expand Up @@ -282,7 +282,7 @@ binary ops =
\() ->
let
next =
between_ whitespace (choice [ operator, symbol "as" ])
between_ whitespace (choice [ operator, symbol_ "as" ])
|> andThen
(\op ->
choice [ Cont <$> application ops, Stop <$> expression ops ]
Expand Down
13 changes: 9 additions & 4 deletions src/Ast/Helpers.elm
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ between_ p =

spaces : Parser s String
spaces =
regex "[ \t]*"
regex "[ \\t]*"


spaces_ : Parser s String
spaces_ =
regex "[ \t]+"
regex "[ \\t]+"


symbol_ : String -> Parser s String
symbol_ k =
(between_ whitespace (string k <* regex " |\\n|\\r"))


symbol : String -> Parser s String
Expand All @@ -68,7 +73,7 @@ symbol k =

initialSymbol : String -> Parser s String
initialSymbol k =
string k <* spaces
string k <* spaces_


commaSeparated : Parser s res -> Parser s (List res)
Expand Down Expand Up @@ -114,7 +119,7 @@ emptyTuple =

operator : Parser s String
operator =
regex "[+\\-\\/*=.$<>:&|^?%#@~!]+|\x08as\x08"
regex "[+\\-\\/*=.$<>:&|^?%#@~!]+|\x8As\x08"
|> andThen
(\n ->
if List.member n reservedOperators then
Expand Down
8 changes: 8 additions & 0 deletions tests/Expression.elm
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ letExpressions =
[ ( var "_", Integer 42 ) ]
(Integer 24)
)
, test "Can start with a tag name" <|
\() ->
"let letter = 1 in letter"
|> is
(Let
[ ( var "letter", Integer 1 ) ]
(var "letter")
)
, test "function" <|
\() ->
"""
Expand Down

0 comments on commit 77e1e90

Please sign in to comment.