Skip to content

Grammar railroad diagram #9

@mingodad

Description

@mingodad

Would be nice if S/SL could generate an EBNF to generate a railroad diagram, I did a proof of concept with a script and a bunch of manual fixes (see bellow):

EBNF for S/SL:

//
// 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.
//

Program ::=
	InputOutputDefinitions ErrorDefinitions TypeAndMechanismDefinitions RuleDefinitions
InputOutputDefinitions ::=
     (
	 'INPUT' 	     (
		 'OUTPUT' 		    SymbolDefinitions
		| SymbolDefinitions OutputDefinitions
	    )
	| OutputDefinitions
    )
OutputDefinitions ::=
     (
	 'OUTPUT' SymbolDefinitions
	| //empty
    )
     (
	 'INPUT' 'OUTPUT' SymbolDefinitions
	| //empty
    )
SymbolDefinitions ::=
    ':' '<NL>'
    (
	 'ident' VerifyNewSymbol
	     (
		 'string' 		     VerifyNewSymbol Value
		| Value
	    )
	    '<NL>'
	| ';'
    )*
Value ::=
     (
	 '=' 	     (
		 'integer'
		| 'ident'| 'string'
	    )
	| //empty
    )
ErrorDefinitions ::=
     (
	 'ERROR' SymbolDefinitions
	| //empty
    )
TypeAndMechanismDefinitions ::=
    (
	 'TYPE' 'ident' VerifyNewSymbol SymbolDefinitions
	| 'MECHANISM' 'ident' VerifyNewSymbol OperationDefinitions
    )*
OperationDefinitions ::=
    ':' '<NL>'
    (
	 'ident' VerifyNewSymbol
	     (
		 '('
		    'ident'

		    ')'
		| //empty
	    )
	     (
		 '>>'
		    'ident'
		| //empty
	    )
	    '<NL>'
	| ';'
    )*
RuleDefinitions ::=
    'RULES' '<NL>'
    (
	 'ident'
	     (
		 '>>' 'ident'
		|  //empty
	    )
	    ':' '<NL>' Actions ';'
    )* 'END'
Actions ::=
    (
	 (
	     'string' InputOperation
	    | '?' InputAny
	    | '.' ('ident' | 'string' ) OutputOperation
	    | '#' 'ident' ErrorSignal
	    | '@' 'ident' RuleCall
	    | '>>' ReturnOperation
	    | 'ident' InputOrUpdateOperation
	    | '{' CycleAction
	    | '>' CycleExit
	    | '[' 		 (
		     'ident' SemanticChoice
		    | '@' RuleChoice
		    | '*' InputLookaheadChoice
		    | InputChoice
		)
	)
	'<NL>'
    )+
InputOperation ::=
InputAny ::=
OutputOperation ::=
ErrorSignal ::=
RuleCall ::=
ReturnOperation ::=
	 'ident'
InputOrUpdateOperation ::=
     (
	     (
		 '('
			    'ident'
		    ')'
		|  //empty
	    )
    )
CycleAction ::=
    '<NL>' Actions
    '}'
CycleExit ::=
SemanticChoice ::=
     (
	 '('
		    'ident'
	    ')'
    ) ChoiceBody
RuleChoice ::=
    'ident'
      ChoiceBody
InputLookaheadChoice ::=
   ChoiceBody
InputChoice ::=
   ChoiceBody
ChoiceBody ::=
    '<NL>' '|' Labels ':' '<NL>' Actions
    (
	 '|'
	     (
		 '*' ':' '<NL>' Actions
		| Labels ':' '<NL>' Actions
	    )
    )*
    ']'
Labels ::=
    (
	 ('ident' | 'string')
	     (
		 ','
	    )
    )*
VerifyNewSymbol ::=

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions