Commit Graph

35 Commits

Author SHA1 Message Date
161166da15 Add symbol collection visitor
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-20 15:24:40 -04:00
499e09b254 Move compile::Ctx to its own mod, compile::ctx::Ctx
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-20 14:51:30 -04:00
9439dfda87 Remove some unused things (interning, type object definition)
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-20 14:47:59 -04:00
32591f5e29 Update how visitors work, add NameId type
* Visitors are now defined on a per-type level, allowing for greater
  flexibility in combining and re-using behavior
* NameId is used for namespaces, which are used to index locally scoped
  variables. Syms are used for free namespaces, specifically in objects.
  All NameIDs are symbols, while not all symbols are NameIDs.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-20 14:41:12 -04:00
3ce7384f15 Fix bug when lexing single-quoted strings
Single-quoted strings were accidentally expecting a double quote for
termination, instead of a single quote.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-19 15:42:34 -04:00
fb3f217d7d Change syntax Pos to use 1-based indices for lines and columns by default
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-19 15:42:13 -04:00
98f455e6fa Squash some warnings
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-19 15:29:20 -04:00
8dc89f7153 Add a lot of new stuff to the compile mod
* compile::sym is now compile::name
* add basic block structure
* add visitor pattern
* some other minor things (e.g. syn::ast::prelude)

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-19 15:26:38 -04:00
c0833086b6 Fix newattrs test
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-16 18:54:25 -04:00
d5cf39108b Changes all around - objects and GC
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-16 18:46:09 -04:00
a15dde0fc2 Add vm and compile modules
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-16 12:56:52 -04:00
a60471f526 Add AttrsBuidler, change Attrs struct around some
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-15 11:33:53 -04:00
f3680f29ad Add Attrs::new() test
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-14 17:17:14 -04:00
ccb12306d4 Add mem and obj modules, move to nightly
* mem and obj modules are roughly divided between doing memory-specific
  things and object-specific things
* Box::new_uninit() is a nightly feature and it's quite useful, so I'm
  enabling that for now
* Check out src/obj/attrs.rs for possible undefined behavior in the
  Attrs::new() function. I'm sure it'll be just fine.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-14 17:10:53 -04:00
e233ff1cfc Clean up warnings, update next_body, add more tests
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-08 16:19:01 -04:00
378bcef40b Add comment skipping to lexer
* Comment and whitespace skipping is now handed by a regex
* Remove skip_whitespace and adv_char since they aren't used anymore
* Fix pos_text() to return a reference with the correct lifetime
* Add comment skipping tests

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-08 12:34:51 -04:00
e7e8690463 Add structopt and base argument parsing
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-07 18:31:08 -04:00
1232eca64c Add function expression parsing
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-07 17:43:39 -04:00
d90ecfd4d7 cargo fmt
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-06 18:04:07 -04:00
10e37e2707 Add dot binary op expression parsing
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-06 18:02:13 -04:00
d238610f33 Add dot as binop
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-06 17:55:56 -04:00
5d3021ced7 Add indexing expression parsing and tests
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-06 17:55:25 -04:00
44970dbf97 Add dot token
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-06 17:41:46 -04:00
5c505e5ae5 Add function call expressions
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-06 17:39:31 -04:00
bd87e9dd30 Add block expression parsing and test
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-06 17:14:55 -04:00
66af3dcc53 Add base statement parsing
Assign statements and standalone expression statements are added, plus
some tests.

Additionally, starting tokens are implemented using lazy_static!{} so
that they can be mixed and matched.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-06 16:57:28 -04:00
7698e49baf cargo fmt
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-05 17:22:39 -04:00
ae99bbfc1e Add object parsing and tests
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-05 17:21:12 -04:00
4c2f18b7c9 Update parser bin_expr testing to be more consistent with the rest of the tests
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-05 16:52:46 -04:00
5622eb96bc Add ObjBrace token
To distinguish between objects and code bodies, an object is delimited
by curly braces, prefixed with a percent sign. Ex:

    obj = %{
        key = value
    }

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-05 16:43:38 -04:00
a4f289fb53 Add more expressions to parser, add EOL and newline tokens
* Lexer recognizes semicolons as EOL tokens, and newline tokens
* Parser can be configured to ignore newlines (which is also used
  internally)
* Newlines are allowed in lists, tuples, and parenthesized expressions
* Add a bunch of tests for the new stuff

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-05 16:38:07 -04:00
d9edf21d16 Add expression parsing
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-05-02 18:42:01 -04:00
28d29c2270 Add parser and AST, remove some stuff from lexer
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-04-27 20:17:16 -04:00
ce97d90f9d Move lexer to use regex instead of hand-rolled lexing
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-04-27 19:50:46 -04:00
58421a0469 Initial commit with lexer
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-04-27 12:42:17 -04:00