Commit Graph

147 Commits

Author SHA1 Message Date
greg
e4a42e7691 Add back eval printing 2017-09-19 22:11:01 -07:00
greg
6e28ae68a0 Add options 2017-09-19 22:11:01 -07:00
greg
48b0b8d053 Add logic for picking language with command line flags 2017-09-19 22:11:01 -07:00
greg
e0c49abe56 Change show-llvm opt to -v 2017-09-19 22:11:01 -07:00
greg
65dc362a1d Killed some warnings, cleaned up some code 2017-09-19 22:11:01 -07:00
greg
8ff1c632c2 Make REPL friendlier 2017-09-19 22:11:01 -07:00
greg
039022bfc5 Get rid of println 2017-09-19 22:11:01 -07:00
greg
387ec25cda Fix bugs in interpreter argument parsing 2017-09-19 22:11:01 -07:00
greg
ecf60198fa Can now switch between languages in the interpreter 2017-09-19 22:11:01 -07:00
greg
f83cece2b4 Import Maaru into main 2017-09-19 22:11:00 -07:00
greg
8fd5fb5a0b Added language name functionality 2017-09-19 22:11:00 -07:00
greg
455fe2abe2 Get rid of stand alone evaluator 2017-09-19 22:11:00 -07:00
greg
902c85ccd7 Fully implemented state
If I make the LanguageInterface trait over a pair of language and
evaluator, then it works :)
2017-09-19 22:11:00 -07:00
greg
4ea600d55c Abstracted most work into LanguageInterface trait
Still need to handle state
2017-09-19 22:11:00 -07:00
greg
6dec35d460 Think I've nearly gotten it traitified correctly... 2017-09-19 22:11:00 -07:00
greg
a303aa2a5b Add first new language - Maaru
Maaru is intended to be a haskell-ish functional language.
Here's enough of a skeleton to print a thing
2017-09-19 22:11:00 -07:00
greg
421a9a7e9b Abstract evaluation into EvaluationMachine trait 2017-09-19 22:11:00 -07:00
greg
178434171e Cleaning up some types 2017-09-19 22:11:00 -07:00
greg
fd4610e175 Make newtype for LLVM code strings 2017-09-19 22:11:00 -07:00
greg
1a4bf24ab1 Move schala-specific stuff into its own module 2017-09-19 22:11:00 -07:00
greg
9d6bdf22da More conversions to trait version 2017-09-19 22:11:00 -07:00
greg
8326a12c9c (Largely) trait-ify Schala
The idea is to provide a trait `ProgrammingLanguage` that actually does
all the work, and then main.rs will just be the infra for storing its
own state
2017-09-19 22:11:00 -07:00
greg
1ac440c8df Implement trait parse 2017-09-19 22:11:00 -07:00
greg
f5022a771c Starting work to trait-ify language 2017-09-19 22:11:00 -07:00
greg
3e231b4715 Use native rust to write source file 2017-09-19 22:11:00 -07:00
greg
1702163478 Add flag for llvm 2017-09-19 22:11:00 -07:00
greg
bdd6f75cf6 Show/hide LLVM IR in REPL 2017-09-19 22:11:00 -07:00
greg
0ace370fc2 Tightened up REPL loop 2017-09-19 22:10:59 -07:00
greg
1f50fcc620 Improvments to interpreter directives parsing 2017-09-19 22:10:59 -07:00
greg
d7181afa91 Few more linefeed-related changes 2017-09-19 22:10:59 -07:00
greg
4eb7683f47 Move linefeed reader to struct 2017-09-19 22:10:59 -07:00
greg
b04a8f0092 Add back interpreter directives 2017-09-19 22:10:59 -07:00
greg
c50be58cd2 Moved from simplerepl to lineread crate 2017-09-19 22:10:59 -07:00
greg
7ddb421ced Exit cleanly on opt parse fail 2017-09-19 22:10:59 -07:00
greg
9b74527618 Control printing eval steps with flags 2017-09-19 22:10:59 -07:00
greg
f158b6c712 Converted to multiple-evaluator logic
Now I have (basically) full single-step evaluation and it works fine
2017-09-19 22:10:58 -07:00
greg
9b62efc830 Fix conditional parsing
Needed to account for semicolons/newlines. Maybe need to generalize
delimiter-separated list of things
2017-09-19 22:10:58 -07:00
greg
e84550f3ec Kill two compilation warnings 2017-09-19 22:10:57 -07:00
greg
3063de1242 Run rustfmt on the rest of them 2017-09-19 22:10:57 -07:00
greg
d4d61ce5ad Use process::exit in main 2017-09-19 22:10:57 -07:00
greg
743311d18a Convert Tokenize to Result 2017-09-19 22:10:57 -07:00
greg
fe8418edbe Kill some extraneous spaces 2017-09-19 22:10:57 -07:00
greg
1d8102b9fa Make compilation controllable 2017-09-19 22:10:57 -07:00
greg
aac3ca40fe Add getopts 2017-09-19 22:10:57 -07:00
greg
3d406f1dd2 Move llmv wrapper into separate file 2017-09-19 22:10:57 -07:00
greg
95b773de7f Compilation sequence
-move all steps of the llvm IR compilation process into the binary
2017-09-19 22:10:57 -07:00
greg
923566c4e9 Get rid of println's for token/ast debugging
Instead just explicitly stick them into the returned string.

