Formal Syntax for the PAT Text Searching Language

Originally produced May 10, 1990
Centre for the New OED and Text Research, University of Waterloo
Edited for HTML access by Frank Tompa

PAT is a registered trademark of Open Text Corporation

The following grammar describes the formal syntax of the query language accepted by PAT.

   Statement    :  IndexControl | EnvirControl
                |  Query
                |   "=" Query
                |  Print
                |  "history"
                |  "stop" | "quit" | "done"
                |  

   Query        :  Boolean
                |  OpCode OptParam OptQuery

   Boolean      :  Boolean "+" ABoolean
                |  ABoolean

   ABoolean     :  ABoolean  "^"  RBoolean
                |  NxtBoolean
                |  RBoolean "not" "nxt" Proxim RBoolean
                |  FbyBoolean
                |  RBoolean "not" "fby" Proxim RBoolean
                |  DiffBoolean
                |  RBoolean

   FbyBoolean   :  RBoolean "fby" Proxim FbyBoolean
                |  RBoolean "fby" Proxim RBoolean

   NxtBoolean   :  RBoolean "nxt" Proxim NxtBoolean
                |  RBoolean "nxt" Proxim RBoolean

   DiffBoolean  :  DiffBoolean "-" RBoolean
                |  RBoolean "-" RBoolean
                |  RBoolean "including" OptParam RBoolean
                |  RBoolean "within" RBoolean

   RBoolean     :  PrimBoolean
                |   ".." 
                |  "docs"
                |  "docs" 
                |  "docs" PrimBoolean ".." PrimBoolean

   PrimBoolean  :  
                |  "(" Query ")"
                |  
                |  "["  "]"
                |  "*" 
                |  "%"

   Proxim       :   | "." 

   OpCode       :  "lrep" | "sample" | "signif" | "shift"

   OptParam     :   | "."  | "." "-" 

   OptQuery     :   | Query

   IndexControl :  "{" "Mode"  "}"
                |  "{" "CharMappings"  Sep ListOfWords "}"
                |  "{" "StopWords" ListOfWords "}"
                |  "{" "NumberChars"  "}"
                |  "{" "NumberExtNodes"  "}"
                |  "{" "LongestMatch"  "}"
                |  "{" "WordSeparators"  "}"
                |  "{" "HashValue"  "}"

   EnvirControl :  "{" "PrintMode"  "}"
                |  "{" "PrintLength"  "}"
                |  "{" "Proximity"  "}"
                |  "{" "SampleSize"  "}"
                |  "{" "Textfilename" TextData "}"
                |  "{" "TreeFilename"  "}"
                |  "{" "SaveFile"  "}"
                |  "{" "DocumentFile"  "}"

   ListOfWords :   | ListOfWords Sep 

   TextData     :  TextDatum | TextData Sep TextDatum

   TextDatum    :   ":"  ".."  "(" ) ")"

   Print        :  ("pr"|"save") OptLength OptQuery
                |  ("pr"|"save") PrDocs OptQuery

   PrDocs       :  "." docs
                |  "." docs DocsRef

   DocsRef      :  
                |  
                |  "*" 

   OptLength    :   | "." 

   Sep          :   | "," |