Artifact
1bd67852b451a56e0ba152ab8b26b8c724c44672:
Attachment "xlsx.peg" to
ticket [3183064fff]
added by
andreas_kupries
2011-02-17 04:11:36.
PEG xlsexpr (Formula)
Formula <- Expr EOF ;
MulOp <- '<' / '>' / '=' / '*' / '/' ;
Expo <- Value ('^' Value)? ;
Prod <- Expo WS (MulOp WS Expo)* ;
AddOp <- '^' / '+' / '-' ;
Sum <- Prod WS (AddOp WS Prod)* ;
Expr <- Sum ;
void: WS <- <space>* ;
Value <- UnOp? ( '(' Expr ')' / String / Func / Range / Cell / Number ) ;
UnOp <- '-' / '+' ;
Func <- FunName '(' WS FunArgs WS ')' ;
FunName <- <alpha><alnum>* ;
FunArgs <- Expr WS (',' WS Expr)* ;
Range <- Sheet? RowCol ':' RowCol ;
Cell <- Sheet? Cell_ ;
Sheet <- "'"? Sheet_ "'"? '!' ;
Sheet_ <- [-A-Za-z0-9& ]+ ;
Cell_ <- <alpha>+<ddigit>+ ;
RowCol <- Col_ Row_ ;
Col_ <- <alpha>+ ;
Row_ <- <ddigit>+ ;
String <- '"' [A-Za-z0-9]* '"' ;
leaf: Number <- Sign? ( <ddigit>+ Frac? ) / Frac? ;
Sign <- '-' / '+' ;
Frac <- '.' <ddigit>* ;
EOF <- !. ;
END;