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

Online grammar editor #39

Open
mingodad opened this issue Nov 19, 2023 · 0 comments
Open

Online grammar editor #39

mingodad opened this issue Nov 19, 2023 · 0 comments

Comments

@mingodad
Copy link

I've just added this project grammar to https://mingodad.github.io/parsertl-playground/playground/ (select Event compiler parser from Examples then click Parse to see a parser tree for the content in Input source).

I hope it can help document/develop/debug this project grammar !

Any feedback is welcome !

And here is an EBNF understood by https://www.bottlecaps.de/rr/ui to generate a nice navigable railroad diagram:

//
// EBNF to be viewd at https://www.bottlecaps.de/rr/ui
//
// Copy and paste this at https://www.bottlecaps.de/rr/ui in the 'Edit Grammar' tab
// then click the 'View Diagram' tab.
//

translation_unit::=
	  declaration_sequence

declaration_sequence::=
	  declaration_sequence declaration
	| declaration

declaration::=
	  event_declaration SEMIC
	| rule_declaration SEMIC
	| predicate_definition SEMIC
	| function_definition SEMIC

event_declaration::=
	  EVENT TYPE LBRACE member_sequence RBRACE
	| EVENT TYPE EXTENDS TYPE LBRACE member_sequence RBRACE

member_sequence::=
	  member_sequence COMMA member
	| member

member::=
	  IDENTIFIER

rule_declaration::=
	  TYPE COLON rule_signature RARROW IDENTIFIER

rule_signature::=
	  LBRACKET event_sequence COLON predicate_sequence RBRACKET
	| LBRACKET event_sequence RBRACKET
	| LBRACKET RBRACKET

event_sequence::=
	  event_sequence COMMA event
	| event

event::=
	  TYPE

predicate_sequence::=
	  predicate_sequence COMMA predicate
	| predicate

predicate::=
	  IDENTIFIER

predicate_definition::=
	  PREDICATE IDENTIFIER LPAREN parameter_list RPAREN DEF expression

function_definition::=
	  TYPE IDENTIFIER LPAREN RPAREN DEF expression
	| TYPE IDENTIFIER LPAREN parameter_list RPAREN DEF expression

parameter_list::=
	  parameter_list COMMA parameter
	| parameter

parameter::=
	  TYPE IDENTIFIER

function_call::=
	  IDENTIFIER LPAREN argument_sequence RPAREN
	| IDENTIFIER LPAREN RPAREN

argument_sequence::=
	  expression_sequence

event_definition::=
	  LBRACE initializer_sequence RBRACE

initializer_sequence::=
	  initializer_sequence COMMA initializer
	| initializer

initializer::=
	  IDENTIFIER ASSIGN expression

vector::=
	  LBRACKET component_sequence RBRACKET

component_sequence::=
	  expression_sequence

expression_sequence::=
	  expression_sequence COMMA expression
	| expression

expression::=
	  comparison_expression

comparison_expression::=
	  additive_expression EQ additive_expression
	| additive_expression NEQ additive_expression
	| additive_expression GT additive_expression
	| additive_expression LT additive_expression
	| additive_expression

additive_expression::=
	  addition
	| multiplicative_expression

addition::=
	  additive_expression ADD multiplicative_expression
	| additive_expression SUB multiplicative_expression

multiplicative_expression::=
	  multiplication
	| negation

multiplication::=
	  multiplicative_expression MULT negation
	| multiplicative_expression DIV negation

negation::=
	  SUB negation
	| power

power::=
	  primary_expression POW primary_expression
	| primary_expression

primary_expression::=
	  LPAREN expression RPAREN
	| atomic

atomic::=
	  IDENTIFIER DOT IDENTIFIER
	| IDENTIFIER
	| NUMBER
	| vector
	| event_definition
	| function_call

//Tokens

EVENT ::= "event"
EXTENDS ::= "extends"
PREDICATE ::= "predicate"
EQ ::= "=="
NEQ ::= "!="
GT ::= ">"
LT ::= "<"
RARROW ::= "->"
DEF ::= ":="
DOT ::= "."
COLON ::= ":"
COMMA ::= ","
SEMIC ::= ";"
LBRACE ::= "{"
RBRACE ::= "}"
LBRACKET ::= "["
RBRACKET ::= "]"
LPAREN ::= "("
RPAREN ::= ")"
ASSIGN ::= "="
ADD ::= "+"
SUB ::= "-"
MULT ::= "*"
DIV ::= "/"
POW ::= "^"
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

1 participant