Comments (5)
You can also pass a tuple to %parse-param
, so that is possible if it is inconvenient to make a struct wrapping up all of your parameters. I seem to recall there are some limitations on the parameters like being copy or shared references for reference types. (But it has been long enough that i'm not totally sure). So if you do need something like a mutable symbol table, you may need interior mutability.
There is also a mention of the tuple aspects here in the yacc compatibility section:
https://softdevteam.github.io/grmtools/master/book/yacccompatibility.html
from grmtools.
I think you might want %parse-param
which allows to pass arbitrary data of an arbitrary type to the parser. Depending on your use case, that might best be a struct
or an enum
.
from grmtools.
So if I need to send symbol table and type table to the parser, I should create another struct (let's call it ParserState) with both these data structures and use %parse-param p: &ParserState
in the .y
file and I don't need to define this in variable anywhere like in main function or so. If that's the case is variable p
defined in the parser generated by lrpar
and dropped after the parsing?
from grmtools.
https://github.com/softdevteam/grmtools/blob/master/lrpar/cttests/src/parseparam.test might help explain how to use it.
from grmtools.
Thanks for the quick replies, I could successfully do what I wanted to do. I'll close this issue now.
from grmtools.
Related Issues (20)
- Generated code incompatible with `-D rust-2018-idioms` HOT 7
- Broken links for YACC and LEX Manual in grmtools-book HOT 5
- %ignore like in flex HOT 8
- Is it possible to perform side effects while parsing? HOT 3
- Would be nice to have an online playground HOT 8
- Order of execution of grammar statements? HOT 7
- Bug in grmtools documentation - traits not displaying required method names HOT 12
- 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
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.