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