Allen Brain Atlas API: RMA Grammar

# The Pipeline
expr : stage*
stage : model_stage | service_stage | pipe_stage

# Pipeline Stages
model_stage : model_step (rma_option_step | filters | includes)*
service_stage : service_step filters
pipe_stage : pipe_step filters

# Axis Steps
model_step : 'model' '::' ID
rma_step : 'rma' '::' ID
rma_option_step : 'rma' '::' 'option'
attribute_step : ('attribute' '::')? ID
service_step : 'service' '::' ID
pipe_step : 'pipe' '::' ID

# Filters (also used as Parameters)
filters : ('[' qcolumn operator filter_list ']')+
qcolumn : (ID '.')? ID
operator :  '$' ('eq' | 'ne' | 'li' | 'gt' | 'lt' | 'ge' | 'le' | 'in' | 'il' | 'is')
filter_list : filter_element (',' filter_element)*
filter_element : (STRING | REAL | INTEGER | variable | qcolumn | NIL)

# Association Includes (and Criteria)
includes : attribute_step filters? ('(' include_terms ')')+
include_terms : includes (',' includes)*

# Literals
STRING : '\'' (.)* '\''
REAL : INTEGER* '.' INTEGER+ ;
INTEGER : DIGIT+;
variable : '$' ID
ID : (ID_START | '*') (ID_CHAR | WILDCARD)*
ID_CHAR  ID_START | DIGIT ;
ID_START : ('A'..'Z' | 'a'..'z' | '_' )
DIGIT : '0'..'9'