X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=lex.dcl;h=535487d1b750923c005453ecc48cc74fbac862b4;hb=e33962666f8af6a34432d57180eb322f4543eb78;hp=d1daf7cf991b6b3a6ae7a022f4fad3fce51314eb;hpb=889d4798a0da64d76422da98378f5e5c35f0bf32;p=cc1516.git diff --git a/lex.dcl b/lex.dcl index d1daf7c..535487d 100644 --- a/lex.dcl +++ b/lex.dcl @@ -1,12 +1,16 @@ definition module lex -import Data.Either +from Data.Either import :: Either +from yard import :: Error +from AST import :: Pos -:: Token +:: Token :== (Pos, TokenValue) +:: TokenValue //Value tokens - = IdentToken [Char] // Identifier - | NumberToken [Char]// Integer + = IdentToken String // Identifier + | NumberToken Int // Integer | CharToken Char // Character literal + | StringToken [Char]// String literal //Keyword tokens | VarToken // var keyword | ReturnToken // return keyword @@ -28,6 +32,7 @@ import Data.Either | AmpersandsToken // && | PipesToken // || | ArrowToken // -> + | EmptyListToken // [] //One character tokens | BraceOpenToken // ( | BraceCloseToken // ) @@ -48,11 +53,7 @@ import Data.Either | LesserToken // < | BiggerToken // > | ExclamationToken // ! - //Special tokens - | EndOfFileToken // EOF -:: LexerOutput :== Either String [Token] - -instance toString LexerOutput +:: LexerOutput :== Either Error [Token] lexer :: [Char] -> LexerOutput