Comments (1)
I've rewritten the code, greatly simplifying it. The overall transformation is correct, which is:
// Left recursion:
// Convert A -> A beta1 | A beta2 | ... | alpha1 | alpha2 | ... ;
// into A -> (alpha1 | alpha2 | ... ) (beta1 | beta2 | ...)*
//
// Right recursion:
// Convert A -> beta1 A | beta2 A | ... | alpha1 | alpha2 | ... ;
// into A -> (beta1 | beta2 | ...)* (alpha1 | alpha2 | ... )
However, the prior implementation tried to construct a valid tree from scratch. This is extremely hard to do, and required over-the-top verbose code. Instead, the solution is to just construct a string for the collection of alpha and beta symbols for the new rule, and insert that into the parse tree for the code. It does not matter that the parse tree is not strictly an Antlr4 parse tree--it get reserialized on output.
from domemtech.trash.
Related Issues (20)
- New command-- a command like trtree, except it only prints the root
- trxgrep char/string compare does not work
- [trgen] asn/asn_3gpp should give ambiguous start rule
- [Feature Request] Add a command for adding labels HOT 2
- Trsponge doesn't work nicely with "trparse -l" input
- Decouple Antlr4.Runtime.Standard from Trash tools
- trperf doesn't show which alts are problems in a parser rule
- trconvert documentation error HOT 1
- Add Z3/SMT analysis of grammars to Trash
- Add trgenvsc HOT 1
- Consider distributing package as docker image HOT 2
- Port Saxon and switch over from Xalan
- Update Antlr4 grammar to not use labeledLexerElement HOT 1
- Add in template attribute definitions in the desc.xml HOT 1
- Reasoning about off-channel content HOT 1
- Converting really old bison HOT 5
- Replace trdelabel with g4-scripts/delabel.sh HOT 1
- Cannot get parent of attribute node HOT 1
- Fix grammar analysis for trgen
- Trgen should give a meaningful error message for missing Eof
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 domemtech.trash.