rename Token Identifier to IDENTIFIER

This commit is contained in:
Marvin Schlegel 2024-05-01 22:46:58 +02:00
parent 5d49da69a6
commit e5baa701b2
2 changed files with 8 additions and 5 deletions

View File

@ -11,9 +11,9 @@ testEmptyComment = TestCase $ assertEqual "scan '/*x*/'" emptyTokenList $ alex
testLineComment = TestCase $ assertEqual "scan '// comment'" emptyTokenList $ alexScanTokens "// comment"
testLineCommentEnds = TestCase $ assertEqual "scan '// com\\n'" emptyTokenList $ alexScanTokens "// com\n"
testIdentifier = TestCase $ assertEqual "scan 'identifier'" [Identifier "identifier"] $ alexScanTokens "identifier"
testShortIdentifier = TestCase $ assertEqual "scan 'i'" [Identifier "i"] $ alexScanTokens "i"
testIdentifierWithNumber = TestCase $ assertEqual "scan 'i2'" [Identifier "i2"] $ alexScanTokens "i2"
testIdentifier = TestCase $ assertEqual "scan 'identifier'" [IDENTIFIER "identifier"] $ alexScanTokens "identifier"
testShortIdentifier = TestCase $ assertEqual "scan 'i'" [IDENTIFIER "i"] $ alexScanTokens "i"
testIdentifierWithNumber = TestCase $ assertEqual "scan 'i2'" [IDENTIFIER "i2"] $ alexScanTokens "i2"
testKeywordBreak = TestCase $ assertEqual "scan 'break'" [BREAK] $ alexScanTokens "break"
testKeywordInt = TestCase $ assertEqual "scan 'int'" [INT] $ alexScanTokens "int"

View File

@ -65,7 +65,9 @@ tokens :-
"volatile" { \_ -> VOLATILE}
"while" { \_ -> WHILE}
-- end keywords
$JavaLetter$JavaLetterOrDigit* { \s -> Identifier s }
$JavaLetter$JavaLetterOrDigit* { \s -> IDENTIFIER s }
-- Literals
{
data Token
@ -119,7 +121,8 @@ data Token
| VOID
| VOLATILE
| WHILE
| Identifier String
| IDENTIFIER String
deriving(Eq,Show)
}