Comments (7)
Can you cut the example down a bit so I can understand it more easily please?
from grmtools.
Ok,
I have this grammar
"INT_T" "MAIN" '(' ')' '{' LDeclBlock BeginBlock '}'
{
...
process($6?) //LDeclBlock
let node = $7?; //BeginBlock
}
;
$6 contains grammar for local variables and process() function generates a table for storing the details of the local variables.
$7 should only be executed after process($6?) has been executed.
However when I run my code, $7 runs before process($6?). I don't know why this happens, is this an LR parsing thing or a mistake from my side? the process() is critical here.
from grmtools.
I'm really sorry but I'm going to struggle to debug with this sort of information. Either (preferably) I need a self-contained minimal example or (if that's not possible) a complete repository where I can compile and run code.
from grmtools.
https://github.com/madhavpcm/rexpl, here is the repository of the codebase im working on.
try cargo run -- input.expl
in the src folder.
Also, when I use rust-gdb I cant goto the stack frames of the parser rust code.
in parser.y
//this is the intended order of execution
let ldecl_ = $6.map_err(|_| ())?;
__gen_local_symbol_table(&ldecl_, &ParamList::Null);
let body_ = $7.map_err(|_| ())?;
however this gives the same output as the current state in the repo.
from grmtools.
I think I see what you're asking for:
$6 contains grammar for local variables and process() function generates a table for storing the details of the local variables.
$7 should only be executed after process($6?) has been executed.
In essence, all of the $
variables are assigned values before the user's code is executed. You can see this by putting log::info!
calls into LDeclBlock
and BeginBlock
.
from grmtools.
I think I see what you're asking for:
$6 contains grammar for local variables and process() function generates a table for storing the details of the local variables.
$7 should only be executed after process($6?) has been executed.In essence, all of the
$
variables are assigned values before the user's code is executed. You can see this by puttinglog::info!
calls intoLDeclBlock
andBeginBlock
.
Yes I just noticed it. I misinterpreted some things and apologize for the confusion. I may have figured out a fix for my situation.
In essence, all of the $ variables are assigned values before the user's code is executed. You can see this by putting log::info! calls into LDeclBlock and BeginBlock.
Can we override this somehow ? Otherwise I think this issue can be closed.
Thanks Alot again!,
from grmtools.
Can we override this somehow ?
There's no current mechanism, and it would be difficult to do so: grmtools would more-or-less need to read your mind!
FWIW, my preference is not to do as much in action code as you're doing. I prefer to create a minimal Abstract Syntax Tree in action code, and then have a later step which translates the AST into something else. This gives me much more control over evaluation order, and allows me to do things in a different order than dictated by the grammar. You can see a simple example of this in pizauth (https://github.com/ltratt/pizauth/blob/master/src/config.y, https://github.com/ltratt/pizauth/blob/master/src/config_ast.rs, https://github.com/ltratt/pizauth/blob/master/src/config.rs) or a more complex example in yksom (https://github.com/softdevteam/yksom/tree/master/src/lib/compiler).
Best of luck!
from grmtools.
Related Issues (20)
- Request for example of handling string literals in lexer HOT 2
- error when using fake UMINUS token in %prec directive HOT 9
- GDB Support? HOT 5
- Add support for comments in lrlex files HOT 3
- Explain why Copy is required for a type specified %parse-param HOT 7
- Nondeterministic generation of Rust code HOT 2
- Support lex-style definitions HOT 1
- Trying to replicate `tinylang.yy` and `tinylang.l` syntax with `nimbleparse` HOT 5
- Weird that `nimbleparse` works on `java7.y` `java7.l` even though the `GT` symbol in both is different. HOT 1
- Online Yacc/Lex editor/tester HOT 6
- Detailed debug info for reduce/reduce shift/reduce errors? HOT 27
- Docs Question - Optional Prefix to Regular Expressions HOT 5
- lrpar lose info about debug HOT 7
- nimbleparse:Suggestions for outputting information HOT 5
- lrlex: match beginning of line HOT 4
- lrpar:%prec not followed by token name HOT 11
- lpar:Unused rule HOT 6
- Is there a way to pass Conext in `$lexer` when doing action? HOT 3
- How to use the code generated by grmtools as a lib for others to use HOT 6
- Make generated parsers usable on the web HOT 2
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 grmtools.