Skip to content

Commit

Permalink
allow identifiers to start witha digit #64
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosh committed Nov 16, 2018
1 parent f5769a6 commit c25c1bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Language/Parser/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ optionParser =
identifier :: Parser String
identifier = (lexeme . try) (p >>= check)
where
unquotedIdentifier = lowerId <|> upperId <|> specialId
unquotedIdentifier = some (idChar <|> digitChar)
quotedIdentifier = between (char '"') (char '"') $ some $ satisfy (\c -> isPrint c && (c /= '"'))
p = unquotedIdentifier <|> quotedIdentifier
check x =
Expand Down
6 changes: 3 additions & 3 deletions test/Parser/ParserSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ spec = do
forAll upperIdGen $ \s -> parse identifier "" s == Right s
specify "parses correctly a string starting with a special character" $
forAll specialIdGen $ \s -> parse identifier "" s == Right s
specify "does not parse a string starting with a digit" $
forAll ((:) <$> digitCharGen <*> listOf (oneof [idCharGen, digitCharGen])) $ \s ->
isLeft $ parse identifier "" s
-- specify "does not parse a string starting with a digit" $
-- forAll ((:) <$> digitCharGen <*> listOf (oneof [idCharGen, digitCharGen])) $ \s ->
-- isLeft $ parse identifier "" s
specify
"does not parse a string starting with a not-allowed special character" $
forAll
Expand Down

0 comments on commit c25c1bc

Please sign in to comment.