Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add complete example into ReadMe #2

Open
harrison314 opened this issue May 30, 2024 · 1 comment
Open

Please add complete example into ReadMe #2

harrison314 opened this issue May 30, 2024 · 1 comment

Comments

@harrison314
Copy link

harrison314 commented May 30, 2024

Hello,
I tried to start using parakeet because its API looks good and is practically used.

Well, at the very beginning I ran into the problem of which nuggets to install in order for the example given on CodeProject to work. I solved that.

I had a problem with practical use, I corrected the grammar, but the ReadMe lacks how to parse the input, how to pass AST or tokens,...

Could you add a complete example to the ReadMe, for example a simple calculator? It would be enough to show the grammar, show its notation in Parakeet, how to parse the input, display the AST/tokens on the console, calculate the result of the math formula (eg. 32 + 14 * (2 + 3) - 1).

I mean the grammar for the calculator, which is often used in examples for parsers:

E ::= E '+' T | E '-' T | T
T ::= T '*' F | T '/' F | F
F ::= number | '(' E ')'
number ::= `[1-9]\d*`
@Palatis
Copy link
Contributor

Palatis commented Nov 27, 2024

you might want to take a look at Parakeet.Grammars for some examples.
there are easy examples like the CsvGrammar and SExpressGrammar, or some more advanced examples such as CSharpGrammar or JsonGrammar.

basically you want to extends BaseCommonGrammar, and define your language by defining rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants