-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Using the syntax described here https://dusa.rocks/docs/language/syntax/ after small fixes (<builtin-identifier> probably is <builtin>) I've included it here https://mingodad.github.io/parsertl-playground/playground/ (an Yacc/Lex compatible online interpreter/editor, select Gusa parser from Examples then click Parse to see a parser tree for the content in Input source) and from there generated the EBNF understood by https://github.com/GuntherRademacher/rr that generate a nice navigable railroad diagram that can be viewed online (see instructions at the top bellow).
//
// 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::=
program declaration
| /*%empty*/
declaration::=
"#builtin" builtin identifier dot_opt
| "#lazy" identifier dot_opt
| "#demand" premises '.'
| "#forbid" premises '.'
| conclusion '.'
| conclusion ":-" premises '.'
dot_opt::=
/*%empty*/
| '.'
premises::=
premise
| premises ',' premise
premise::=
term oper term
| attribute
| attribute "is" term
oper::=
"=="
| "!="
| ">="
| '>'
| "<="
| '<'
conclusion::=
attribute
| attribute "is" term_or_choices
| attribute "is?" term_or_choices
term_or_choices::=
term
| '{' choice_options '}'
choice_options::=
term
| choice_options ',' term
attribute::=
identifier
| identifier arguments
arguments::=
atomic_term
| arguments atomic_term
atomic_term::=
wildcard
| variable
| string_literal
| int_literal
| identifier
| builtin
| '(' term ')'
term::=
atomic_term
| identifier arguments
| builtin arguments
builtin::=
"BOOLEAN_TRUE"
| "BOOLEAN_FALSE"
| "NAT_ZERO"
| "NAT_SUCC"
| "INT_PLUS"
| "INT_MINUS"
| "INT_TIMES"
| "STRING_CONCAT"
//Tokens
COMMENT ::= "#"[ #x09].*
variable ::= [A-Z][a-zA-Z0-9_]*
wildcard::= '_'[a-zA-Z0-9_]* // and represents variable names that you wish to be ignored.
identifier ::= [a-z][a-zA-Z0-9_]*
string_literal ::= '"'[^"]+'"' //is a regular string constant with no escape characters: two double quotes " surrounding any ASCII character in the range 32-126 except for " and \.
int_literal ::= '0'|'-'?[1-9][0-9]*
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels