dcl voor interface infrastructure, we lezen nu stdin, dat werkt, lexer implementeren...
authorMart Lubbers <mart@martlubbers.net>
Thu, 11 Feb 2016 16:15:32 +0000 (17:15 +0100)
committerMart Lubbers <mart@martlubbers.net>
Thu, 11 Feb 2016 16:15:32 +0000 (17:15 +0100)
.gitignore
Makefile [deleted file]
README.md
lex.dcl [new file with mode: 0644]
lex.icl
lex.prj [new file with mode: 0644]

index e45a789..490b9f4 100644 (file)
@@ -1,2 +1,3 @@
 Clean System Files
 lex
+sapl
diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index 3f8aeff..0000000
--- a/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-CLM:=clm
-CLMFLAGS:=-b -nt
-
-BINARIES:=lex
-
-.PHONY: all clean
-
-all: $(BINARIES)
-
-%: %.icl
-       $(CLM) $(CLMFLAGS) $(basename $<) -o $@
-
-clean:
-       $(RM) -rv $(BINARIES) Clean\ System\ Files
index 167a116..b75222a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1 +1,3 @@
 # cc1516
+
+- Bouwen met `cpm make`
diff --git a/lex.dcl b/lex.dcl
new file mode 100644 (file)
index 0000000..3abe22d
--- /dev/null
+++ b/lex.dcl
@@ -0,0 +1,49 @@
+definition module lex
+
+import Data.Either
+
+:: Token
+       //Value tokens
+       = IdentToken String // Identifier
+       | NumberToken Int   // Integer
+       | CharToken Char    // Character literal
+       //Keyword tokens
+       | VarToken          // var keyword
+       | VoidToken         // void keyword
+       | ReturnToken       // return keyword
+       | IfToken           // if keyword
+       | ElseToken         // else keyword
+       | WhileToken        // while keyword
+       | TrueToken         // True keyword
+       | FalseToken        // False keyword
+       //One character tokens
+       | BraceOpenToken    // (
+       | BraceCloseToken   // )
+       | CBraceOpenToken   // {
+       | CBraceCloseToken  // {
+       | SquareOpenToken   // [
+       | SquareCloseToken  // ]
+       | CommaToken        // ,
+       | ColonToken        // :
+       | SColonToken       // ;
+       | DotToken          // .
+       | PlusToken         // +
+       | DashToken         // -
+       | StarToken         // *
+       | SlashToken        // /
+       | PercentToken      // %
+       | AssignmentToken   // =
+       | LesserToken       // <
+       | BiggerToken       // >
+       | ExclamationToken  // !
+       //Two character tokens
+       | DoubleColonToken  // ::
+       | LesserEqToken     // <=
+       | GreaterEqToken    // >=
+       | EqualsToken       // ==
+       | AmpersandsToken   // &&
+       | PipesToken        // ||
+
+:: LexerOutput :== Either String [Token]
+
+lexer :: [Char] -> LexerOutput
diff --git a/lex.icl b/lex.icl
index 34d913c..cc4bc2f 100644 (file)
--- a/lex.icl
+++ b/lex.icl
@@ -1,40 +1,32 @@
-module lex
+implementation module lex
 
-:: Token
-       //Values
-       = IdentToken String // Identifier
-       | NumberToken Int   // Integer
-       //Keywords
-       | VarToken          // var keyword
-       | VoidToken         // void keyword
-       | ReturnToken       // return keyword
-       | IfToken           // if keyword
-       | ElseToken         // else keyword
-       | WhileToken        // while keyword
-       | TrueToken         // True keyword
-       | FalseToken        // False keyword
-       //Single Characters
-       | BraceOpenToken    // (
-       | BraceCloseToken   // )
-       | CBraceOpenToken   // {
-       | CBraceCloseToken  // {
-       | SquareOpenToken   // [
-       | SquareCloseToken  // ]
-       | CommaToken        // ,
-       | ColonToken        // :
-       | SColonToken       // ;
-       | DotToken          // .
-       | PlusToken         // +
-       | DashToken         // -
-       | StarToken         // *
-       | SlashToken        // /
-       | PercentToken      // %
-       | EqualsToken       // =
-       | LesserToken       // <
-       | BiggerToken       // >
-       | ExclamationToken  // !
-       | AmpersandToken    // &
-       | PipeToken         // |
-       | SingleQuoteToken  // '
+import Data.Either
+import Data.List
+import StdString
+import System.CommandLine
+import StdFile
+import StdMisc
 
