Comments (4)
?
is syntax sugar which unrolls to rules with _opt
suffix. Please see here.
Using rule gyro_specifier_opt: gyro_specifier?;
you end-up with gyro_specifier_opt: gyro_specifier_opt | EMPTY;
. The first alternative is invalid self-reference. A workaround is to use different name for gyro_specifier_opt
, or gyro_specifier?
directly in other rules RHSs (which is IMHO better for readability as it makes apparent that something is optional).
While this is not a bug, i.e. it works as designed, I think it would be nice to have better error report in this case where user rules clashes with rules produced by syntax sugar unroll.
from parglare.
Thank you.
A workaround is to use different name for gyro_specifier_opt, or gyro_specifier? directly in other rules RHSs (which is IMHO better for readability as it makes apparent that something is optional).
I just resorted to doing desugaring in this case myself. It may be better for readability to have a?
than a_opt: a | EMPTY; ... a_opt
, but for me it is not an option (for now) because for some parser generators one has to have each thing being captured in a separate rule and having the same tree structure for all the grammars for all the backends allows me use the same code for postprocessing.
While this is not a bug, i.e. it works as designed, I think it would be nice to have better error report in this case where user rules clashes with rules produced by syntax sugar unroll.
Could we detect the cases when a: b;
and optimize them out by renaming b
everywhere into a
, when b
is a generated name?
from parglare.
Manual desugaring is perfectly fine as the desugaring process will introduce new rules only if they don't already exist.
Could we detect the cases when a: b; and optimize them out by renaming b everywhere into a, when b is a generated name?
I don't think that such transformation should be implemented in parglare.
from parglare.
Thanks for making it clear.
from parglare.
Related Issues (20)
- A terminal that doesn't match specific strings HOT 2
- QUESTION: confusing 0.12.0 versions ... HOT 1
- ENHANCEMENT: new parameter for call_actions for not reversing HOT 1
- Parser object singleton or caching. Actions as object members HOT 3
- Error for named matches in an imported grammar with default action HOT 2
- Possible memory leak HOT 4
- Question on AST generation and actions with side effects HOT 1
- 0.13.0 is released
- Support for parenthesized groups HOT 1
- 0.14.0 is released
- 0.15.0 is released
- possible regression in regexp handling HOT 2
- Request to optimize recognizers matching HOT 4
- 0.16.0 is released
- advice requested on implementing a language "feature" HOT 1
- Lexical disambiguation not working as expected HOT 1
- Iterating through Forest fails in NodeNonTerm solutions property HOT 3
- Overriding terminal indirectly through multiple module imports fails when using separator repetition HOT 3
- Separate imports of the same file result in multiple "instances" HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parglare.