Commit Graph

17 Commits

Author SHA1 Message Date
57c1aa4702 Fix bug in parser where - symbol was being parsed as a + symbol in binary expressions
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-10-13 16:34:18 -07:00
16063d50f8 Add a couple of builtin functions, and the Vm::call() method
* Builtin functions print and println have been added
* If a global lookup fails, the VM will attempt to look up a builtin
* Vm::call(fun, args) allows interrupting the current execution state
  and starting a new function instead. It will return the value left on
  top of the stack.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-10-07 17:21:01 -07:00
76d0e6723f Add "return" statement
Functions may now be exited by returning a value or no value.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-10-07 16:34:23 -07:00
4848a342f0 Add function compilation
Functions are compiled in the most naiive way right now. I want to fix
up how scope lookups are done before it becomes too much to update.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-09-26 18:31:23 -07:00
f0032afe12 Add function expr parsing
* Introduce new `fn` keyword
* Function example is added to examples/expr.not

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-09-18 16:39:06 -07:00
cb5689c513 Add vm:📦:Package, instruction disassembly
* Code is compiled into a vm:📦:Package which contains the
  executable code, the constants, and the local name mappings.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-09-18 15:45:54 -07:00
0d6f68216b Rename "Local" to "Name" when referring to variables during compilation
* Variables were previously named "Local"s because they described a
  local variable - however, this is kind of a misnomer because it
  handles globals as well. This has been changed pretty much everywhere
  when appropriate (hopefully).
* Renamed obj/names.rs to obj/reserved.rs, freeing up the "names" module
  for the new Names handle
* Renamed obj/locals.rs to obj/names.rs, see above

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-09-18 13:57:51 -07:00
9394239b83 Skip comments when parsing
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-09-17 13:31:02 -07:00
1be0fb8a04 Add implementations for parsing assign statements, forgot to do this
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-09-17 13:17:53 -07:00
e72cbe2b8c Base compilation of some kind of file to a list of instructions seems to work(!)
I'm able to compile some basic expressions into instructions using the
`not` binary. Big first step, now we need to introduce branches and
loops to the syntax.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-09-16 18:01:40 -07:00
582b3a4b73 Add basic blocks and implementation of flattening thunks -> basic blocks
* Basic are a more linear way of representing code. Thunks beget basic
  blocks, which beget vectors of instructions.
* Basic blocks are also being flattened into a vector of instructions
  (hopefully, no tests done yet)
* OH yeah locals can be collected too (but currently are not being
  collected in the compiler, that should come soon)

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-09-16 17:18:31 -07:00
e2c43dc911 Add LhsExpr parsing
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-09-03 18:58:22 -07:00
4d8a815ffc Remove old TODO from parser grammar
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-09-03 18:49:53 -07:00
c42b63e016 Add Body AST item and visit_body in visitor
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-09-03 18:47:48 -07:00
f8819279f8 Fix parser for index and call exprs, remove old test that didn't work, add visitor pattern
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-09-03 18:32:22 -07:00
2fd340a688 Add lexer, parser, ast, and basic command line interaction
* Add lexer and parser using lrpar crate
* AST is added and constructed via lexer and parser
* Command line program `not` will read a file and parse it

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-09-02 14:40:43 -07:00
178ed4a952 Initial commit
Includes: runtime base from a previous project, syn(tax) module with
parser and lexer

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-09-01 17:32:48 -07:00