Commit 3d4df460 authored by Christopher Silva's avatar Christopher Silva

finish initial formula grammar

parent 8f49e33c
formula = _{ SOI ~ "=" ~ expr ~ EOI }
expr = _{ term ~ (infix_op ~ term)* }
expr = _{ term ~ (operation ~ term)* }
term = {
"(" ~ expr ~ ")" |
number |
function
function |
position
}
infix_op = { "+"|"-"|"*"|"/" }
operation = _{ add | subtract | multiply | divide | power }
add = { "+" }
subtract = { "-" }
multiply = { "*" }
divide = { "/" }
power = { "^" }
function = { identifier ~ "(" ~ range ~ ("," ~ criteria)? ~")" }
range = { index ~ ":" ~ index }
index = { "r" ~ uint ~ "c" ~ uint }
function = { identifier ~ "(" ~ parameter ~ ("," ~ parameter)* ~ ")" }
parameter = { range | position | criteria }
range = { position ~ ":" ~ position }
position = { "r" ~ index ~ "c" ~ index }
index = _{ absIndex | relIndex }
absIndex = { uint }
relIndex = { ("[" ~ int ~ "]")? }
criteria = { "\"" ~ comparison? ~ value ~ "\"" }
comparison = { ">"|"<"|"="|">="|"<="|"!=" }
value = { number | identifier }
comparison = _{ greaterEqual | lessEqual | notEqual | greater | less | equal }
greaterEqual = { ">=" }
lessEqual = { "<=" }
notEqual = { "<>" }
greater = { ">" }
less = { "<" }
equal = { "=" }
value = { number | string }
uint = { ASCII_DIGIT+ }
number = { "-"? ~ ASCII_DIGIT+ ~ ("." ~ ASCII_DIGIT+)?}
int = { "-"? ~ ASCII_DIGIT+ }
number = { "-"? ~ ASCII_DIGIT+ ~ ("." ~ ASCII_DIGIT+)? }
string = { ANY+ }
identifier = { ASCII_ALPHA+ }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment