Skip to content

Instantly share code, notes, and snippets.

@tinfoil-knight
Created December 3, 2023 15:55
Show Gist options
  • Save tinfoil-knight/88f1b7bdf84581c96beea50deb91a4da to your computer and use it in GitHub Desktop.
Save tinfoil-knight/88f1b7bdf84581c96beea50deb91a4da to your computer and use it in GitHub Desktop.
MediaExpr {
// Syntax Grammar
Main = Expression
Expression = LogicOr
LogicOr = LogicAnd ("or" LogicAnd)*
LogicAnd = Equality ("and" Equality)*
Equality = Comparison (("!=" | "==") Comparison)*
Comparison = Term ((">" | ">=" | "<" | "<=") Term)*
Term = Factor (("-" | "+") Factor)*
Factor = Exponent (("/" | "*" | "%") Exponent)*
Exponent = Unary ("^" Unary)*
Unary = ("!" | "-") Unary --unary
| Literal
Literal = "(" Expression ")" --parens
| bool
| number
| variable
// Lexical Grammar
bool = "true" | "false"
number = decimal | whole
decimal = digit* "." digit+
whole = digit+
variable = letter alnum*
/*
alnum (an alpha-numeric character) = letter
| digit
digit (a digit) = "0".."9"
letter (a letter) = lower
| upper
| unicodeLtmo
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment