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

Add two new options to output the naked grammar and an EBNF #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mingodad
Copy link

@mingodad mingodad commented Jul 5, 2021

Add two new options to output the naked grammar and an EBNF to view railroad diagram at https://www.bottlecaps.de/rr/ui

Copy and paste the EBNF bellow on https://www.bottlecaps.de/rr/ui tab Edit Grammar then switch to the tab View Diagram.

bison -e examples/c/calc/calc.y

input ::=
	/* empty */
	| input line 

line ::=
	'\n' 
	| expr '\n' 
	| error '\n' 

expr ::=
	expr '+' term 
	| expr '-' term 
	| term 

term ::=
	term '*' fact 
	| term '/' fact 
	| fact 

fact ::=
	"number" 
	| '(' expr ')'

bison -n examples/c/calc/calc.y
input :
	/* empty */
	| input line 
	;

line :
	'\n' 
	| expr '\n' 
	| error '\n' 
	;

expr :
	expr '+' term 
	| expr '-' term 
	| term 
	;

term :
	term '*' fact 
	| term '/' fact 
	| fact 
	;

fact :
	"number" 
	| '(' expr ')' 
	;

@akimd
Copy link
Owner

akimd commented Sep 16, 2021

Hi!

I'm sorry for the super slow response: I had not seen your PR, and GitHub does not send me notifications (and I couldn't find how to enable them...).

The development of Bison is driven by the [email protected] mailing list, please submit your contribution there.

Have you checked how the grammar is output in the report files? Check -v and y.output, or --html and y.html. I don't think we need the -n option, we already have it, and, AFAICT, Railroad Diagram Generator does not grok it.

An option to output in BNF is interesting, why not. But we'll need documentation, tests, and most importantly, that you sign the FSF disclaimer so that I can included your contribution.

Cheers!

(Please, let's move to [email protected]).

@akimd
Copy link
Owner

akimd commented Sep 18, 2021

FWIW, I think I just found where to enable notifications :)

@mingodad
Copy link
Author

I'm working to achieve a LALR(1)/LEX to try grammars online with wasm based on https://github.com/BenHanson/gram_grep and I've got the Bison grammar working, view it here https://mingodad.github.io/parsertl-playground/playground/ select Bison parser (partially working) from the examples, you can edit the Grammar or the Input source and press Parse to see a parser tree.

I hope it can be a nice tool to experiment with LALR(1)/LEX grammars with instant feedback !

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

Successfully merging this pull request may close these issues.

2 participants