Testing testing testing#25
Open
impact-basin wants to merge 18 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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!