tonal-glyph / faustus

FAUST creative coding toolkit in Rust [WIP]

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Grammar railroad diagram

mingodad opened this issue · comments

Using some online tools like https://www.bottlecaps.de/rr/ui and https://www.bottlecaps.de/convert/ and a bit of manual fixes we can have a nice navigable railroad diagram.

Copy and paste the EBNF shown bellow on https://www.bottlecaps.de/rr/ui on the tab Edit Grammar the click on the tab View Diagram to see/download a navigable railroad diagram.

/* converted on Mon Dec 5, 2022, 14:07 (UTC+01) by bison-to-w3c v0.62 which is Copyright (c) 2011-2022 by Gunther Rademacher <grd@gmx.net> */
// From https://raw.githubusercontent.com/tonal-glyph/faustus/master/compiler/parser/faustparser.y
program  ::= stmtlist
stmtlist ::= statement*
deflist  ::= definition*
number   ::= ( ADD | SUB )? ( INT | FLOAT )
statement
         ::= ( IMPORT LPAR uqstring RPAR | DECLARE name name? string ) ENDDEF
           | definition
           | BDOC docelem* EDOC
docelem  ::= DOCCHAR*
           | doceqn
           | docdgm
           | docntc
           | doclst
           | docmtd
doceqn   ::= BEQN expression EEQN
docdgm   ::= BDGM expression EDGM
docntc   ::= NOTICE
doclst   ::= BLST lstattrdef* ELST
lstattrdef
         ::= ( LSTDEPENDENCIES | LSTMDOCTAGS | LSTDISTRIBUTED ) LSTEQ LSTQ lstattrval LSTQ
lstattrval
         ::= LSTTRUE
           | LSTFALSE
docmtd   ::= BMETADATA name EMETADATA
definition
         ::= ( defname ( LPAR arglist RPAR )? DEF expression | error ) ENDDEF
recinition
         ::= ( recname DEF expression | error ) ENDDEF
defname  ::= ident
recname  ::= DELAY1 ident
expression
         ::= expression ( ( WITH LBRAQ deflist | LETREC LBRAQ recinition* ) RBRAQ | ( PAR | SEQ | SPLIT | MIX | REC ) expression )
           | infixexp
infixexp ::= infixexp ( ( ADD | SUB | MUL | DIV | MOD | POWOP | FDELAY | AND | OR | XOR | LSH | RSH | LT | LE | GT | GE | EQ | NE ) infixexp | DELAY1 | DOT ident | LPAR arglist RPAR | LCROC deflist RCROC )
           | primitive
primitive
         ::= INT
           | FLOAT
           | ADD INT
           | ADD FLOAT
           | SUB INT
           | SUB FLOAT
           | WIRE
           | CUT
           | MEM
           | PREFIX
           | INTCAST
           | FLOATCAST
           | ADD
           | SUB
           | MUL
           | DIV
           | MOD
           | FDELAY
           | AND
           | OR
           | XOR
           | LSH
           | RSH
           | LT
           | LE
           | GT
           | GE
           | EQ
           | NE
           | ATTACH
           | ENABLE
           | CONTROL
           | ACOS
           | ASIN
           | ATAN
           | ATAN2
           | COS
           | SIN
           | TAN
           | EXP
           | LOG
           | LOG10
           | POWOP
           | POWFUN
           | SQRT
           | ABS
           | MIN
           | MAX
           | FMOD
           | REMAINDER
           | FLOOR
           | CEIL
           | RINT
           | RDTBL
           | RWTBL
           | SELECT2
           | SELECT3
           | ident
           | SUB ident
           | LPAR expression RPAR
           | LAMBDA LPAR ident ( PAR ident )* RPAR DOT LPAR expression RPAR
           | CASE LBRAQ rule+ RBRAQ
           | ffunction
           | fconst
           | fvariable
           | COMPONENT LPAR uqstring RPAR
           | LIBRARY LPAR uqstring RPAR
           | ENVIRONMENT LBRAQ stmtlist RBRAQ
           | WAVEFORM LBRAQ number ( PAR number )* RBRAQ
           | button
           | checkbox
           | vslider
           | hslider
           | nentry
           | vgroup
           | hgroup
           | tgroup
           | vbargraph
           | hbargraph
           | soundfile
           | fpar
           | fseq
           | fsum
           | fprod
           | finputs
           | foutputs
ident    ::= IDENT
name     ::= IDENT
arglist  ::= argument ( PAR argument )*
argument ::= argument ( SEQ | SPLIT | MIX | REC ) argument
           | infixexp
string   ::= STRING
uqstring ::= STRING
fstring  ::= STRING
           | FSTRING
fpar     ::= IPAR LPAR ident PAR argument PAR expression RPAR
fseq     ::= ISEQ LPAR ident PAR argument PAR expression RPAR
fsum     ::= ISUM LPAR ident PAR argument PAR expression RPAR
fprod    ::= IPROD LPAR ident PAR argument PAR expression RPAR
finputs  ::= INPUTS LPAR expression RPAR
foutputs ::= OUTPUTS LPAR expression RPAR
ffunction
         ::= FFUNCTION LPAR signature PAR fstring PAR string RPAR
fconst   ::= FCONSTANT LPAR type name PAR fstring RPAR
fvariable
         ::= FVARIABLE LPAR type name PAR fstring RPAR
