# aqp

Another go at creating tooling for Congress.gov's legislation text query syntax.

The parsing code started as an attempt to implement this grammar:

```
Query {
 
    Exp = ( ParenExp | Prox | Boolean | term | not )+
     
    ParenExp =  "(" Exp ")"
         
    Prox = ( "n" | "N" |  "w" | "W" ) "/" digit+ ParenProxArgs
     
    ParenProxArgs = "(" ( ProxArgs | ParenProxArgs ) ")"
         
    ProxArgs = literal+ | ( Prox | Boolean | nonliteral )+
         
    Boolean = ("+" | "~") ( BoolArgs | ParenBoolArgs )
     
    ParenBoolArgs = "(" ( BoolArgs+ | ParenBoolArgs+ ) ")"
     
    BoolArgs =  Prox | Boolean | term
     
    // tokens
         
    term = nonliteral | literal
         
    nonliteral = wildcard | phrase | bare
         
    phrase = "\"" ( bare | space )+ "\""
         
    literal = "'" bare "'"
         
    wildcard = bare "*"
         
    not = "!" term
     
    // may need to add more punctuation
 
    bare = ( alnum | space | "," | "." | "%" | "$" )+ ~"/"
         
}
```

However, the implementation has likely diverged from the grammar. Copy and paste the grammar into https://ohmjs.org/editor/ to try it out.
