Comments (6)
The #[no_reduce(LParen)]
worked great, and then I was able to get it working with out that by looking further into that java compiler link your shared here. Thank you!
from plex.
There's already some support for this, though undocumented, haha. Look for
"overriding" and "no_reduce".
On Oct 18, 2016 19:24, "Yuki Izumi" [email protected] wrote:
This isn't a feature request, more feeling out: would you be interested in
a PR that added precedence operators to automatically solve shift–reduce
conflicts? (per bison's %left / %right / %nonassoc) If so, I might give
it a shot. (No guarantees I'm actually capable of it!)—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#12, or mute the thread
https://github.com/notifications/unsubscribe-auth/ABLtTrE3vbNDGrmAc7aeBI-vJQ-W2vcgks5q1X9igaJpZM4KafmF
.
from plex.
See https://github.com/rudi-c/cs444-java-compiler-in-rust/blob/master/ast/src/parser.rs for an old example of how I used them. If you want to improve the interface or make them more general, or whatever, that would be great!
from plex.
Great, will look at this tonight! Thanks :)
from plex.
Sorry if this is the wrong place for this, but I am getting a shift reduce conflict, and am unable to figure out how to use these macros to fix it. Here is the code:
expr: Expr {
// #[overriding]
Ident(var) Equals expr[rhs] => Expr {
span: span!(),
node: Expr_::Assign(var, Box::new(rhs)),
},
expr[e] LParen RParen => Expr {
span: span!(),
node: Expr_::FuncCall(e),
},
term[t] => t,
}
That second line, the one commented out, was my attempt at trying to solve the error, but that did nothing to fix it. Do you have any idea how I'd use these macros to fix this problem?
Here is the error:
error: shift-reduce conflict:
state: expr -> Ident Equals expr •
expr -> expr • LParen RParen
token: LParen
Thank you for your time!
from plex.
So I believe you can fix this by using #[no_reduce(LParen)]
, but I don't recommend that as a proper solution. The normal way to fix this kind of issue in an LR grammar is to introduce precedence levels for different kinds of expressions (in this case, you'd want the function-call expression to have higher precedence than the assignment-expression). I don't know of a good reference to point you to off-hand, but any classical compiler textbook should cover this kind of thing. Hope this helps!
from plex.
Related Issues (20)
- Multiple entry points
- Nightly build broken by proc_macro feature rename HOT 1
- Attribute needed to use the emit function HOT 3
- supporting error recovery?
- The crates.io version seems out of date HOT 2
- ⚠⚠⚠ Extreme compile times ⚠⚠⚠ HOT 2
- Example lexer can be simplified HOT 1
- No way to pass additional args to the lexer HOT 1
- Documentation leads to 404 error
- Token lifetime in parser
- Naming regex patterns? HOT 1
- Update to syn 1.0 HOT 1
- Warnings caused by plex macros HOT 4
- Support of start conditions
- [HELP] Function argument parser HOT 1
- Anyway to have a priority? HOT 3
- Any way to build for stable channel?
- warning: function 'reduce_11' is never used HOT 2
- Certain lexical tokens cause optional productions to shift-reduce conflict HOT 3
- One block for a set of two or more production rules?
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 plex.