This is necessary 'cause I'm gonna convert simplerepl to use ncurses
soon, so I can't have any side effects
2017-09-19 22:10:57 -07:00
greg
ee12e10ac6 Fix slice syntax 2017-09-19 22:10:56 -07:00
greg
6c44d295db Framework for compilation 2017-09-19 22:10:56 -07:00
greg
cd69ebaa9d Split main() into subfunctions 2017-09-19 22:10:56 -07:00
greg
3fe9ec95d5 Fix repl error message 2017-09-19 22:10:56 -07:00
greg
8b5d1ecd15 Kill compilation for now
Don't wanna deal with this right this second
2017-09-19 22:10:56 -07:00
greg
8a92d5ffa8 Partial LLVM work 2017-09-19 22:10:56 -07:00
greg
231de69084 Added infrastructure for reading files 2017-09-19 22:10:56 -07:00
greg
a8cafa8c64 Move Evaluator state into interpreter state 2017-09-19 22:10:55 -07:00
greg
16e8d969be Add basic evaluation 2017-09-19 22:10:55 -07:00
greg
fdaf4c302c Fix all compiler warnings 2017-09-19 22:10:55 -07:00
greg
087402ece6 Add more tests
Need to use box patterns
2017-09-19 22:10:55 -07:00
greg
09b67dc3f7 Change error message 2017-09-19 22:10:54 -07:00
greg
a613fa73e5 Basic parsing framework 2017-09-19 22:10:54 -07:00
greg
8662a3ba0e Make tokenize error-able 2017-09-19 22:10:54 -07:00
greg
5ca98c7d77 Print tokeniziation 2017-09-19 22:10:54 -07:00
greg
09d524c74a Changing how parsing works again
Someone wrote a port of the LLVM kaleidoscope tutorial to rust, namely
https://github.com/jauhien/iron-kaleidoscope

I'm just gonna follow this along
2017-09-19 22:10:54 -07:00
greg
1c23329656 Add boilerplate for evaluation
Just wires everything up, doesn't actually evaluate yet
2017-09-19 22:10:54 -07:00
greg
509ab80b9c I can now parse one thing 2017-09-19 22:10:54 -07:00
greg
247638c4db Get parsing REPL working 2017-09-19 22:10:54 -07:00
greg
16dfbb27d5 Use state features from simplerepl 2017-09-19 22:10:53 -07:00
greg
3af7e6a409 Refactoring Schala
Gonna work on Schala in earnest now! Using the simplerepl crate instead
of a build-in REPL, temporarily dropping parsing and evaluation code.
2017-09-19 22:10:53 -07:00
greg
123f388711 Rename language to "Schala" 2017-09-19 22:10:53 -07:00
greg
caa331ecdc Read from file as well as repl 2017-09-19 22:10:53 -07:00
greg
eb5ce2ef9e Don't print newline for empty REPL result 2017-09-19 22:10:53 -07:00
greg
72b26755a7 Make ParseResult just a normal Result type
No reason for it to be different
2017-09-19 22:10:53 -07:00
greg
c27c900e7f Add operators % and **
semantics for these are hard with floats handle later
2017-09-19 22:10:53 -07:00
greg
582a7fd6dc Make parse and tokens optional 2017-09-19 22:10:53 -07:00
greg
79619025ea Add directive to print precedence chart 2017-09-19 22:10:53 -07:00
greg
56b338a6a8 Move to global precedence table 2017-09-19 22:10:53 -07:00
greg
8e3a571d67 .env dirctive to display environment 2017-09-19 22:10:53 -07:00
greg
f88f115567 Environment persistent across repl loop 2017-09-19 22:10:53 -07:00
greg
34fdf2be00 Add machinery for evaluation environments 2017-09-19 22:10:53 -07:00
greg
d2108f0f97 First pass at evaluation
Very incomplete
2017-09-19 22:10:52 -07:00
greg
1342a76786 Added support for interpreter directives 2017-09-19 22:10:52 -07:00
greg
1059a88ee6 Separate parsing into module 2017-09-19 22:10:52 -07:00
greg
429ace73bd Move tokenizing into separate module 2017-09-19 22:10:52 -07:00
greg
044e7a6a26 Rename ASTNode -> AST
saves typing
2017-09-19 22:10:52 -07:00
greg
dbdae42c1b Add string to AST 2017-09-19 22:10:52 -07:00
greg
fc3dcf792d Start writing recursive descent parser
I think I get the idea now
2017-09-19 22:10:52 -07:00
greg
02b34ca105 Wrote expect()
Hopefully correctly?
2017-09-19 22:10:52 -07:00
greg
9f4330889a Starting parsing work 2017-09-19 22:10:52 -07:00
greg
3058af4f05 Break on ctrl-D 2017-09-19 22:10:52 -07:00
greg
4f17d5a0dc Add number tokenizing 2017-09-19 22:10:52 -07:00
greg
8e3774ffca Comma as separate token 2017-09-19 22:10:52 -07:00
greg
c6059ada7d Separators and parens
Separator = ; or \n, they are equivalent
2017-09-19 22:10:52 -07:00
greg
2aaa600d53 More tokenizer stuff 2017-09-19 22:10:51 -07:00
greg
c6a92728ee Scaffolding for evaluation function 2017-09-19 22:10:51 -07:00
greg
b2e23bed86 Print tokens and parse 2017-09-19 22:10:51 -07:00
greg
3fdacf018e Basic repl 2017-09-19 22:10:51 -07:00
greg
6098bf84d6 Initial commit 2017-09-19 22:10:51 -07:00