poliqarp-query-syntax

poliqarp-query-syntax — semi-formal Poliqarp query syntax description

Description

Query

[1]query::= main-query within-part? meta-part?  
[2]main-query::= simple-query |
"(" main-query ")" |
main-query "|" main-query |
main-query "^" main-query |
main-query main-query |
main-query quantifier
 
[3]simple-query::= implicit-query | segment-query  
[4]implicit-query::= flagged-regexp  
[5]segment-query::= "[" expression? "]"  

within part

[6]within-part::= simple-within-part |
phrase-within-part
 
[7]simple-within-part::= "within" regexp  
[8]phrase-within-part::= "within" "[" expression "]" /* new in Poliqarp 1.2 */

meta part

[9]meta-part::= "meta" meta-expression  
[10]meta-expression::= basic-meta-expression |
meta-expression "|" meta-expression |
meta-expression "&" meta-expression |
"(" meta-expression ")" |
"!" meta-expression
 
[11]basic-meta-expression::= identifier meta-operator flagged-regexp  
[12]meta-operator::= "<" | "<=" | ">" | ">=" | "=" | "!="  

Expressions

[13]expression::= basic-expression | variable-expression | phrase-expression |
expression "|" expression |
expression "&" expression |
"(" expression ")" |
"!" expression
 
[14]basic-expression::= identifier operator flagged-regexp  
[15]variable-expression::= identifier operator variable
/* new in Poliqarp 1.3.2 */
[16]phrase-expression::= "head" operator segment-query segment-query? |
"synh" operator segment-query |
"semh" operator segment-query
/* new in Poliqarp 1.2 */
[17]operator::= "~" | "~~" | "=" | "==" | "!~" | "!~~" | "!=" | "!=="  

Quantifiers

[18]quantifier::= "+" | "*" | "?" |
"{" integer "}" |
"{" integer? "," integer "}" |
"{" integer "," integer? "}"
 

Regular expressions

[19]flagged-regexp::= regexp | regexp "/" regexp-flag  
[20]regexp-flag::= identifier /* only of i, I, x, X characters are allowed.  */
[21]regexp::= identifier | string  

Strings and identifiers

[22]string::= "'" string-item* "'" |
'"' string-item* '"'
 
[23]string-item::= string-char | string-escape  
[24]string-char::= <any character except "\"> /* see below */
[25]string-escape::= "\" <any character> /* no implicit whitespace */
/* see below */
[26]identifier::= id-char id-ext-char* /* no implicit whitespace */
[27]id-char::= [A-Za-z] | [0-9] | ":" | "-" | "_" | "."  
[28]id-ext-char::= id-char | "*" | "+" | "?"  

String literals are enclosed in matching single quotes (') or double quotes ("). The backslash (\) character is used to escape characters that otherwise have a special meaning, or the quote character. The recognized escape sequences are:

\\

backslash (\)

\'

single quote (')

\"

double quote (")

\n

line feed (LF, U+000A)

\r

carriage return (CR, U+000D)

\t

character tabulation (U+0009)

\v

line tabulation (U+000B)

\b

backspace (U+0008)

\f

form feed (FF, U+000C)

\xhh

Unicode character with hex value hh

\uhhhh

Unicode character with hex value hhhh

\Uhhhhhhhh

Unicode character with hex value hhhhhhhh

Variables

[29]variable::= "$" [0-9] /* no implicit whitespace */
/* new in Poliqarp 1.3.2 */

Integers

[30]integer::= [0-9]+