DOCUMENT START TOKENS // ------------------------------------------ // Tokens // Comments and whitespace SKIP : { " " | "\t" | "\n" | "\r" | "\f" } TOKEN : { <#WS: " " | "\t" | "\n" | "\r" | "\f"> } SPECIAL : { } // Main tokens */ TOKEN : { ","<","\"","{","}","^","\\","|","`","\u0000"-" "])* ">"> | )? ":"> | > | > | > | > | ()+ ("-" ()+)*> | <#A2Z: ["a"-"z","A"-"Z"]> | <#A2ZN: ["a"-"z","A"-"Z","0"-"9"]> } // ------------------------------------------------- // Keyworks : includes operators that are words and should be // before general things like IDENTIFIER which swallow almost // anything TOKEN : { } TOKEN [IGNORE_CASE] : { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | } // ------------------------------------------------- TOKEN : { <#DIGITS: (["0"-"9"])+> | > | "." ()* | "." > | | "." (["0"-"9"])+ | (["0"-"9"])+ > | > | > | > | > | > | > | <#EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+> | <#QUOTE_3D: "\"\"\""> | <#QUOTE_3S: "\'\'\'"> | | )* "\'"> | )* "\""> | (("\'" | "\'\'")? (~["\'","\\"] | ))* > | (("\"" | "\"\"")? (~["\"","\\"] | ))* > } TOKEN : { | | ( | )* > | | | | | ( | )* > | | | | "> | | ="> | | | | | | | | | | | } // See XML chars.txt for notes TOKEN : { <#PN_CHARS_BASE: ["A"-"Z"] | ["a"-"z"] | ["\u00c0"-"\u00d6"] | ["\u00d8"-"\u00f6"] | ["\u00f8"-"\u02ff"] | ["\u0370"-"\u037d"] | ["\u037f"-"\u1fff"] | ["\u200c"-"\u200d"] | ["\u2070"-"\u218f"] | ["\u2c00"-"\u2fef"] | ["\u3001"-"\ud7ff"] | ["\uf900"-"\ufffd"]> | <#PN_CHARS_U: | "_"> | <#PN_CHARS: | "-" | ["0"-"9"] | "\u00b7" | ["\u0300"-"\u036f"] | ["\u203f"-"\u2040"]> | <#PN_PREFIX: (( | ".")* )?> | <#PN_LOCAL: ( | ["0"-"9"]) (( | ".")* )?> | <#VARNAME: ( | ["0"-"9"]) ( | ["0"-"9"] | "\u00b7" | ["\u0300"-"\u036f"] | ["\u203f"-"\u2040"])*> } // Catch-all tokens. Must be last. // Any non-whitespace. Causes a parser exception, rather than a // token manager error (with hidden line numbers). // Only bad IRIs (e.g. spaces) now give unhelpful parse errors. TOKEN : { <#UNKNOWN: (~[" ","\t","\n","\r","\f"])+> } NON-TERMINALS QueryUnit := Query Query := Prologue ( SelectQuery | ConstructQuery | DescribeQuery | AskQuery ) Prologue := ( BaseDecl )? ( PrefixDecl )* BaseDecl := IRI_REF PrefixDecl := IRI_REF // ---- Query type clauses SelectQuery := Project ( DatasetClause )* WhereClause SolutionModifier SubSelect := Project WhereClause SolutionModifier Project :=