Skip to content

Testing testing testing#25

Open
impact-basin wants to merge 18 commits into
LCSB-BioCore:masterfrom
impact-basin:master
Open

Testing testing testing#25
impact-basin wants to merge 18 commits into
LCSB-BioCore:masterfrom
impact-basin:master

Conversation

@impact-basin

Copy link
Copy Markdown

Heya - long time no see!

I've been twiddling with bits here on and off for a while, but my PhD has gotten quite busy, and so I've not been able to put in the hours, as it were.

I've not forgotten about this, and thought I'd raise a PR to get some CI outputs and get the ball rolling if there's anything here you want to merge. I won't be able to dedicate much work, but I can certainly get any requests done at some point over the coming month or two.

Thanks for writing an incredible parser library :-) sorry for disappearing!

The "@evaluate" macro was standing out to me as a bad name;
it is not an "evaluator" in the sense that an interpreter is.
Likewise, "@grammar" felt odd; specifically, this macro provides
_syntax_, not grammar as a whole.

Hence, I have changed names:
    * @grammar  => @syntax
    * @evaluate => @semantics

Secondly, a lesson learned from parser bringup: dereferencing
the array of submatches as a default leads to nuisance, but
having default matches means that the parse tree is immediately
visible, so this is invaluable.

Here is the new idea: if there are no submatches, we return
the matched text. If there are submatches, we return the
submatch array.

With nothing written for @semantics, this yields the parse tree
in terms of strings; bringing up @semantics is now as simple as
filling in the details bit-by-bit, with incremental changes
immediately visible against test cases for a parse tree.
Changes in this commit:
* Allow `@syntax` declarations for arbitrary token types.
* Remove need for commas in `@syntax` rules.
* Don't search for PikaParser: `import` to a gensym.
* make_grammar!() now called at compile-time.
    * This should give a nice speed-boost!
    * Note that helper functions used in `@syntax`
      _must_ be in the calling module's global scope.
      Otherwise the symbol will not be resolved.
* New testset capturing module behaviour.
* Expose `@syntax`, `@semantics` as public names.
* Docstrings with examples for `@syntax`, `@semantics`
* Heavy refactoring
We can get away with using @eval at macro time
so long as we are not evaluating into any closed modules --
i.e., modules Julia has finished precompiling. This means that
invoking @eval with anything other than __module__ will
cause incremental compilation to fail.

This breaks the import-gensym trick from the last commit:
Julia will see a recursion into a closed module via
@eval and complain. We need to maintain a "look but don't
touch" approach -- so a reversion to the old way of doing
things is necessary here, where we do not effect any stateful
change in the calling module; we just resolve a symbol.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant