- VisitObj is for visiting object instances and dyn objects (and thus
dynamically dispatching accept)
- Obj::accept method is used for dispatching to the specific visitor
method
- GcMark ZST added for visiting/marking living objects
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* Accept requires a Visit parameter, so acceptor implementations are
type-wide and not method-wide. This allows us to pass &dyn Trait
references around to the visitor.
* Additionally, visitors now take a &dyn Accept so that acceptors are
dynamically dispatched(!)
* Converted everything except for the WIP TranslateAst visitor. This
might make things a little weird because return values can't vary
per-acceptor anymore, and must instead be uniform. Maybe it would make
most sense to do away with the Out parameters and expect acceptors to
report their state to their visitor, instead of returning something.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
DynAccept trait is necessary because we need some kind of Accept trait
that doesn't have generic methods - this is so we can dynamically
dispatch the .accept() method from a &dyn Obj type. I plan to work this
into the regular Accept trait and do away with the DynAccept distinction
entirely.
I'm also experimenting with using visitors to do GC, so that all
references are wrapped in a future GcRef, so they don't have to
implement that as part of their object. The GC will be able to visit any
Obj + ?Sized type, and can have a specific implementation if required.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* 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>
Single-quoted strings were accidentally expecting a double quote for
termination, instead of a single quote.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* 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>
* 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>
* 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>
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>
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>
* 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>