Open leviettung200 opened 2 years ago
Hi @leviettung200,
the goal of pybison ist to combine bison and python. It does so by implementing the grammar syntax into the docstrings of a "parser" python file. Thus, while it is possible to use C code in the lexer, pybison does not allow C code in the grammar actions. The actions of the grammar rules can however be programmatically used using python. (See the examples folder for some used cases.)
Best da-h
I'm seeking a Python, Java, JS, or C# solution that allows C code in the grammar actions. Creating a parser file enables me in parsing the input and getting the output.
Can you give me any other suggestions? Thanks @da-h !!
Python-wise, it is relatively easy to write C-extensions.
So, if C-code in the grammar actions is necessary for your solution, with an python-api I would try plain bison (instead of pybison) to generate the parser itself and write an python C-extension as an entrypoint for the resulting parser.
Can you please describe the process in greater detail?
If at all possible, I'd prefer my solution to avoid having to modify the parser file (using flex and bison files directly). e.g., writing a wrapper for C code (which helps me to compile flex and bison).
My specific problem was migrating input file parsing from on-premise to the Azure Function App
My bison file contains the action in Grammar rules. This action will call the functions declared at the end of the bison. However your library doesn't handle it, what can I do to fix it? Functions declared at the end of the bison file are necessary for business logic.
Sample Grammar rule:
Sample c code(function):