Code Monkey home page Code Monkey logo

Comments (5)

ratmice avatar ratmice commented on June 1, 2024 1

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.

ltratt avatar ltratt commented on June 1, 2024

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.

0xadeeb avatar 0xadeeb commented on June 1, 2024

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.

ltratt avatar ltratt commented on June 1, 2024

https://github.com/softdevteam/grmtools/blob/master/lrpar/cttests/src/parseparam.test might help explain how to use it.

from grmtools.

0xadeeb avatar 0xadeeb commented on June 1, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.