Comments (4)
Can you give the example where you added the ++
?
from lalrpop.
I tried a couple of places. One was to change Term
to this:
Term: Exp = {
Float => Exp::Float(<>),
Var => Exp::Var(<>),
"(" <Exp> ")",
<Term> "++" => Exp::PostInc(Box::new(<>)),
};
But this didn't work because after reading a Term
and a single +
, it could either be parsing an add operation or a incrementation.
The other way I tried tried involved making a separate nonterminal for incrementation/decrementation expressions and a nonterminal for ++
and --
, but this just turned the shift/reduce conflict into a reduce/reduce, so it didn't solve anything.
from lalrpop.
I got it working with the following changes (to the original):
MulExp: Exp = {
<m:MulExp> <o:MulOp> <t:Term> => Exp::BinExp(Box::new(m), o, Box::new(t)),
PreExp,
};
PreExp: Exp = {
"++" <PostExp> => Exp::PreInc(Box::new(<>)),
PostExp,
};
PostExp: Exp = {
<Term> "++" => Exp::PostInc(Box::new(<>)),
Term,
};
I'm not sure why I didn't see it like this in the first place, but it seems pretty obvious to me now!
Sorry to bother you about this!
from lalrpop.
No problem, glad you got it working!
Niko
MulExp: Exp = {
<m:MulExp> <o:MulOp> <t:Term> => Exp::BinExp(Box::new(m), o, Box::new(t)),
PreExp,
};
PreExp: Exp = {
"++" => Exp::PreInc(Box::new(<>)),
PostExp,
};
PostExp: Exp = {
"++" => Exp::PostInc(Box::new(<>)),
Term,
};
I'm not sure why I didn't see it like this in the first place, but it seems pretty obvious to me now!
Sorry to bother you about this!
—
Reply to this email directly or view it on GitHub.
from lalrpop.
Related Issues (20)
- Release a new version and yank last release HOT 4
- Adding a feature `unicode` HOT 5
- Using `ThinVec` instead of `Vec` HOT 3
- Error in 0.20's generated code HOT 3
- Custom lexer needs context information from the parser? HOT 7
- Custom lexer with custom Token type HOT 8
- Dangling symlinks anywhere in the crate cause obscure build failures HOT 1
- Is it supposed to be possible to use the lexer generator without enabling the unicode feature? HOT 7
- Assertion instead of error message HOT 3
- Additional bracket make generated code fail to compile. HOT 1
- Online yacc/lex grammar editor/tester HOT 2
- Custom parser errors HOT 10
- Grouping rules together HOT 1
- Confusion about Ambiguous regex HOT 1
- Parsing from standard input? HOT 2
- Release 0.20.1 not SemVer compatible? HOT 7
- How can I parse newline-separated code with lalrpop? HOT 2
- Lane Table not quite correct? HOT 2
- Access to span in fallible actions HOT 1
- Replace term with anstream?
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 lalrpop.