blob: ca759c85d3fea81723c6cf91a097f3e51c8ca466 [file] [log] [blame]
Pete Bentley0c61efe2019-08-13 09:32:23 +01001package main
2
3type Statement Peg {}
4
5Statement <- WS? (Assignment / Action / Expression) WS? !.
6Assignment <- Variable WS? '=' WS? Expression
7Variable <- [a-zA-Z_][a-zA-Z0-9_]*
8Expression <- (StringLiteral / Indexing / Search / Variable)
9StringLiteral <- '"' QuotedText '"'
10QuotedText <- (EscapedChar / [^\\"])*
11EscapedChar <- '\\' [\\n"]
12Indexing <- Variable ('[' Index ']')+
13Index <- [0-9a-z]+
14Search <- Variable '[' WS? 'where' WS Query ']'
15Action <- Expression '.' Command
16Command <- Function '(' Args? ')'
17Function <- [a-zA-Z]+
18Args <- StringLiteral (WS? ',' WS? Args)
19Query <- Conjunctions (WS? '||' WS? Conjunctions)?
20Conjunctions <- Conjunction (WS? '&&' WS? Conjunctions)?
21Conjunction <- Field WS? Relation WS? StringLiteral
22Field <- [a-z][a-zA-Z0-9]*
23Relation <- ('==' / '!=' / 'contains' / 'startsWith' / 'endsWith')
24
25WS <- [ \t]+