-Start = "Hello World!\n"
+// Misschien moeten we hier continuation style van maken
+instance toString lexerOutput where
+       toString l = "dit is een lexer output, danwel error\n"
+
+lexer :: [Char] -> LexerOutput
+lexer _ = Left "Not Implemented"
+
+Start :: *World -> *World
+Start w
+# (args, w) = getCommandLine w // We lezen nu nog standaard van stdin
+# (out, w) = stdio w
+# (toparse, out) = readEntireFile out
+# out = out <<< toString (lexer toparse)
+# (b, w) = fclose out w
+| not b = setReturnCode 1 w
+= w
+       where
+               readEntireFile :: *File -> *([Char], *File)
+               readEntireFile f
+               # (b, c, f) = freadc f
+               | not b = ([], f)
+               # (cs, f) = readEntireFile f
+               = ([c:cs], f)
diff --git a/lex.prj b/lex.prj
new file mode 100644 (file)
index 0000000..4fc8d41
--- /dev/null
+++ b/lex.prj
@@ -0,0 +1,547 @@
+Version: 1.4
+Global
+       ProjectRoot:    .
+       Target: iTasks
+       Exec:   {Project}/lex
+       CodeGen
+               CheckStacks:    False
+               CheckIndexes:   True
+       Application
+               HeapSize:       8388608
+               StackSize:      4194304
+               ExtraMemory:    81920
+               IntialHeapSize: 1048576
+               HeapSizeMultiplier:     4096
+               ShowExecutionTime:      False
+               ShowGC: False
+               ShowStackSize:  False
+               MarkingCollector:       False
+               DisableRTSFlags:        False
+               StandardRuntimeEnv:     True
+               Profile
+                       Memory: False
+                       MemoryMinimumHeapSize:  0
+                       Time:   True
+                       Stack:  True
+               Output
+                       Output: ShowConstructors
+                       Font:   Courier
+                       FontSize:       9
+                       WriteStdErr:    False
+       Link
+               LinkMethod:     Static
+               GenerateRelocations:    False
+               GenerateLinkMap:        False
+               LinkResources:  False
+               ResourceSource: 
+               GenerateDLL:    False
+               ExportedNames:  
+       Paths
+               Path:   {Project}
+       Precompile:     
+       Postlink:       
+MainModule
+       Name:   lex
+       Dir:    {Project}
+       Compiler
+               NeverMemoryProfile:     False
+               NeverTimeProfile:       False
+               StrictnessAnalysis:     True
+               ListTypes:      StrictExportTypes
+               ListAttributes: True
+               Warnings:       True
+               Verbose:        True
+               ReadableABC:    False
+               ReuseUniqueNodes:       True
+               Fusion: False
+OtherModules
+       Module
+               Name:   StdArray
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   StdBool
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   StdChar
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   StdCharList
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   StdClass
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   StdEnum
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   StdEnv
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   StdFile
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   StdFunc
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   StdInt
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   StdList
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   StdMisc
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   StdOrdList
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   StdOverloaded
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   StdReal
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   StdString
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   StdTuple
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   _SystemArray
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   _SystemEnum
+               Dir:    {Application}/lib/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   Control.Applicative
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   Control.Monad
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   Data.Either
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   Data.Func
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   Data.Functor
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   Data.List
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   Data.Maybe
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   Data.Monoid
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   Data.Void
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   System.CommandLine
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   System.IO
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   System._Pointer
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   System.OS
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Linux-64
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   _SystemDynamic
+               Dir:    {Application}/lib/iTasks-SDK/Patches/Dynamics
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   GenEq
+               Dir:    {Application}/lib/iTasks-SDK/Patches/Generics
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   StdGeneric
+               Dir:    {Application}/lib/iTasks-SDK/Patches/StdEnv
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False