Jump to content

Grammar: Difference between revisions

968 bytes added ,  2 years ago
no edit summary
mNo edit summary
No edit summary
Line 10:
<verb> ::= <term> <Adverb> | <Verb>
<noun> ::= <term> "[" <Exprs> "]" | "(" <Exprs> ")" | "{" <Exprs> "}" | <Noun>
 
<tt>&lt;Adverb&gt;</tt>, <tt>&lt;Verb&gt;</tt>, and <tt>&lt;Noun&gt;</tt> can be further defined (with minor variations between dialects) as:
 
<Adverb> ::= "'" | "/" | "\" | "':" | "/:" | "\:"
<Verb> ::= <Verb1> | <Verb1> ":"
<Verb1> ::= ":" | "+" | "-" | "*" | "%" | "!" | "&" | "|" | "<" | ">" | "=" | "~" | "," |
"^" | "#" | "_" | "$" | "?" | "@" | "." | <Digit> ":"
<Noun> ::= <Names> | <Ints> | <Floats> | <CharsString> | <Symbols>
<Names> ::= <Names> "." <Name> | <Name>
..
<Name> ::= <Letter> | <Name> <Letter> | <Name> <Digit>
<Ints> ::= <Int> | <Ints> " " <Int>
<Int> ::= "-" <Digits> | <Digits>
<Floats> ::= <Float> | <Floats> " " <Float>
<Float> ::= <Int> | <Int> "." <Digits> | <Int> "." <Digits> "e" <Int>
<String> ::= '"' <Chars> '"' | "0x" <Bytes>
<Chars> ::= <Chars> <Char> | empty
<Char> ::= "\0" | "\t" | "\n" | "\r" | '\"' | "\\" | any
<Bytes> ::= <Bytes> <Hex> <Hex> | empty
<Symbols>::= <Symbols> <Symbol> | <Symbol>
<Symbol> ::= "`" | "`" <Name> | "`" <String>
<Digits> ::= <Digit> | <Digits> <Digit>
<Digit> ::= "0" | .. | "9"
<Hex> ::= <Digit> | "a" | .. | "f"
<Letter> ::= "A" | .. | "Z" | "a" | .. | "z"
 
K can be parsed statically - no knowledge about the runtime values of variables is required to build a parse tree.
Cookies help us deliver our services. By using our services, you agree to our use of cookies.