Some special characters in ids; new demos
Adds support for several special characters in identifiers. Adds a demo for converting values to source code and another for checking equality. Updates the existing demo and tests to reflect new names for functions returning booleans.
This commit is contained in:
@ -18,7 +18,10 @@ keywordT = string "t" *> notFollowedBy alphaNumChar *> pure LKeywordT
|
||||
identifier :: Lexer LToken
|
||||
identifier = do
|
||||
first <- letterChar <|> char '_'
|
||||
rest <- many (letterChar <|> char '_' <|> char '-' <|> digitChar)
|
||||
rest <- many $ letterChar
|
||||
<|> digitChar
|
||||
<|> char '_' <|> char '-' <|> char '?' <|> char '!'
|
||||
<|> char '$' <|> char '#' <|> char '@' <|> char '%'
|
||||
let name = first : rest
|
||||
if (name == "t" || name == "__result")
|
||||
then fail "Keywords (`t`, `__result`) cannot be used as an identifier"
|
||||
|
Reference in New Issue
Block a user