• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package 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]+
26