shithub: tlsclient

ref: bfe9da47cfa2f51ebef78c59332b5ba2deba306d
dir: /third_party/boringssl/src/util/fipstools/acvp/acvptool/parser.peg/

View raw version
# Copyright (c) 2019, Google Inc.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

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]+