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" testLineComment = TestCase $ assertEqual "scan '// comment'" emptyTokenList $ alexScanTokens "// comment"
testLineCommentEnds = TestCase $ assertEqual "scan '// com\\n'" emptyTokenList $ alexScanTokens "// com\n" testLineCommentEnds = TestCase $ assertEqual "scan '// com\\n'" emptyTokenList $ alexScanTokens "// com\n"
testIdentifier = TestCase $ assertEqual "scan 'identifier'" [Identifier "identifier"] $ alexScanTokens "identifier" testIdentifier = TestCase $ assertEqual "scan 'identifier'" [IDENTIFIER "identifier"] $ alexScanTokens "identifier"
testShortIdentifier = TestCase $ assertEqual "scan 'i'" [Identifier "i"] $ alexScanTokens "i" testShortIdentifier = TestCase $ assertEqual "scan 'i'" [IDENTIFIER "i"] $ alexScanTokens "i"
testIdentifierWithNumber = TestCase $ assertEqual "scan 'i2'" [Identifier "i2"] $ alexScanTokens "i2" testIdentifierWithNumber = TestCase $ assertEqual "scan 'i2'" [IDENTIFIER "i2"] $ alexScanTokens "i2"
testKeywordBreak = TestCase $ assertEqual "scan 'break'" [BREAK] $ alexScanTokens "break" testKeywordBreak = TestCase $ assertEqual "scan 'break'" [BREAK] $ alexScanTokens "break"
testKeywordInt = TestCase $ assertEqual "scan 'int'" [INT] $ alexScanTokens "int" testKeywordInt = TestCase $ assertEqual "scan 'int'" [INT] $ alexScanTokens "int"

View File

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