button   ::= BUTTON LPAR uqstring RPAR
checkbox ::= CHECKBOX LPAR uqstring RPAR
vslider  ::= VSLIDER LPAR uqstring PAR argument PAR argument PAR argument PAR argument RPAR
hslider  ::= HSLIDER LPAR uqstring PAR argument PAR argument PAR argument PAR argument RPAR
nentry   ::= NENTRY LPAR uqstring PAR argument PAR argument PAR argument PAR argument RPAR
vgroup   ::= VGROUP LPAR uqstring PAR expression RPAR
hgroup   ::= HGROUP LPAR uqstring PAR expression RPAR
tgroup   ::= TGROUP LPAR uqstring PAR expression RPAR
vbargraph
         ::= VBARGRAPH LPAR uqstring PAR argument PAR argument RPAR
hbargraph
         ::= HBARGRAPH LPAR uqstring PAR argument PAR argument RPAR
soundfile
         ::= SOUNDFILE LPAR uqstring PAR argument RPAR
signature
         ::= type fun ( OR fun ( OR fun )? )? LPAR typelist? RPAR
fun      ::= IDENT
typelist ::= type ( PAR type )*
rule     ::= LPAR arglist RPAR ARROW expression ENDDEF
type     ::= INTCAST
           | FLOATCAST

//
// Tokens
//

// \("[^"]+"\)\s+return\s+\(\S[^;]+\); -> \2 ::= \1

BDOC ::= "<mdoc>"
NOTICE ::= "<notice/>" //| "<notice />"
BLST ::= "<listing"
BEQN ::= "<equation>"
EEQN ::= "</equation>"
BDGM ::= "<diagram>"
EDGM ::= "</diagram>"
BMETADATA ::= "<metadata>"
EMETADATA ::= "</metadata>"
EDOC ::= "</mdoc>"

LSTTRUE ::= "true"
LSTFALSE ::= "false"
LSTDEPENDENCIES ::= "dependencies"
LSTMDOCTAGS ::= "mdoctags"
LSTDISTRIBUTED ::= "distributed"
LSTEQ ::= "="
LSTQ ::= '"'
ELST ::= "/>"


SEQ ::= ":"
PAR ::= ","
SPLIT ::= "<:"
MIX ::= "+>"
MIX ::= ":>"
REC ::= "~"

ADD ::= "+"
SUB ::= "-"
MUL ::= "*"
DIV ::= "/"
MOD ::= "%"
FDELAY ::= "@"
DELAY1 ::= "'"

AND ::= "&"
OR ::= "|"
XOR ::= "xor"

LSH ::= "<<"
RSH ::= ">>"

LT ::= "<"
LE ::= "<="
GT ::= ">"
GE ::= ">="
EQ ::= "=="
NE ::= "!="

WIRE ::= "_"
CUT ::= "!"

ENDDEF ::= ";"
DEF ::= "="
LPAR ::= "("
RPAR ::= ")"
LBRAQ ::= "{"
RBRAQ ::= "}"
LCROC ::= "["
RCROC ::= "]"

LAMBDA ::= "\\"
DOT ::= "."
WITH ::= "with"
LETREC ::= "letrec"

MEM ::= "mem"
PREFIX ::= "prefix"

INTCAST ::= "int"
FLOATCAST ::= "float"

RDTBL ::= "rdtable"
RWTBL ::= "rwtable"

SELECT2 ::= "select2"
SELECT3 ::= "select3"

FFUNCTION ::= "ffunction"
FCONSTANT ::= "fconstant"
FVARIABLE ::= "fvariable"

BUTTON ::= "button"
CHECKBOX ::= "checkbox"
VSLIDER ::= "vslider"
HSLIDER ::= "hslider"
NENTRY ::= "nentry"
VGROUP ::= "vgroup"
HGROUP ::= "hgroup"
TGROUP ::= "tgroup"
VBARGRAPH ::= "vbargraph"
HBARGRAPH ::= "hbargraph"
SOUNDFILE ::= "soundfile"

ATTACH ::= "attach"

ACOS ::= "acos"
ASIN ::= "asin"
ATAN ::= "atan"
ATAN2 ::= "atan2"

COS ::= "cos"
SIN ::= "sin"
TAN ::= "tan"

EXP ::= "exp"
LOG ::= "log"
LOG10 ::= "log10"
POWOP ::= "^"
POWFUN ::= "pow"
SQRT ::= "sqrt"

ABS ::= "abs"
MIN ::= "min"
MAX ::= "max"

FMOD ::= "fmod"
REMAINDER ::= "remainder"

FLOOR ::= "floor"
CEIL ::= "ceil"
RINT ::= "rint"

ISEQ ::= "seq"
IPAR ::= "par"
ISUM ::= "sum"
IPROD ::= "prod"

INPUTS ::= "inputs"
OUTPUTS ::= "outputs"

IMPORT ::= "import"
COMPONENT ::= "component"
LIBRARY ::= "library"
ENVIRONMENT ::= "environment"

WAVEFORM ::= "waveform"
ENABLE ::= "enable"
CONTROL ::= "control"

DECLARE ::= "declare"

CASE ::= "case"
ARROW ::= "=>"

This is a neat idea. I doubt I have the time at the moment but FAUST will factor in to the digital audio workstation I'm designing. It would be really cool to have railroad diagrams embedded in the editor...