# oslc_where ::= “oslc.where=” compound_term # compound_term ::= simple_term (space? boolean_op space? simple_term)* # simple_term ::= term | scoped_term # space ::= “ ” /* a space character */ # boolean_op ::= “and” # term ::= identifier_wc comparison_op value | identifier_wc space in_op space? in_val # scoped_term ::= identifier_wc “{” compound_term “}” # identifier_wc ::= identifier | wildcard # identifier ::= PrefixedName # PrefixedName ::= /* see “SPARQL Query Language for RDF”, www.w3.org/TR/rdf-sparql-query/#rPrefixedName */ # wildcard ::= “*” # comparison_op ::= “=” | “!=” | “<” | “>” | “<=” | “>=” # in_op ::= “in” # in_val ::= “[” value (“,” value)* “]” # value ::= uri_ref_esc | literal_value # uri_ref_esc ::= /* an angle bracket-delimited URI reference in which > and \ are -escaped. */ # literal_value ::= boolean | decimal | string_esc (LANGTAG | (“^^” PrefixedName))? # boolean ::= “true” | “false” # decimal ::= /* see “XML Schema Part 2: Datatypes Second Edition”, www.w3.org/TR/xmlschema-2/ */ # string_esc ::= /* a string enclosed in double quotes, with certain characters escaped. See below. */ # LANGTAG ::= /* see “SPARQL Query Language for RDF”, www.w3.org/TR/rdf-sparql-query/#rLANGTAG */

# Extension # literal_value ::= | blank_value # blank_value ::= “blank”

grammar Grammar

rule decision
  binary_decision / simple_term
end

rule binary_decision
  operand_1:simple_term space? boolean_op space? operand_2:decision <Mongoid::Oslc::Grammar::BinaryDecision>
end

rule simple_term
  term
end

rule term
  field_name:field operator:comparison_op field_value:value <Mongoid::Oslc::Grammar::Condition>
  /
  field_name:field space operator:in_op space? field_value:in_val <Mongoid::Oslc::Grammar::Condition>
end

rule boolean_op
  'and'
end

rule in_op
  'in' <Mongoid::Oslc::Grammar::InOp>
end

rule in_val
  '[' first_value:value rest_values:(',' rest_value:value)* ']' <Mongoid::Oslc::Grammar::InVal>
end

rule space
  ' '
end

rule field
  [\w\:]+
end

rule comparison_op
  [\>\<\!]? [\=]? <Mongoid::Oslc::Grammar::Operator>
end

rule value
  literal_value / uri_ref_esc
end

rule uri_ref_esc
  [\w]+ <Mongoid::Oslc::Grammar::UriRefEsc>
end

rule literal_value
  boolean / decimal / string_esc / blank_value
end

rule boolean
  'true' <Mongoid::Oslc::Grammar::BooleanValue> / 'false' <Mongoid::Oslc::Grammar::BooleanValue>
end

rule blank_value
  'blank' <Mongoid::Oslc::Grammar::BlankValue>
end

rule decimal
  [\+\-]? [\d\.]+ <Mongoid::Oslc::Grammar::DecimalValue>
end

rule string_esc
  '"' [^\"]* '"' <Mongoid::Oslc::Grammar::StringEsc>
end

end