--- title: Grammar author: - Quinn Dougherty --- Formal grammar specification, reference material for parser implementation. _In all likelihood the reference will have to be debugged as we see what tests pass and don't pass during implementation_. ## Lexical descriptions of constants and identifiers - `` ::= `[-]? [0-9]+ (.[0-9]+)? | [-]? [0-9]+ (.[0-9]+)? [e] [-]? [0-9]+` - `` ::= `[a-zA-Z]+ [a-zA-Z0-9]?` - `` ::= `normal(, ) | beta(, ) | triangular(, , ) | cauchy(, ) | lognormal(, )) | uniform(, ) | to | exponential()` - `` ::= `true | false` ## Expressions The following gives no typing information. You can obey the grammar and still write nonsensical code. Think of javascript's list unpacking notation to read our variable-argument function `mixture`. ``` ::= + | - | .+ | .- | | sample() | mixture(..., ) | mx(..., ) | exp() | log(, ?) | log10() | dotLog(, ?) | normalize() | isNormalized() | pdf(, ) | cdf(, ) | inv(, ) | mean() | truncate(, , ) | truncateLeft(, ) | truncateRight(, ) ::= * | | / | .* | | ::= ^ | .^ | ::= | | | | ( ) ``` ## Data structures ``` ::= [] | [] | [, ] | ... ::= {} | {: } | {: , : } | ... ``` ## Statements ``` ::= | ::= = ::= () = ``` ## A squiggle file To be valid and raise no errors as of current (apr22) interpreter, ``` ::= ; | \n ::= | | | ... ``` This isn't strictly speaking true; the interpreter allows expressions outside of the final line.