Skip to content

Grammar railroad diagram #91

@mingodad

Description

@mingodad

I've just added jscc grammar to https://mingodad.github.io/parsertl-playground/playground/ an Yacc/Lex compatible browser based interpreter/editor (select Jscc parser from Examples then click Parse to see a parse tree for the content in Input source) and also generated an EBNF undertood by https://github.com/GuntherRademacher/rr to generate a nice navigable railroad diagram (see bellow with instructions at the top).

//
// EBNF to be viewd at
//    (IPV6) https://www.bottlecaps.de/rr/ui
//    (IPV4) https://rr.red-dove.com/ui
//
// Copy and paste this at one of the urls shown above in the 'Edit Grammar' tab
// then click the 'View Diagram' tab.
//

def::=
	  header_code token_assocs "##" grammar_defs footer_code

header_code::=
	  code_opt

footer_code::=
	  code_opt

token_assocs::=
	  token_assocs token_assoc
	| token_assoc

token_assoc::=
	  PREC_LEFT token_defs ';'
	| PREC_RIGHT token_defs ';'
	| PREC_NONASSOC token_defs ';'
	| token_defs ';'
	| WS_IGNORE string opt_semicolon

token_defs::=
	  token_defs token_def
	| token_def

token_def::=
	  string identifier code_opt
	| string code_opt

grammar_defs::=
	  grammar_defs grammar_def
	| grammar_def

grammar_def::=
	  identifier ':' productions ';'

productions::=
	  productions '|' rhs
	| rhs

rhs::=
	  sequence_opt rhs_prec code_opt

rhs_prec::=
	  '&' identifier
	| '&' string
	| /*%empty*/

sequence_opt::=
	  sequence
	| /*%empty*/

sequence::=
	  sequence symbol
	| symbol

symbol::=
	  identifier
	| string
	| ON_ERROR

code_opt::=
	  code
	| "=>" identifier
	| "=>" CODE
	| /*%empty*/

code::=
	  code CODE
	| CODE

string::=
	  STRING_SINGLE
	| STRING_DOUBLE

identifier::=
	  IDENT

opt_semicolon::=
	  ';'
	| /*%empty*/

//Tokens

PREC_LEFT ::= "<"	
PREC_RIGHT::= ">"	
PREC_NONASSOC ::= "^"	
WS_IGNORE ::= "!"	
ON_ERROR ::= "~"	

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions