// motivated by the Kerf project by Jay Aslam et al.

import edu.neu.ccs.demeter.dj.*;

Main = <s> String.
Examples = List(SawQL) EOF.
SawQL = "{" Element List(RelTimeElement) "}" .
Element : SubQuery .
RelTimeElement = [RelTime] Element.
SubQuery : Simple | Compound.
Simple = Keyword Parameter.
Keyword : Hosts | Service | IPAddress.
Hosts = "HOSTS".
Service = "SERVICE".
IPAddress = "IPADDRESS".

Compound = "(" Op <args> List(SubQuery) ")".
Op : And | Or .
And = "and".
Or  = "or".

RelTime : Minutes | Anytime.
Minutes = "+" <i> int.
Anytime = "ANYTIME".

Parameter : Constant | Variable | RegularExp  .
Constant = String.
Variable = "%" VariableName.
RegularExp = "*".
VariableName = Ident.


List(S) ~ {S}.
CList(S) ~ "(" S {"," S} ")".