22#+author: Felix Drees
33#+STARTUP: latexpreview
44#+OPTIONS: toc:nil tex:t # tex:verbatim num:nil
5- #+keywords: while programs, turing complete, turing machines
5+ #+keywords: while
66
77* while
88
@@ -132,7 +132,7 @@ stack run
132132#+RESULTS:
133133:
134134: = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
135- : [91m[ Error][0m : Usage: stack run <filename>
135+ : [ Error]: Usage: stack run <filename>
136136: Use 'stack run <filename>' to interpret a while source file.
137137: = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
138138:
@@ -146,17 +146,33 @@ stack run ./examples/multiplication-func.while
146146
147147= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
148148
149- [92m[ Interpreting file][0m ./examples/multiplication-func.while
150- [92m[ READING .WHILE FILE][0m "./examples/multiplication-func.while"
151- [92m[ DONE TOKENIZE][0m
152- [92m[ DONE PARSING AST][0m
153- [92m[ RESULT OF EVALUATION][0m
149+ [ Interpreting file] ./examples/multiplication-func.while
150+ [ READING .WHILE FILE] "./examples/multiplication-func.while"
151+ [ DONE TOKENIZE]
152+ [ DONE PARSING AST]
153+ [ RESULT OF EVALUATION]
154154[("temp",28980),("b",0),("a",420),("rv",28980)]
155155
156156= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
157157
158158#+end_example
159159
160+ or use
161+
162+ #+begin_src shell
163+ stack ghci
164+
165+ ghci> xs <- readFileContent "./examples/multiplication-func.while"
166+ [READING .WHILE FILE] "./examples/multiplication-func.while"
167+ ghci> eval ((runASTParser . tokenize) xs) []
168+ [("temp",28980),("b",0),("a",420),("rv",28980)]
169+ ghci> evalT ((runASTParser . tokenize) xs) []
170+ ((),[("temp",28980),("b",0),("a",420),("rv",28980)])
171+ ghci>
172+ #+end_src
173+
174+
175+
160176
161177*** compile
162178
@@ -186,6 +202,14 @@ stack exec hlint src/*.hs app/*.hs test/*.hs
186202#+end_src
187203
188204
205+ *** pre commit
206+
207+ #+begin_src shell
208+ pre-commit run --all-files
209+ #+end_src
210+
211+
212+
189213** requirements
190214
191215*** using `apt`
0 commit comments