summaryrefslogtreecommitdiff
path: root/src/util/fipstools/acvp/acvptool/parser.peg
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/fipstools/acvp/acvptool/parser.peg')
-rw-r--r--src/util/fipstools/acvp/acvptool/parser.peg25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/util/fipstools/acvp/acvptool/parser.peg b/src/util/fipstools/acvp/acvptool/parser.peg
new file mode 100644
index 00000000..ca759c85
--- /dev/null
+++ b/src/util/fipstools/acvp/acvptool/parser.peg
@@ -0,0 +1,25 @@
+package main
+
+type Statement Peg {}
+
+Statement <- WS? (Assignment / Action / Expression) WS? !.
+Assignment <- Variable WS? '=' WS? Expression
+Variable <- [a-zA-Z_][a-zA-Z0-9_]*
+Expression <- (StringLiteral / Indexing / Search / Variable)
+StringLiteral <- '"' QuotedText '"'
+QuotedText <- (EscapedChar / [^\\"])*
+EscapedChar <- '\\' [\\n"]
+Indexing <- Variable ('[' Index ']')+
+Index <- [0-9a-z]+
+Search <- Variable '[' WS? 'where' WS Query ']'
+Action <- Expression '.' Command
+Command <- Function '(' Args? ')'
+Function <- [a-zA-Z]+
+Args <- StringLiteral (WS? ',' WS? Args)
+Query <- Conjunctions (WS? '||' WS? Conjunctions)?
+Conjunctions <- Conjunction (WS? '&&' WS? Conjunctions)?
+Conjunction <- Field WS? Relation WS? StringLiteral
+Field <- [a-z][a-zA-Z0-9]*
+Relation <- ('==' / '!=' / 'contains' / 'startsWith' / 'endsWith')
+
+WS <- [ \t]+