xref: /aosp_15_r20/external/boringssl/src/util/fipstools/acvp/acvptool/parser.peg (revision 8fb009dc861624b67b6cdb62ea21f0f22d0c584b)
1# Copyright (c) 2019, Google Inc.
2#
3# Permission to use, copy, modify, and/or distribute this software for any
4# purpose with or without fee is hereby granted, provided that the above
5# copyright notice and this permission notice appear in all copies.
6#
7# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
15package main
16
17type Statement Peg {}
18
19Statement <- WS? (Assignment / Action / Expression) WS? !.
20Assignment <- Variable WS? '=' WS? Expression
21Variable <- [a-zA-Z_][a-zA-Z0-9_]*
22Expression <- (StringLiteral / Indexing / Search / Variable)
23StringLiteral <- '"' QuotedText '"'
24QuotedText <- (EscapedChar / [^\\"])*
25EscapedChar <- '\\' [\\n"]
26Indexing <- Variable ('[' Index ']')+
27Index <- [0-9a-z]+
28Search <- Variable '[' WS? 'where' WS Query ']'
29Action <- Expression '.' Command
30Command <- Function '(' Args? ')'
31Function <- [a-zA-Z]+
32Args <- StringLiteral (WS? ',' WS? Args)
33Query <- Conjunctions (WS? '||' WS? Conjunctions)?
34Conjunctions <- Conjunction (WS? '&&' WS? Conjunctions)?
35Conjunction <- Field WS? Relation WS? StringLiteral
36Field <- [a-z][a-zA-Z0-9]*
37Relation <- ('==' / '!=' / 'contains' / 'startsWith' / 'endsWith')
38
39WS <- [ \t]+
40