From: Mart Lubbers Date: Mon, 29 Feb 2016 12:10:23 +0000 (+0100) Subject: lexer met generics X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=39ec3b9396a095d914f703163ff02ea5028eea26;p=cc1516.git lexer met generics --- diff --git a/src/lex.icl b/src/lex.icl index 99aa37c..cbeaf76 100644 --- a/src/lex.icl +++ b/src/lex.icl @@ -77,47 +77,10 @@ lex t=:[x:xs] = case get x SingleCharTokens of | otherwise = err ("Unexpected character: " +++ toString x) +derive gEq TokenValue + (===) :: TokenValue Token -> Bool (===) (IdentToken _) (_, IdentToken _) = True (===) (NumberToken _) (_, NumberToken _) = True (===) (CharToken _) (_, CharToken _) = True -(===) (VarToken) (_, VarToken) = True -(===) (ReturnToken) (_, ReturnToken) = True -(===) (IfToken) (_, IfToken) = True -(===) (ElseToken) (_, ElseToken) = True -(===) (WhileToken) (_, WhileToken) = True -(===) (TrueToken) (_, TrueToken) = True -(===) (FalseToken) (_, FalseToken) = True -(===) (VoidToken) (_, VoidToken) = True -(===) (IntTypeToken) (_, IntTypeToken) = True -(===) (CharTypeToken) (_, CharTypeToken) = True -(===) (BoolTypeToken) (_, BoolTypeToken) = True -(===) (DoubleColonToken) (_, DoubleColonToken) = True -(===) (NotEqualToken) (_, NotEqualToken) = True -(===) (LesserEqToken) (_, LesserEqToken) = True -(===) (GreaterEqToken) (_, GreaterEqToken) = True -(===) (EqualsToken) (_, EqualsToken) = True -(===) (AmpersandsToken) (_, AmpersandsToken) = True -(===) (PipesToken) (_, PipesToken) = True -(===) (ArrowToken) (_, ArrowToken) = True -(===) (EmptyListToken) (_, EmptyListToken) = True -(===) (BraceOpenToken) (_, BraceOpenToken) = True -(===) (BraceCloseToken) (_, BraceCloseToken) = True -(===) (CBraceOpenToken) (_, CBraceOpenToken) = True -(===) (CBraceCloseToken) (_, CBraceCloseToken) = True -(===) (SquareOpenToken) (_, SquareOpenToken) = True -(===) (SquareCloseToken) (_, SquareCloseToken) = True -(===) (CommaToken) (_, CommaToken) = True -(===) (ColonToken) (_, ColonToken) = True -(===) (SColonToken) (_, SColonToken) = True -(===) (DotToken) (_, DotToken) = True -(===) (PlusToken) (_, PlusToken) = True -(===) (DashToken) (_, DashToken) = True -(===) (StarToken) (_, StarToken) = True -(===) (SlashToken) (_, SlashToken) = True -(===) (PercentToken) (_, PercentToken) = True -(===) (AssignmentToken) (_, AssignmentToken) = True -(===) (LesserToken) (_, LesserToken) = True -(===) (BiggerToken) (_, BiggerToken) = True -(===) (ExclamationToken) (_, ExclamationToken) = True -(===) _ _ = False +(===) x (_, y) = gEq {|*|} x y diff --git a/src/main.prj b/src/main.prj index d50d00f..177aab2 100644 --- a/src/main.prj +++ b/src/main.prj @@ -31,7 +31,6 @@ Global Link LinkMethod: Static GenerateRelocations: False - GenerateSymbolTable: False GenerateLinkMap: False LinkResources: False ResourceSource: @@ -422,7 +421,7 @@ OtherModules Fusion: False Module Name: Control.Applicative - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -436,7 +435,7 @@ OtherModules Fusion: False Module Name: Control.Monad - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -450,7 +449,7 @@ OtherModules Fusion: False Module Name: Data.Either - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -464,7 +463,7 @@ OtherModules Fusion: False Module Name: Data.Foldable - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -478,7 +477,7 @@ OtherModules Fusion: False Module Name: Data.Func - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -492,7 +491,7 @@ OtherModules Fusion: False Module Name: Data.Functor - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -506,7 +505,7 @@ OtherModules Fusion: False Module Name: Data.List - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -520,7 +519,7 @@ OtherModules Fusion: False Module Name: Data.Map - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -534,7 +533,7 @@ OtherModules Fusion: False Module Name: Data.Maybe - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -548,7 +547,7 @@ OtherModules Fusion: False Module Name: Data.Monoid - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -562,7 +561,7 @@ OtherModules Fusion: False Module Name: Data.Set - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -576,7 +575,7 @@ OtherModules Fusion: False Module Name: Data.Traversable - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -590,7 +589,7 @@ OtherModules Fusion: False Module Name: Data.Void - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -604,7 +603,7 @@ OtherModules Fusion: False Module Name: System.CommandLine - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -618,7 +617,7 @@ OtherModules Fusion: False Module Name: System.IO - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -632,7 +631,7 @@ OtherModules Fusion: False Module Name: System._Pointer - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -646,7 +645,7 @@ OtherModules Fusion: False Module Name: Text - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -660,7 +659,7 @@ OtherModules Fusion: False Module Name: Text.JSON - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -674,7 +673,7 @@ OtherModules Fusion: False Module Name: Text.PPrint - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -688,7 +687,7 @@ OtherModules Fusion: False Module Name: System.OS - Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Mac + Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Linux-64 Compiler NeverMemoryProfile: False NeverTimeProfile: False diff --git a/src/parse.icl b/src/parse.icl index bc93239..f1c7620 100644 --- a/src/parse.icl +++ b/src/parse.icl @@ -218,7 +218,7 @@ printStatements [s:ss] i = (case s of printCodeBlock [] _ = ["{}"] printCodeBlock [x] i = ["\n":printStatements [x] (i+1)] printCodeBlock x i = - ["{\n":printStatements x (i+1)] ++ indent i ["}"] + ["{\n":printStatements x (i+1)] ++ indent i ["}\n"] indent :: Int [String] -> [String] indent i rest = replicate i "\t" ++ rest