Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Kick off

  • Loading branch information...
commit 33be0dc0a3a64e5c209d49d889c37359bad8344d 0 parents
Huy Phan authored
21 pysparql/__init__.py
... ... @@ -0,0 +1,21 @@
  1 +__version__ = "0.1"
  2 +__date__ = "2011/03/24"
  3 +
  4 +__all__ = [
  5 + 'Lexer',
  6 + 'Parser'
  7 + ]
  8 +
  9 +import sys
  10 +
  11 +# generator expressions require 2.4
  12 +assert sys.version_info >= (2, 4, 0), "yardflib requires Python 2.4 or higher"
  13 +del sys
  14 +
  15 +import logging
  16 +_LOGGER = logging.getLogger("pysparql")
  17 +_LOGGER.info("version: %s" % __version__)
  18 +
  19 +
  20 +from pysparql.lexer import Lexer
  21 +from pysparql.parser import Parser
13 pysparql/extensions.py
... ... @@ -0,0 +1,13 @@
  1 +from yardflib import Query
  2 +from utils import flatten
  3 +
  4 +class GroupQuery(list):
  5 +
  6 + def __init__(self, queries = [], operation = 'join', options = {}):
  7 + self.queries = filter(lambda x: x!=None, flatten(queries))
  8 + super(GroupQuery, self).__init__(queries)
  9 + self.operation = operation
  10 +
  11 + def to_sxa(self):
  12 + return [operation] + map(self, lambda x: x.to_sxa())
  13 +
170 pysparql/lexer.py
... ... @@ -0,0 +1,170 @@
  1 +import re
  2 +
  3 +class Scanner (object):
  4 +
  5 + def __init__(self, s):
  6 + self.s = s
  7 + self.offset = 0
  8 +
  9 + def eos(self):
  10 + return self.offset == len(self.s)
  11 +
  12 + def rest(self):
  13 + return self.s[self.offset:]
  14 +
  15 + def scan(self, pattern):
  16 + match = pattern.match(self.s, self.offset)
  17 + if match is not None:
  18 + self.offset = match.end()
  19 + return match
  20 + return None
  21 +
  22 +class Token (object):
  23 +
  24 + def __init__(self, type, value = None, options = {}):
  25 + self.type = type
  26 + self.value = value
  27 + self.lineno = options['lineno']
  28 +
  29 + def __repr__(self):
  30 + return "%s : %s" % (self.type, self.value)
  31 +
  32 + @property
  33 + def representation(self):
  34 + return self.type if self.type else self.value
  35 +
  36 +class TokenError(Exception):
  37 +
  38 + def __init__(self, message, options = {}):
  39 + self._message = message
  40 + self.query = options.get('query')
  41 + self.token = options.get('token')
  42 + self.lineno = options.get('lineno')
  43 +
  44 + def __str__(self):
  45 + return repr(self._message)
  46 +
  47 +class Lexer:
  48 +
  49 + ESCAPE_CHARS = {
  50 + '\\t' : "\t", # \u0009 (tab)
  51 + '\\n' : "\n", # \u000A (line feed)
  52 + '\\r' : "\r", # \u000D (carriage return)
  53 + '\\b' : "\b", # \u0008 (backspace)
  54 + '\\f' : "\f", # \u000C (form feed)
  55 + '\\"' : '"', # \u0022 (quotation mark, double quote mark)
  56 + '\\\'' : '\'', # \u0027 (apostrophe-quote, single quote mark)
  57 + '\\\\' : '\\' # \u005C (backslash)
  58 + }
  59 +
  60 + KEYWORDS = ['SELECT','CONSTRUCT','DESCRIBE','ASK','BASE','PREFIX','LIMIT','OFFSET','DISTINCT','REDUCED','ORDER','BY','ASC','DESC','FROM','NAMED','WHERE','GRAPH','OPTIONAL','UNION','FILTER']
  61 + FUNCTIONS = ['STR','LANGMATCHES','LANG','DATATYPE','BOUND','sameTerm','isIRI','isURI','isBLANK','isLITERAL','REGEX']
  62 + VAR1 = re.compile("\?([0-9]|_|[A-Z]|[a-z])*")
  63 + VAR2 = re.compile("\$([0-9]|_|[A-Z]|[a-z])*")
  64 + IRI_REF = re.compile("<([^<>\"{}|^`\\\x00-\x20]*)>")
  65 +
  66 + PN_CHARS_BASE = "[A-Z]|[a-z]"
  67 + PN_CHARS_U = "_|[A-Z]|[a-z]"
  68 + PN_CHARS = "-|[0-9]|%s" % PN_CHARS_U
  69 + PN_CHARS_BODY = "(?:(?:\.|%s)*(?:%s))?" % (PN_CHARS, PN_CHARS)
  70 + PN_PREFIX = "%s%s" % (PN_CHARS_BASE, PN_CHARS_BODY)
  71 + PN_LOCAL = "(?:[0-9]|%s)%s" % (PN_CHARS_U, PN_CHARS_BODY)
  72 + ECHAR = "\\\[tbnrf\\\"']"
  73 + EXPONENT = "[eE][+-]?[0-9]+"
  74 +
  75 + WS = re.compile("(\x20|\x09|\x0D|\x0A)+")
  76 + COMMENT = re.compile("#.*")
  77 +
  78 + VAR1 = re.compile("\?([0-9_A-Za-z]*)")
  79 + VAR2 = re.compile("\$([0-9_A-Za-z]*)")
  80 + IRI_REF = re.compile("<([^<>\"{}|^`\\\x00-\x20]*)>")
  81 + PNAME_LN = re.compile("(%s?):(%s)" % (PN_PREFIX, PN_LOCAL))
  82 + PNAME_NS = re.compile("(%s?):" % PN_PREFIX)
  83 + STRING_LITERAL_LONG1 = re.compile("'''((?:(?:'|'')?(?:[^'\\]|%s)+)*)'''" % ECHAR, re.M)
  84 + STRING_LITERAL_LONG2 = re.compile("\"\"\"((?:(?:\"|\"\")?(?:[^\"\\]|%s)+)*)\"\"\"" % ECHAR, re.M)
  85 + STRING_LITERAL1 = re.compile("'((?:[^\x27\x5C\x0A\x0D]|%s)*)'" % ECHAR)
  86 + STRING_LITERAL2 = re.compile("\"((?:[^\x22\x5C\x0A\x0D]|%s)*)\"" % ECHAR)
  87 +
  88 + LANGTAG = re.compile("@([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)")
  89 + DOUBLE = re.compile("(?:[0-9]+\.[0-9]*|\.[0-9]+|[0-9]+)%s" % EXPONENT)
  90 + INTEGER = re.compile("[0-9]+")
  91 + DECIMAL = re.compile("(?:[0-9]+\.[0-9]*|\.[0-9]+)")
  92 + DOUBLE = re.compile("(?:[0-9]+\.[0-9]*|\.[0-9]+|[0-9]+)%s" % EXPONENT)
  93 + BooleanLiteral = re.compile("true|false")
  94 + BLANK_NODE_LABEL = re.compile("_:(%s)" % PN_LOCAL)
  95 +
  96 + NIL = re.compile("\(\x20|\x09|\x0D|\x0A*\)")
  97 + ANON = re.compile("\[\x20|\x09|\x0D|\x0A*\]")
  98 +
  99 + KEYWORD = re.compile("%s|%s" % ("|".join(KEYWORDS), "|".join(FUNCTIONS)))
  100 + DELIMITER = re.compile("\^\^|[{}\(\)\[\],;\.]")
  101 + OPERATOR = re.compile("a|\|\||&&|!=|<=|>=|[!=<>+\-*\/]")
  102 +
  103 +
  104 + patterns = [ 'VAR1', 'VAR2', 'IRI_REF', 'PNAME_LN', 'PNAME_NS', 'STRING_LITERAL_LONG1', 'STRING_LITERAL_LONG2',
  105 + 'STRING_LITERAL1', 'STRING_LITERAL2', 'LANGTAG', 'DOUBLE', 'DECIMAL', 'INTEGER', 'BooleanLiteral',
  106 + 'BLANK_NODE_LABEL', 'KEYWORD', 'DELIMITER', 'OPERATOR' ,'NIL', 'ANON'
  107 + ]
  108 +
  109 + def __init__(self, query, options = {}):
  110 + self.query = query
  111 + self.lineno = 0
  112 +
  113 + def unescape_string(self, s):
  114 + return re.sub(self.ECHAR, lambda escaped: self.ESCAPE_CHARS[escaped.group(0)] , s)
  115 +
  116 + def token(self, type, value = None):
  117 + return Token(type, value, {'lineno' : self.lineno})
  118 +
  119 + def tokens(self):
  120 + self.lineno = 0
  121 + scanner = Scanner(self.query)
  122 + t = scanner.scan(self.WS)
  123 + while not scanner.eos():
  124 + if t: self.lineno += t.group(0).count("\n")
  125 +
  126 + scanner.scan(self.COMMENT)
  127 +
  128 + t = None
  129 + for pattern in self.patterns:
  130 + t = scanner.scan(getattr(self,pattern))
  131 + if t is not None:
  132 + break
  133 +
  134 + if t is not None:
  135 + if pattern == 'PNAME_LN':
  136 + yield self.token(pattern, [t.group(1),t.group(2)])
  137 +
  138 + elif pattern in ['STRING_LITERAL_LONG1', 'STRING_LITERAL_LONG2', 'STRING_LITERAL1', 'STRING_LITERAL2']:
  139 + yield self.token(pattern, self.unescape_string(t.group(0)))
  140 +
  141 + elif pattern in ['DOUBLE', 'DECIMAL', 'INTEGER', 'BooleanLiteral', 'DOUBLE']:
  142 + yield self.token(pattern, t.group(0))
  143 +
  144 + elif pattern in ['DECIMAL', 'INTEGER']:
  145 + yield self.token(pattern, t.group(0))
  146 +
  147 + elif pattern in ['OPERATOR', 'DELIMITER']:
  148 + yield self.token(None, t.group(0))
  149 +
  150 + elif pattern in ['NIL', 'ANON']:
  151 + yield self.token(pattern)
  152 +
  153 +
  154 + elif pattern == 'KEYWORD':
  155 + yield self.token(None, t.group(0).upper())
  156 +
  157 + else:
  158 + yield self.token(pattern, t.group(1))
  159 +
  160 + else: # t is None
  161 + try:
  162 + lexeme = re.split("\x20|\x09|\x0D|\x0A|#.*",scanner.rest())[0]
  163 + except Exeption, e:
  164 + lexeme = scanner.rest()
  165 + raise TokenError("invalid token %s at line %d" % (repr(lexeme), self.lineno + 1),
  166 + {'input' : self.query, 'token' : lexeme, 'lineno' : self.lineno} )
  167 +
  168 + break
  169 +
  170 + t = scanner.scan(self.WS)
1,790 pysparql/meta.py
... ... @@ -0,0 +1,1790 @@
  1 +BRANCHES = {
  2 + 'AdditiveExpression' : {
  3 + "!" : ['MultiplicativeExpression',
  4 + '_Add_Sub_MultiplicativeExpression_Star'],
  5 + "(" : ['MultiplicativeExpression',
  6 + '_Add_Sub_MultiplicativeExpression_Star'],
  7 + "+" : ['MultiplicativeExpression',
  8 + '_Add_Sub_MultiplicativeExpression_Star'],
  9 + "-" : ['MultiplicativeExpression',
  10 + '_Add_Sub_MultiplicativeExpression_Star'],
  11 + "BOUND" : ['MultiplicativeExpression',
  12 + '_Add_Sub_MultiplicativeExpression_Star'],
  13 + "DATATYPE" : ['MultiplicativeExpression',
  14 + '_Add_Sub_MultiplicativeExpression_Star'],
  15 + "LANG" : ['MultiplicativeExpression',
  16 + '_Add_Sub_MultiplicativeExpression_Star'],
  17 + "LANGMATCHES" : ['MultiplicativeExpression',
  18 + '_Add_Sub_MultiplicativeExpression_Star'],
  19 + "REGEX" : ['MultiplicativeExpression',
  20 + '_Add_Sub_MultiplicativeExpression_Star'],
  21 + "STR" : ['MultiplicativeExpression',
  22 + '_Add_Sub_MultiplicativeExpression_Star'],
  23 + 'BooleanLiteral' : ['MultiplicativeExpression',
  24 + '_Add_Sub_MultiplicativeExpression_Star'],
  25 + 'DECIMAL' : ['MultiplicativeExpression',
  26 + '_Add_Sub_MultiplicativeExpression_Star'],
  27 + 'DOUBLE' : ['MultiplicativeExpression',
  28 + '_Add_Sub_MultiplicativeExpression_Star'],
  29 + 'INTEGER' : ['MultiplicativeExpression',
  30 + '_Add_Sub_MultiplicativeExpression_Star'],
  31 + 'IRI_REF' : ['MultiplicativeExpression',
  32 + '_Add_Sub_MultiplicativeExpression_Star'],
  33 + 'PNAME_LN' : ['MultiplicativeExpression',
  34 + '_Add_Sub_MultiplicativeExpression_Star'],
  35 + 'PNAME_NS' : ['MultiplicativeExpression',
  36 + '_Add_Sub_MultiplicativeExpression_Star'],
  37 + 'STRING_LITERAL1' : ['MultiplicativeExpression',
  38 + '_Add_Sub_MultiplicativeExpression_Star'],
  39 + 'STRING_LITERAL2' : ['MultiplicativeExpression',
  40 + '_Add_Sub_MultiplicativeExpression_Star'],
  41 + 'STRING_LITERAL_LONG1' : ['MultiplicativeExpression',
  42 + '_Add_Sub_MultiplicativeExpression_Star'],
  43 + 'STRING_LITERAL_LONG2' : ['MultiplicativeExpression',
  44 + '_Add_Sub_MultiplicativeExpression_Star'],
  45 + 'VAR1' : ['MultiplicativeExpression',
  46 + '_Add_Sub_MultiplicativeExpression_Star'],
  47 + 'VAR2' : ['MultiplicativeExpression',
  48 + '_Add_Sub_MultiplicativeExpression_Star'],
  49 + "ISBLANK" : ['MultiplicativeExpression',
  50 + '_Add_Sub_MultiplicativeExpression_Star'],
  51 + "ISIRI" : ['MultiplicativeExpression',
  52 + '_Add_Sub_MultiplicativeExpression_Star'],
  53 + "ISLITERAL" : ['MultiplicativeExpression',
  54 + '_Add_Sub_MultiplicativeExpression_Star'],
  55 + "ISURI" : ['MultiplicativeExpression',
  56 + '_Add_Sub_MultiplicativeExpression_Star'],
  57 + "SAMETERM" : ['MultiplicativeExpression',
  58 + '_Add_Sub_MultiplicativeExpression_Star'],
  59 + },
  60 + 'ArgList' : {
  61 + "(" : ["(",
  62 + '_Expression_COMMA_Expression_Star',
  63 + ")"],
  64 + 'NIL' : ['NIL'],
  65 + },
  66 + 'AskQuery' : {
  67 + "ASK" : ["ASK",
  68 + '_DatasetClause_Star',
  69 + 'WhereClause'],
  70 + },
  71 + 'BaseDecl' : {
  72 + "BASE" : ["BASE",
  73 + 'IRI_REF'],
  74 + },
  75 + 'BlankNode' : {
  76 + 'ANON' : ['ANON'],
  77 + 'BLANK_NODE_LABEL' : ['BLANK_NODE_LABEL'],
  78 + },
  79 + 'BlankNodePropertyList' : {
  80 + "[" : ["[",
  81 + 'PropertyListNotEmpty',
  82 + "]"],
  83 + },
  84 + 'BrackettedExpression' : {
  85 + "(" : ["(",
  86 + 'Expression',
  87 + ")"],
  88 + },
  89 + 'BuiltInCall' : {
  90 + "BOUND" : ["BOUND",
  91 + "(",
  92 + 'Var',
  93 + ")"],
  94 + "DATATYPE" : ["DATATYPE",
  95 + "(",
  96 + 'Expression',
  97 + ")"],
  98 + "LANG" : ["LANG",
  99 + "(",
  100 + 'Expression',
  101 + ")"],
  102 + "LANGMATCHES" : ["LANGMATCHES",
  103 + "(",
  104 + 'Expression',
  105 + ",",
  106 + 'Expression',
  107 + ")"],
  108 + "REGEX" : ['RegexExpression'],
  109 + "STR" : ["STR",
  110 + "(",
  111 + 'Expression',
  112 + ")"],
  113 + "ISBLANK" : ["ISBLANK",
  114 + "(",
  115 + 'Expression',
  116 + ")"],
  117 + "ISIRI" : ["ISIRI",
  118 + "(",
  119 + 'Expression',
  120 + ")"],
  121 + "ISLITERAL" : ["ISLITERAL",
  122 + "(",
  123 + 'Expression',
  124 + ")"],
  125 + "ISURI" : ["ISURI",
  126 + "(",
  127 + 'Expression',
  128 + ")"],
  129 + "SAMETERM" : ["SAMETERM",
  130 + "(",
  131 + 'Expression',
  132 + ",",
  133 + 'Expression',
  134 + ")"],
  135 + },
  136 + 'Collection' : {
  137 + "(" : ["(",
  138 + '_GraphNode_Plus',
  139 + ")"],
  140 + },
  141 + 'ConditionalAndExpression' : {
  142 + "!" : ['ValueLogical',
  143 + '_AND_ValueLogical_Star'],
  144 + "(" : ['ValueLogical',
  145 + '_AND_ValueLogical_Star'],
  146 + "+" : ['ValueLogical',
  147 + '_AND_ValueLogical_Star'],
  148 + "-" : ['ValueLogical',
  149 + '_AND_ValueLogical_Star'],
  150 + "BOUND" : ['ValueLogical',
  151 + '_AND_ValueLogical_Star'],
  152 + "DATATYPE" : ['ValueLogical',
  153 + '_AND_ValueLogical_Star'],
  154 + "LANG" : ['ValueLogical',
  155 + '_AND_ValueLogical_Star'],
  156 + "LANGMATCHES" : ['ValueLogical',
  157 + '_AND_ValueLogical_Star'],
  158 + "REGEX" : ['ValueLogical',
  159 + '_AND_ValueLogical_Star'],
  160 + "STR" : ['ValueLogical',
  161 + '_AND_ValueLogical_Star'],
  162 + 'BooleanLiteral' : ['ValueLogical',
  163 + '_AND_ValueLogical_Star'],
  164 + 'DECIMAL' : ['ValueLogical',
  165 + '_AND_ValueLogical_Star'],
  166 + 'DOUBLE' : ['ValueLogical',
  167 + '_AND_ValueLogical_Star'],
  168 + 'INTEGER' : ['ValueLogical',
  169 + '_AND_ValueLogical_Star'],
  170 + 'IRI_REF' : ['ValueLogical',
  171 + '_AND_ValueLogical_Star'],
  172 + 'PNAME_LN' : ['ValueLogical',
  173 + '_AND_ValueLogical_Star'],
  174 + 'PNAME_NS' : ['ValueLogical',
  175 + '_AND_ValueLogical_Star'],
  176 + 'STRING_LITERAL1' : ['ValueLogical',
  177 + '_AND_ValueLogical_Star'],
  178 + 'STRING_LITERAL2' : ['ValueLogical',
  179 + '_AND_ValueLogical_Star'],
  180 + 'STRING_LITERAL_LONG1' : ['ValueLogical',
  181 + '_AND_ValueLogical_Star'],
  182 + 'STRING_LITERAL_LONG2' : ['ValueLogical',
  183 + '_AND_ValueLogical_Star'],
  184 + 'VAR1' : ['ValueLogical',
  185 + '_AND_ValueLogical_Star'],
  186 + 'VAR2' : ['ValueLogical',
  187 + '_AND_ValueLogical_Star'],
  188 + "ISBLANK" : ['ValueLogical',
  189 + '_AND_ValueLogical_Star'],
  190 + "ISIRI" : ['ValueLogical',
  191 + '_AND_ValueLogical_Star'],
  192 + "ISLITERAL" : ['ValueLogical',
  193 + '_AND_ValueLogical_Star'],
  194 + "ISURI" : ['ValueLogical',
  195 + '_AND_ValueLogical_Star'],
  196 + "SAMETERM" : ['ValueLogical',
  197 + '_AND_ValueLogical_Star'],
  198 + },
  199 + 'ConditionalOrExpression' : {
  200 + "!" : ['ConditionalAndExpression',
  201 + '_OR_ConditionalAndExpression_Star'],
  202 + "(" : ['ConditionalAndExpression',
  203 + '_OR_ConditionalAndExpression_Star'],
  204 + "+" : ['ConditionalAndExpression',
  205 + '_OR_ConditionalAndExpression_Star'],
  206 + "-" : ['ConditionalAndExpression',
  207 + '_OR_ConditionalAndExpression_Star'],
  208 + "BOUND" : ['ConditionalAndExpression',
  209 + '_OR_ConditionalAndExpression_Star'],
  210 + "DATATYPE" : ['ConditionalAndExpression',
  211 + '_OR_ConditionalAndExpression_Star'],
  212 + "LANG" : ['ConditionalAndExpression',
  213 + '_OR_ConditionalAndExpression_Star'],
  214 + "LANGMATCHES" : ['ConditionalAndExpression',
  215 + '_OR_ConditionalAndExpression_Star'],
  216 + "REGEX" : ['ConditionalAndExpression',
  217 + '_OR_ConditionalAndExpression_Star'],
  218 + "STR" : ['ConditionalAndExpression',
  219 + '_OR_ConditionalAndExpression_Star'],
  220 + 'BooleanLiteral' : ['ConditionalAndExpression',
  221 + '_OR_ConditionalAndExpression_Star'],
  222 + 'DECIMAL' : ['ConditionalAndExpression',
  223 + '_OR_ConditionalAndExpression_Star'],
  224 + 'DOUBLE' : ['ConditionalAndExpression',
  225 + '_OR_ConditionalAndExpression_Star'],
  226 + 'INTEGER' : ['ConditionalAndExpression',
  227 + '_OR_ConditionalAndExpression_Star'],
  228 + 'IRI_REF' : ['ConditionalAndExpression',
  229 + '_OR_ConditionalAndExpression_Star'],
  230 + 'PNAME_LN' : ['ConditionalAndExpression',
  231 + '_OR_ConditionalAndExpression_Star'],
  232 + 'PNAME_NS' : ['ConditionalAndExpression',
  233 + '_OR_ConditionalAndExpression_Star'],
  234 + 'STRING_LITERAL1' : ['ConditionalAndExpression',
  235 + '_OR_ConditionalAndExpression_Star'],
  236 + 'STRING_LITERAL2' : ['ConditionalAndExpression',
  237 + '_OR_ConditionalAndExpression_Star'],
  238 + 'STRING_LITERAL_LONG1' : ['ConditionalAndExpression',
  239 + '_OR_ConditionalAndExpression_Star'],
  240 + 'STRING_LITERAL_LONG2' : ['ConditionalAndExpression',
  241 + '_OR_ConditionalAndExpression_Star'],
  242 + 'VAR1' : ['ConditionalAndExpression',
  243 + '_OR_ConditionalAndExpression_Star'],
  244 + 'VAR2' : ['ConditionalAndExpression',
  245 + '_OR_ConditionalAndExpression_Star'],
  246 + "ISBLANK" : ['ConditionalAndExpression',
  247 + '_OR_ConditionalAndExpression_Star'],
  248 + "ISIRI" : ['ConditionalAndExpression',
  249 + '_OR_ConditionalAndExpression_Star'],
  250 + "ISLITERAL" : ['ConditionalAndExpression',
  251 + '_OR_ConditionalAndExpression_Star'],
  252 + "ISURI" : ['ConditionalAndExpression',
  253 + '_OR_ConditionalAndExpression_Star'],
  254 + "SAMETERM" : ['ConditionalAndExpression',
  255 + '_OR_ConditionalAndExpression_Star'],
  256 + },
  257 + 'Constraint' : {
  258 + "(" : ['BrackettedExpression'],
  259 + "BOUND" : ['BuiltInCall'],
  260 + "DATATYPE" : ['BuiltInCall'],
  261 + "LANG" : ['BuiltInCall'],
  262 + "LANGMATCHES" : ['BuiltInCall'],
  263 + "REGEX" : ['BuiltInCall'],
  264 + "STR" : ['BuiltInCall'],
  265 + 'IRI_REF' : ['FunctionCall'],
  266 + 'PNAME_LN' : ['FunctionCall'],
  267 + 'PNAME_NS' : ['FunctionCall'],
  268 + "ISBLANK" : ['BuiltInCall'],
  269 + "ISIRI" : ['BuiltInCall'],
  270 + "ISLITERAL" : ['BuiltInCall'],
  271 + "ISURI" : ['BuiltInCall'],
  272 + "SAMETERM" : ['BuiltInCall'],
  273 + },
  274 + 'ConstructQuery' : {
  275 + "CONSTRUCT" : ["CONSTRUCT",
  276 + 'ConstructTemplate',
  277 + '_DatasetClause_Star',
  278 + 'WhereClause',
  279 + 'SolutionModifier'],
  280 + },
  281 + 'ConstructTemplate' : {
  282 + "{" : ["{",
  283 + '_ConstructTriples_Opt',
  284 + "}"],
  285 + },
  286 + 'ConstructTriples' : {
  287 + "(" : ['TriplesSameSubject',
  288 + '_DOT_ConstructTriples_Opt_Opt'],
  289 + "+" : ['TriplesSameSubject',
  290 + '_DOT_ConstructTriples_Opt_Opt'],
  291 + "-" : ['TriplesSameSubject',
  292 + '_DOT_ConstructTriples_Opt_Opt'],
  293 + "[" : ['TriplesSameSubject',
  294 + '_DOT_ConstructTriples_Opt_Opt'],
  295 + 'ANON' : ['TriplesSameSubject',
  296 + '_DOT_ConstructTriples_Opt_Opt'],
  297 + 'BLANK_NODE_LABEL' : ['TriplesSameSubject',
  298 + '_DOT_ConstructTriples_Opt_Opt'],
  299 + 'BooleanLiteral' : ['TriplesSameSubject',
  300 + '_DOT_ConstructTriples_Opt_Opt'],
  301 + 'DECIMAL' : ['TriplesSameSubject',
  302 + '_DOT_ConstructTriples_Opt_Opt'],
  303 + 'DOUBLE' : ['TriplesSameSubject',
  304 + '_DOT_ConstructTriples_Opt_Opt'],
  305 + 'INTEGER' : ['TriplesSameSubject',
  306 + '_DOT_ConstructTriples_Opt_Opt'],
  307 + 'IRI_REF' : ['TriplesSameSubject',
  308 + '_DOT_ConstructTriples_Opt_Opt'],
  309 + 'NIL' : ['TriplesSameSubject',
  310 + '_DOT_ConstructTriples_Opt_Opt'],
  311 + 'PNAME_LN' : ['TriplesSameSubject',
  312 + '_DOT_ConstructTriples_Opt_Opt'],
  313 + 'PNAME_NS' : ['TriplesSameSubject',
  314 + '_DOT_ConstructTriples_Opt_Opt'],
  315 + 'STRING_LITERAL1' : ['TriplesSameSubject',
  316 + '_DOT_ConstructTriples_Opt_Opt'],
  317 + 'STRING_LITERAL2' : ['TriplesSameSubject',
  318 + '_DOT_ConstructTriples_Opt_Opt'],
  319 + 'STRING_LITERAL_LONG1' : ['TriplesSameSubject',
  320 + '_DOT_ConstructTriples_Opt_Opt'],
  321 + 'STRING_LITERAL_LONG2' : ['TriplesSameSubject',
  322 + '_DOT_ConstructTriples_Opt_Opt'],
  323 + 'VAR1' : ['TriplesSameSubject',
  324 + '_DOT_ConstructTriples_Opt_Opt'],
  325 + 'VAR2' : ['TriplesSameSubject',
  326 + '_DOT_ConstructTriples_Opt_Opt'],
  327 + },
  328 + 'DatasetClause' : {
  329 + "FROM" : ["FROM",
  330 + '_DefaultGraphClause_or_NamedGraphClause'],
  331 + },
  332 + 'DefaultGraphClause' : {
  333 + 'IRI_REF' : ['SourceSelector'],
  334 + 'PNAME_LN' : ['SourceSelector'],
  335 + 'PNAME_NS' : ['SourceSelector'],
  336 + },
  337 + 'DescribeQuery' : {
  338 + "DESCRIBE" : ["DESCRIBE",
  339 + '_VarOrIRIref_Plus_or_Star',
  340 + '_DatasetClause_Star',
  341 + '_WhereClause_Opt',
  342 + 'SolutionModifier'],
  343 + },
  344 + 'Expression' : {
  345 + "!" : ['ConditionalOrExpression'],
  346 + "(" : ['ConditionalOrExpression'],
  347 + "+" : ['ConditionalOrExpression'],
  348 + "-" : ['ConditionalOrExpression'],
  349 + "BOUND" : ['ConditionalOrExpression'],
  350 + "DATATYPE" : ['ConditionalOrExpression'],
  351 + "LANG" : ['ConditionalOrExpression'],
  352 + "LANGMATCHES" : ['ConditionalOrExpression'],
  353 + "REGEX" : ['ConditionalOrExpression'],
  354 + "STR" : ['ConditionalOrExpression'],
  355 + 'BooleanLiteral' : ['ConditionalOrExpression'],
  356 + 'DECIMAL' : ['ConditionalOrExpression'],
  357 + 'DOUBLE' : ['ConditionalOrExpression'],
  358 + 'INTEGER' : ['ConditionalOrExpression'],
  359 + 'IRI_REF' : ['ConditionalOrExpression'],
  360 + 'PNAME_LN' : ['ConditionalOrExpression'],
  361 + 'PNAME_NS' : ['ConditionalOrExpression'],
  362 + 'STRING_LITERAL1' : ['ConditionalOrExpression'],
  363 + 'STRING_LITERAL2' : ['ConditionalOrExpression'],
  364 + 'STRING_LITERAL_LONG1' : ['ConditionalOrExpression'],
  365 + 'STRING_LITERAL_LONG2' : ['ConditionalOrExpression'],
  366 + 'VAR1' : ['ConditionalOrExpression'],
  367 + 'VAR2' : ['ConditionalOrExpression'],
  368 + "ISBLANK" : ['ConditionalOrExpression'],
  369 + "ISIRI" : ['ConditionalOrExpression'],
  370 + "ISLITERAL" : ['ConditionalOrExpression'],
  371 + "ISURI" : ['ConditionalOrExpression'],
  372 + "SAMETERM" : ['ConditionalOrExpression'],
  373 + },
  374 + 'Filter' : {
  375 + "FILTER" : ["FILTER",
  376 + 'Constraint'],
  377 + },
  378 + 'FunctionCall' : {
  379 + 'IRI_REF' : ['IRIref',
  380 + 'ArgList'],
  381 + 'PNAME_LN' : ['IRIref',
  382 + 'ArgList'],
  383 + 'PNAME_NS' : ['IRIref',
  384 + 'ArgList'],
  385 + },
  386 + 'GraphGraphPattern' : {
  387 + "GRAPH" : ["GRAPH",
  388 + 'VarOrIRIref',
  389 + 'GroupGraphPattern'],
  390 + },
  391 + 'GraphNode' : {
  392 + "(" : ['TriplesNode'],
  393 + "+" : ['VarOrTerm'],
  394 + "-" : ['VarOrTerm'],
  395 + "[" : ['TriplesNode'],
  396 + 'ANON' : ['VarOrTerm'],
  397 + 'BLANK_NODE_LABEL' : ['VarOrTerm'],
  398 + 'BooleanLiteral' : ['VarOrTerm'],
  399 + 'DECIMAL' : ['VarOrTerm'],
  400 + 'DOUBLE' : ['VarOrTerm'],
  401 + 'INTEGER' : ['VarOrTerm'],
  402 + 'IRI_REF' : ['VarOrTerm'],
  403 + 'NIL' : ['VarOrTerm'],
  404 + 'PNAME_LN' : ['VarOrTerm'],
  405 + 'PNAME_NS' : ['VarOrTerm'],
  406 + 'STRING_LITERAL1' : ['VarOrTerm'],
  407 + 'STRING_LITERAL2' : ['VarOrTerm'],
  408 + 'STRING_LITERAL_LONG1' : ['VarOrTerm'],
  409 + 'STRING_LITERAL_LONG2' : ['VarOrTerm'],
  410 + 'VAR1' : ['VarOrTerm'],
  411 + 'VAR2' : ['VarOrTerm'],
  412 + },
  413 + 'GraphPatternNotTriples' : {
  414 + "GRAPH" : ['GraphGraphPattern'],
  415 + "OPTIONAL" : ['OptionalGraphPattern'],
  416 + "{" : ['GroupOrUnionGraphPattern'],
  417 + },
  418 + 'GraphTerm' : {
  419 + "+" : ['NumericLiteral'],
  420 + "-" : ['NumericLiteral'],
  421 + 'ANON' : ['BlankNode'],
  422 + 'BLANK_NODE_LABEL' : ['BlankNode'],
  423 + 'BooleanLiteral' : ['BooleanLiteral'],
  424 + 'DECIMAL' : ['NumericLiteral'],
  425 + 'DOUBLE' : ['NumericLiteral'],
  426 + 'INTEGER' : ['NumericLiteral'],
  427 + 'IRI_REF' : ['IRIref'],
  428 + 'NIL' : ['NIL'],
  429 + 'PNAME_LN' : ['IRIref'],
  430 + 'PNAME_NS' : ['IRIref'],
  431 + 'STRING_LITERAL1' : ['RDFLiteral'],
  432 + 'STRING_LITERAL2' : ['RDFLiteral'],
  433 + 'STRING_LITERAL_LONG1' : ['RDFLiteral'],
  434 + 'STRING_LITERAL_LONG2' : ['RDFLiteral'],
  435 + },
  436 + 'GroupGraphPattern' : {
  437 + "{" : ["{",
  438 + '_TriplesBlock_Opt',
  439 + '_GraphPatternNotTriples_or_Filter_Dot_Opt_TriplesBlock_Opt_Star',
  440 + "}"],
  441 + },
  442 + 'GroupOrUnionGraphPattern' : {
  443 + "{" : ['GroupGraphPattern',
  444 + '_UNION_GroupGraphPattern_Star'],
  445 + },
  446 + 'IRIref' : {
  447 + 'IRI_REF' : ['IRI_REF'],
  448 + 'PNAME_LN' : ['PrefixedName'],
  449 + 'PNAME_NS' : ['PrefixedName'],
  450 + },
  451 + 'IRIrefOrFunction' : {
  452 + 'IRI_REF' : ['IRIref',
  453 + '_ArgList_Opt'],
  454 + 'PNAME_LN' : ['IRIref',
  455 + '_ArgList_Opt'],
  456 + 'PNAME_NS' : ['IRIref',
  457 + '_ArgList_Opt'],
  458 + },
  459 + 'LimitClause' : {
  460 + "LIMIT" : ["LIMIT",
  461 + 'INTEGER'],
  462 + },
  463 + 'LimitOffsetClauses' : {
  464 + "LIMIT" : ['LimitClause',
  465 + '_OffsetClause_Opt'],
  466 + "OFFSET" : ['OffsetClause',
  467 + '_LimitClause_Opt'],
  468 + },
  469 + 'MultiplicativeExpression' : {
  470 + "!" : ['UnaryExpression',
  471 + '_Mul_Div_UnaryExpression_Star'],
  472 + "(" : ['UnaryExpression',
  473 + '_Mul_Div_UnaryExpression_Star'],
  474 + "+" : ['UnaryExpression',
  475 + '_Mul_Div_UnaryExpression_Star'],
  476 + "-" : ['UnaryExpression',
  477 + '_Mul_Div_UnaryExpression_Star'],
  478 + "BOUND" : ['UnaryExpression',
  479 + '_Mul_Div_UnaryExpression_Star'],
  480 + "DATATYPE" : ['UnaryExpression',
  481 + '_Mul_Div_UnaryExpression_Star'],
  482 + "LANG" : ['UnaryExpression',
  483 + '_Mul_Div_UnaryExpression_Star'],
  484 + "LANGMATCHES" : ['UnaryExpression',
  485 + '_Mul_Div_UnaryExpression_Star'],
  486 + "REGEX" : ['UnaryExpression',
  487 + '_Mul_Div_UnaryExpression_Star'],
  488 + "STR" : ['UnaryExpression',
  489 + '_Mul_Div_UnaryExpression_Star'],
  490 + 'BooleanLiteral' : ['UnaryExpression',
  491 + '_Mul_Div_UnaryExpression_Star'],
  492 + 'DECIMAL' : ['UnaryExpression',
  493 + '_Mul_Div_UnaryExpression_Star'],
  494 + 'DOUBLE' : ['UnaryExpression',
  495 + '_Mul_Div_UnaryExpression_Star'],
  496 + 'INTEGER' : ['UnaryExpression',
  497 + '_Mul_Div_UnaryExpression_Star'],
  498 + 'IRI_REF' : ['UnaryExpression',
  499 + '_Mul_Div_UnaryExpression_Star'],
  500 + 'PNAME_LN' : ['UnaryExpression',
  501 + '_Mul_Div_UnaryExpression_Star'],
  502 + 'PNAME_NS' : ['UnaryExpression',
  503 + '_Mul_Div_UnaryExpression_Star'],
  504 + 'STRING_LITERAL1' : ['UnaryExpression',
  505 + '_Mul_Div_UnaryExpression_Star'],
  506 + 'STRING_LITERAL2' : ['UnaryExpression',
  507 + '_Mul_Div_UnaryExpression_Star'],
  508 + 'STRING_LITERAL_LONG1' : ['UnaryExpression',
  509 + '_Mul_Div_UnaryExpression_Star'],
  510 + 'STRING_LITERAL_LONG2' : ['UnaryExpression',
  511 + '_Mul_Div_UnaryExpression_Star'],
  512 + 'VAR1' : ['UnaryExpression',
  513 + '_Mul_Div_UnaryExpression_Star'],
  514 + 'VAR2' : ['UnaryExpression',
  515 + '_Mul_Div_UnaryExpression_Star'],
  516 + "ISBLANK" : ['UnaryExpression',
  517 + '_Mul_Div_UnaryExpression_Star'],
  518 + "ISIRI" : ['UnaryExpression',
  519 + '_Mul_Div_UnaryExpression_Star'],
  520 + "ISLITERAL" : ['UnaryExpression',
  521 + '_Mul_Div_UnaryExpression_Star'],
  522 + "ISURI" : ['UnaryExpression',
  523 + '_Mul_Div_UnaryExpression_Star'],
  524 + "SAMETERM" : ['UnaryExpression',
  525 + '_Mul_Div_UnaryExpression_Star'],
  526 + },
  527 + 'NamedGraphClause' : {
  528 + "NAMED" : ["NAMED",
  529 + 'SourceSelector'],
  530 + },
  531 + 'NumericExpression' : {
  532 + "!" : ['AdditiveExpression'],
  533 + "(" : ['AdditiveExpression'],
  534 + "+" : ['AdditiveExpression'],
  535 + "-" : ['AdditiveExpression'],
  536 + "BOUND" : ['AdditiveExpression'],
  537 + "DATATYPE" : ['AdditiveExpression'],
  538 + "LANG" : ['AdditiveExpression'],
  539 + "LANGMATCHES" : ['AdditiveExpression'],
  540 + "REGEX" : ['AdditiveExpression'],
  541 + "STR" : ['AdditiveExpression'],
  542 + 'BooleanLiteral' : ['AdditiveExpression'],
  543 + 'DECIMAL' : ['AdditiveExpression'],
  544 + 'DOUBLE' : ['AdditiveExpression'],
  545 + 'INTEGER' : ['AdditiveExpression'],
  546 + 'IRI_REF' : ['AdditiveExpression'],
  547 + 'PNAME_LN' : ['AdditiveExpression'],
  548 + 'PNAME_NS' : ['AdditiveExpression'],
  549 + 'STRING_LITERAL1' : ['AdditiveExpression'],
  550 + 'STRING_LITERAL2' : ['AdditiveExpression'],
  551 + 'STRING_LITERAL_LONG1' : ['AdditiveExpression'],
  552 + 'STRING_LITERAL_LONG2' : ['AdditiveExpression'],
  553 + 'VAR1' : ['AdditiveExpression'],
  554 + 'VAR2' : ['AdditiveExpression'],
  555 + "ISBLANK" : ['AdditiveExpression'],
  556 + "ISIRI" : ['AdditiveExpression'],
  557 + "ISLITERAL" : ['AdditiveExpression'],
  558 + "ISURI" : ['AdditiveExpression'],
  559 + "SAMETERM" : ['AdditiveExpression'],
  560 + },
  561 + 'NumericLiteral' : {
  562 + "+" : ['NumericLiteralPositive'],
  563 + "-" : ['NumericLiteralNegative'],
  564 + 'DECIMAL' : ['NumericLiteralUnsigned'],
  565 + 'DOUBLE' : ['NumericLiteralUnsigned'],
  566 + 'INTEGER' : ['NumericLiteralUnsigned'],
  567 + },
  568 + 'NumericLiteralNegative' : {
  569 + "-" : ["-",
  570 + 'NumericLiteralUnsigned'],
  571 + },
  572 + 'NumericLiteralPositive' : {
  573 + "+" : ["+",
  574 + 'NumericLiteralUnsigned'],
  575 + },
  576 + 'NumericLiteralUnsigned' : {
  577 + 'DECIMAL' : ['DECIMAL'],
  578 + 'DOUBLE' : ['DOUBLE'],
  579 + 'INTEGER' : ['INTEGER'],
  580 + },
  581 + 'Object' : {
  582 + "(" : ['GraphNode'],
  583 + "+" : ['GraphNode'],
  584 + "-" : ['GraphNode'],
  585 + "[" : ['GraphNode'],
  586 + 'ANON' : ['GraphNode'],
  587 + 'BLANK_NODE_LABEL' : ['GraphNode'],
  588 + 'BooleanLiteral' : ['GraphNode'],
  589 + 'DECIMAL' : ['GraphNode'],
  590 + 'DOUBLE' : ['GraphNode'],
  591 + 'INTEGER' : ['GraphNode'],
  592 + 'IRI_REF' : ['GraphNode'],
  593 + 'NIL' : ['GraphNode'],
  594 + 'PNAME_LN' : ['GraphNode'],
  595 + 'PNAME_NS' : ['GraphNode'],
  596 + 'STRING_LITERAL1' : ['GraphNode'],
  597 + 'STRING_LITERAL2' : ['GraphNode'],
  598 + 'STRING_LITERAL_LONG1' : ['GraphNode'],
  599 + 'STRING_LITERAL_LONG2' : ['GraphNode'],
  600 + 'VAR1' : ['GraphNode'],
  601 + 'VAR2' : ['GraphNode'],
  602 + },
  603 + 'ObjectList' : {
  604 + "(" : ['Object',
  605 + '_COMMA_Object_Star'],
  606 + "+" : ['Object',
  607 + '_COMMA_Object_Star'],
  608 + "-" : ['Object',
  609 + '_COMMA_Object_Star'],
  610 + "[" : ['Object',
  611 + '_COMMA_Object_Star'],
  612 + 'ANON' : ['Object',
  613 + '_COMMA_Object_Star'],
  614 + 'BLANK_NODE_LABEL' : ['Object',
  615 + '_COMMA_Object_Star'],
  616 + 'BooleanLiteral' : ['Object',
  617 + '_COMMA_Object_Star'],
  618 + 'DECIMAL' : ['Object',
  619 + '_COMMA_Object_Star'],
  620 + 'DOUBLE' : ['Object',
  621 + '_COMMA_Object_Star'],
  622 + 'INTEGER' : ['Object',
  623 + '_COMMA_Object_Star'],
  624 + 'IRI_REF' : ['Object',
  625 + '_COMMA_Object_Star'],
  626 + 'NIL' : ['Object',
  627 + '_COMMA_Object_Star'],
  628 + 'PNAME_LN' : ['Object',
  629 + '_COMMA_Object_Star'],
  630 + 'PNAME_NS' : ['Object',
  631 + '_COMMA_Object_Star'],
  632 + 'STRING_LITERAL1' : ['Object',
  633 + '_COMMA_Object_Star'],
  634 + 'STRING_LITERAL2' : ['Object',
  635 + '_COMMA_Object_Star'],
  636 + 'STRING_LITERAL_LONG1' : ['Object',
  637 + '_COMMA_Object_Star'],
  638 + 'STRING_LITERAL_LONG2' : ['Object',
  639 + '_COMMA_Object_Star'],
  640 + 'VAR1' : ['Object',
  641 + '_COMMA_Object_Star'],
  642 + 'VAR2' : ['Object',
  643 + '_COMMA_Object_Star'],
  644 + },
  645 + 'OffsetClause' : {
  646 + "OFFSET" : ["OFFSET",
  647 + 'INTEGER'],
  648 + },
  649 + 'OptionalGraphPattern' : {
  650 + "OPTIONAL" : ["OPTIONAL",
  651 + 'GroupGraphPattern'],
  652 + },
  653 + 'OrderClause' : {
  654 + "ORDER" : ["ORDER",
  655 + "BY",
  656 + 'OrderCondition',
  657 + '_OrderCondition_Plus'],
  658 + },
  659 + 'OrderCondition' : {
  660 + "(" : ['_Constraint_or_Var'],
  661 + "ASC" : ['_ASC_Or_DESC_BrackettedExpression'],
  662 + "BOUND" : ['_Constraint_or_Var'],
  663 + "DATATYPE" : ['_Constraint_or_Var'],
  664 + "DESC" : ['_ASC_Or_DESC_BrackettedExpression'],
  665 + "LANG" : ['_Constraint_or_Var'],
  666 + "LANGMATCHES" : ['_Constraint_or_Var'],
  667 + "REGEX" : ['_Constraint_or_Var'],
  668 + "STR" : ['_Constraint_or_Var'],
  669 + 'IRI_REF' : ['_Constraint_or_Var'],
  670 + 'PNAME_LN' : ['_Constraint_or_Var'],
  671 + 'PNAME_NS' : ['_Constraint_or_Var'],
  672 + 'VAR1' : ['_Constraint_or_Var'],
  673 + 'VAR2' : ['_Constraint_or_Var'],
  674 + "ISBLANK" : ['_Constraint_or_Var'],
  675 + "ISIRI" : ['_Constraint_or_Var'],
  676 + "ISLITERAL" : ['_Constraint_or_Var'],
  677 + "ISURI" : ['_Constraint_or_Var'],
  678 + "SAMETERM" : ['_Constraint_or_Var'],
  679 + },
  680 + 'PrefixDecl' : {
  681 + "PREFIX" : ["PREFIX",
  682 + 'PNAME_NS',
  683 + 'IRI_REF'],
  684 + },
  685 + 'PrefixedName' : {
  686 + 'PNAME_LN' : ['PNAME_LN'],
  687 + 'PNAME_NS' : ['PNAME_NS'],
  688 + },
  689 + 'PrimaryExpression' : {
  690 + "(" : ['BrackettedExpression'],
  691 + "+" : ['NumericLiteral'],
  692 + "-" : ['NumericLiteral'],
  693 + "BOUND" : ['BuiltInCall'],
  694 + "DATATYPE" : ['BuiltInCall'],
  695 + "LANG" : ['BuiltInCall'],
  696 + "LANGMATCHES" : ['BuiltInCall'],
  697 + "REGEX" : ['BuiltInCall'],
  698 + "STR" : ['BuiltInCall'],
  699 + 'BooleanLiteral' : ['BooleanLiteral'],
  700 + 'DECIMAL' : ['NumericLiteral'],
  701 + 'DOUBLE' : ['NumericLiteral'],
  702 + 'INTEGER' : ['NumericLiteral'],
  703 + 'IRI_REF' : ['IRIrefOrFunction'],
  704 + 'PNAME_LN' : ['IRIrefOrFunction'],
  705 + 'PNAME_NS' : ['IRIrefOrFunction'],
  706 + 'STRING_LITERAL1' : ['RDFLiteral'],
  707 + 'STRING_LITERAL2' : ['RDFLiteral'],
  708 + 'STRING_LITERAL_LONG1' : ['RDFLiteral'],
  709 + 'STRING_LITERAL_LONG2' : ['RDFLiteral'],
  710 + 'VAR1' : ['Var'],
  711 + 'VAR2' : ['Var'],
  712 + "ISBLANK" : ['BuiltInCall'],
  713 + "ISIRI" : ['BuiltInCall'],
  714 + "ISLITERAL" : ['BuiltInCall'],
  715 + "ISURI" : ['BuiltInCall'],
  716 + "SAMETERM" : ['BuiltInCall'],
  717 + },
  718 + 'Prologue' : {
  719 + "ASK" : ['_BaseDecl_Opt',
  720 + '_PrefixDecl_Star'],
  721 + "BASE" : ['_BaseDecl_Opt',
  722 + '_PrefixDecl_Star'],
  723 + "CONSTRUCT" : ['_BaseDecl_Opt',
  724 + '_PrefixDecl_Star'],
  725 + "DESCRIBE" : ['_BaseDecl_Opt',
  726 + '_PrefixDecl_Star'],
  727 + "PREFIX" : ['_BaseDecl_Opt',
  728 + '_PrefixDecl_Star'],
  729 + "SELECT" : ['_BaseDecl_Opt',
  730 + '_PrefixDecl_Star'],
  731 + },
  732 + 'PropertyList' : {
  733 + "." : [],
  734 + "FILTER" : [],
  735 + "GRAPH" : [],
  736 + "OPTIONAL" : [],
  737 + "a" : ['PropertyListNotEmpty'],
  738 + 'IRI_REF' : ['PropertyListNotEmpty'],
  739 + 'PNAME_LN' : ['PropertyListNotEmpty'],
  740 + 'PNAME_NS' : ['PropertyListNotEmpty'],
  741 + 'VAR1' : ['PropertyListNotEmpty'],
  742 + 'VAR2' : ['PropertyListNotEmpty'],
  743 + "{" : [],
  744 + "}" : [],
  745 + },
  746 + 'PropertyListNotEmpty' : {
  747 + "a" : ['Verb',
  748 + 'ObjectList',
  749 + '_SEMI_Verb_ObjectList_Opt_Star'],
  750 + 'IRI_REF' : ['Verb',
  751 + 'ObjectList',
  752 + '_SEMI_Verb_ObjectList_Opt_Star'],
  753 + 'PNAME_LN' : ['Verb',
  754 + 'ObjectList',
  755 + '_SEMI_Verb_ObjectList_Opt_Star'],
  756 + 'PNAME_NS' : ['Verb',
  757 + 'ObjectList',
  758 + '_SEMI_Verb_ObjectList_Opt_Star'],
  759 + 'VAR1' : ['Verb',
  760 + 'ObjectList',
  761 + '_SEMI_Verb_ObjectList_Opt_Star'],
  762 + 'VAR2' : ['Verb',
  763 + 'ObjectList',
  764 + '_SEMI_Verb_ObjectList_Opt_Star'],
  765 + },
  766 + 'Query' : {
  767 + "ASK" : ['Prologue',
  768 + '_SelectQuery_or_ConstructQuery_or_DescribeQuery_or_AskQuery',
  769 + 'eof'],
  770 + "BASE" : ['Prologue',
  771 + '_SelectQuery_or_ConstructQuery_or_DescribeQuery_or_AskQuery',
  772 + 'eof'],
  773 + "CONSTRUCT" : ['Prologue',
  774 + '_SelectQuery_or_ConstructQuery_or_DescribeQuery_or_AskQuery',
  775 + 'eof'],
  776 + "DESCRIBE" : ['Prologue',
  777 + '_SelectQuery_or_ConstructQuery_or_DescribeQuery_or_AskQuery',
  778 + 'eof'],
  779 + "PREFIX" : ['Prologue',
  780 + '_SelectQuery_or_ConstructQuery_or_DescribeQuery_or_AskQuery',
  781 + 'eof'],
  782 + "SELECT" : ['Prologue',
  783 + '_SelectQuery_or_ConstructQuery_or_DescribeQuery_or_AskQuery',
  784 + 'eof'],
  785 + },
  786 + 'RDFLiteral' : {
  787 + 'STRING_LITERAL1' : ['String',
  788 + '_LANGTAG_IRIref_Opt'],
  789 + 'STRING_LITERAL2' : ['String',
  790 + '_LANGTAG_IRIref_Opt'],
  791 + 'STRING_LITERAL_LONG1' : ['String',
  792 + '_LANGTAG_IRIref_Opt'],
  793 + 'STRING_LITERAL_LONG2' : ['String',
  794 + '_LANGTAG_IRIref_Opt'],
  795 + },
  796 + 'RegexExpression' : {
  797 + "REGEX" : ["REGEX",
  798 + "(",
  799 + 'Expression',
  800 + ",",
  801 + 'Expression',
  802 + '_COMMA_Expression_Opt',
  803 + ")"],
  804 + },
  805 + 'RelationalExpression' : {
  806 + "!" : ['NumericExpression',
  807 + '_Compare_NumericExpression_Opt'],
  808 + "(" : ['NumericExpression',
  809 + '_Compare_NumericExpression_Opt'],
  810 + "+" : ['NumericExpression',
  811 + '_Compare_NumericExpression_Opt'],
  812 + "-" : ['NumericExpression',
  813 + '_Compare_NumericExpression_Opt'],
  814 + "BOUND" : ['NumericExpression',
  815 + '_Compare_NumericExpression_Opt'],
  816 + "DATATYPE" : ['NumericExpression',
  817 + '_Compare_NumericExpression_Opt'],
  818 + "LANG" : ['NumericExpression',
  819 + '_Compare_NumericExpression_Opt'],
  820 + "LANGMATCHES" : ['NumericExpression',
  821 + '_Compare_NumericExpression_Opt'],
  822 + "REGEX" : ['NumericExpression',
  823 + '_Compare_NumericExpression_Opt'],
  824 + "STR" : ['NumericExpression',
  825 + '_Compare_NumericExpression_Opt'],
  826 + 'BooleanLiteral' : ['NumericExpression',
  827 + '_Compare_NumericExpression_Opt'],
  828 + 'DECIMAL' : ['NumericExpression',
  829 + '_Compare_NumericExpression_Opt'],
  830 + 'DOUBLE' : ['NumericExpression',
  831 + '_Compare_NumericExpression_Opt'],
  832 + 'INTEGER' : ['NumericExpression',
  833 + '_Compare_NumericExpression_Opt'],
  834 + 'IRI_REF' : ['NumericExpression',
  835 + '_Compare_NumericExpression_Opt'],
  836 + 'PNAME_LN' : ['NumericExpression',
  837 + '_Compare_NumericExpression_Opt'],
  838 + 'PNAME_NS' : ['NumericExpression',
  839 + '_Compare_NumericExpression_Opt'],
  840 + 'STRING_LITERAL1' : ['NumericExpression',
  841 + '_Compare_NumericExpression_Opt'],
  842 + 'STRING_LITERAL2' : ['NumericExpression',
  843 + '_Compare_NumericExpression_Opt'],
  844 + 'STRING_LITERAL_LONG1' : ['NumericExpression',
  845 + '_Compare_NumericExpression_Opt'],
  846 + 'STRING_LITERAL_LONG2' : ['NumericExpression',
  847 + '_Compare_NumericExpression_Opt'],
  848 + 'VAR1' : ['NumericExpression',
  849 + '_Compare_NumericExpression_Opt'],
  850 + 'VAR2' : ['NumericExpression',
  851 + '_Compare_NumericExpression_Opt'],
  852 + "ISBLANK" : ['NumericExpression',
  853 + '_Compare_NumericExpression_Opt'],
  854 + "ISIRI" : ['NumericExpression',
  855 + '_Compare_NumericExpression_Opt'],
  856 + "ISLITERAL" : ['NumericExpression',
  857 + '_Compare_NumericExpression_Opt'],
  858 + "ISURI" : ['NumericExpression',
  859 + '_Compare_NumericExpression_Opt'],
  860 + "SAMETERM" : ['NumericExpression',
  861 + '_Compare_NumericExpression_Opt'],
  862 + },
  863 + 'SelectQuery' : {
  864 + "SELECT" : ["SELECT",
  865 + '_DISTINCT_OR_REDUCED_Opt',
  866 + '_Var_Plus_or_Star',
  867 + '_DatasetClause_Star',
  868 + 'WhereClause',
  869 + 'SolutionModifier'],
  870 + },
  871 + 'SolutionModifier' : {
  872 + "LIMIT" : ['_OrderClause_Opt',
  873 + '_LimitOffsetClauses_Opt'],
  874 + "OFFSET" : ['_OrderClause_Opt',
  875 + '_LimitOffsetClauses_Opt'],
  876 + "ORDER" : ['_OrderClause_Opt',
  877 + '_LimitOffsetClauses_Opt'],
  878 + 'eof' : ['_OrderClause_Opt',
  879 + '_LimitOffsetClauses_Opt'],
  880 + },
  881 + 'SourceSelector' : {
  882 + 'IRI_REF' : ['IRIref'],
  883 + 'PNAME_LN' : ['IRIref'],
  884 + 'PNAME_NS' : ['IRIref'],
  885 + },
  886 + 'String' : {
  887 + 'STRING_LITERAL1' : ['STRING_LITERAL1'],
  888 + 'STRING_LITERAL2' : ['STRING_LITERAL2'],
  889 + 'STRING_LITERAL_LONG1' : ['STRING_LITERAL_LONG1'],
  890 + 'STRING_LITERAL_LONG2' : ['STRING_LITERAL_LONG2'],
  891 + },
  892 + 'TriplesBlock' : {
  893 + "(" : ['TriplesSameSubject',
  894 + '_Dot_TriplesBlock_Opt_Opt'],
  895 + "+" : ['TriplesSameSubject',
  896 + '_Dot_TriplesBlock_Opt_Opt'],
  897 + "-" : ['TriplesSameSubject',
  898 + '_Dot_TriplesBlock_Opt_Opt'],
  899 + "[" : ['TriplesSameSubject',
  900 + '_Dot_TriplesBlock_Opt_Opt'],
  901 + 'ANON' : ['TriplesSameSubject',
  902 + '_Dot_TriplesBlock_Opt_Opt'],
  903 + 'BLANK_NODE_LABEL' : ['TriplesSameSubject',
  904 + '_Dot_TriplesBlock_Opt_Opt'],
  905 + 'BooleanLiteral' : ['TriplesSameSubject',
  906 + '_Dot_TriplesBlock_Opt_Opt'],
  907 + 'DECIMAL' : ['TriplesSameSubject',
  908 + '_Dot_TriplesBlock_Opt_Opt'],
  909 + 'DOUBLE' : ['TriplesSameSubject',
  910 + '_Dot_TriplesBlock_Opt_Opt'],
  911 + 'INTEGER' : ['TriplesSameSubject',
  912 + '_Dot_TriplesBlock_Opt_Opt'],
  913 + 'IRI_REF' : ['TriplesSameSubject',
  914 + '_Dot_TriplesBlock_Opt_Opt'],
  915 + 'NIL' : ['TriplesSameSubject',
  916 + '_Dot_TriplesBlock_Opt_Opt'],
  917 + 'PNAME_LN' : ['TriplesSameSubject',
  918 + '_Dot_TriplesBlock_Opt_Opt'],
  919 + 'PNAME_NS' : ['TriplesSameSubject',
  920 + '_Dot_TriplesBlock_Opt_Opt'],
  921 + 'STRING_LITERAL1' : ['TriplesSameSubject',
  922 + '_Dot_TriplesBlock_Opt_Opt'],
  923 + 'STRING_LITERAL2' : ['TriplesSameSubject',
  924 + '_Dot_TriplesBlock_Opt_Opt'],
  925 + 'STRING_LITERAL_LONG1' : ['TriplesSameSubject',
  926 + '_Dot_TriplesBlock_Opt_Opt'],
  927 + 'STRING_LITERAL_LONG2' : ['TriplesSameSubject',
  928 + '_Dot_TriplesBlock_Opt_Opt'],
  929 + 'VAR1' : ['TriplesSameSubject',
  930 + '_Dot_TriplesBlock_Opt_Opt'],
  931 + 'VAR2' : ['TriplesSameSubject',
  932 + '_Dot_TriplesBlock_Opt_Opt'],
  933 + },
  934 + 'TriplesNode' : {
  935 + "(" : ['Collection'],
  936 + "[" : ['BlankNodePropertyList'],
  937 + },
  938 + 'TriplesSameSubject' : {
  939 + "(" : ['TriplesNode',
  940 + 'PropertyList'],
  941 + "+" : ['VarOrTerm',
  942 + 'PropertyListNotEmpty'],
  943 + "-" : ['VarOrTerm',
  944 + 'PropertyListNotEmpty'],
  945 + "[" : ['TriplesNode',
  946 + 'PropertyList'],
  947 + 'ANON' : ['VarOrTerm',
  948 + 'PropertyListNotEmpty'],
  949 + 'BLANK_NODE_LABEL' : ['VarOrTerm',
  950 + 'PropertyListNotEmpty'],
  951 + 'BooleanLiteral' : ['VarOrTerm',
  952 + 'PropertyListNotEmpty'],
  953 + 'DECIMAL' : ['VarOrTerm',
  954 + 'PropertyListNotEmpty'],
  955 + 'DOUBLE' : ['VarOrTerm',
  956 + 'PropertyListNotEmpty'],
  957 + 'INTEGER' : ['VarOrTerm',
  958 + 'PropertyListNotEmpty'],
  959 + 'IRI_REF' : ['VarOrTerm',
  960 + 'PropertyListNotEmpty'],
  961 + 'NIL' : ['VarOrTerm',
  962 + 'PropertyListNotEmpty'],
  963 + 'PNAME_LN' : ['VarOrTerm',
  964 + 'PropertyListNotEmpty'],
  965 + 'PNAME_NS' : ['VarOrTerm',
  966 + 'PropertyListNotEmpty'],
  967 + 'STRING_LITERAL1' : ['VarOrTerm',
  968 + 'PropertyListNotEmpty'],
  969 + 'STRING_LITERAL2' : ['VarOrTerm',
  970 + 'PropertyListNotEmpty'],
  971 + 'STRING_LITERAL_LONG1' : ['VarOrTerm',
  972 + 'PropertyListNotEmpty'],
  973 + 'STRING_LITERAL_LONG2' : ['VarOrTerm',
  974 + 'PropertyListNotEmpty'],
  975 + 'VAR1' : ['VarOrTerm',
  976 + 'PropertyListNotEmpty'],
  977 + 'VAR2' : ['VarOrTerm',
  978 + 'PropertyListNotEmpty'],
  979 + },
  980 + 'UnaryExpression' : {
  981 + "!" : ["!",
  982 + 'PrimaryExpression'],
  983 + "(" : ['PrimaryExpression'],
  984 + "+" : ["+", 'PrimaryExpression'], # GK: Added back due to conflict
  985 + "-" : ["-", 'PrimaryExpression'], # GK: Added back due to conflict
  986 + "BOUND" : ['PrimaryExpression'],
  987 + "DATATYPE" : ['PrimaryExpression'],
  988 + "LANG" : ['PrimaryExpression'],
  989 + "LANGMATCHES" : ['PrimaryExpression'],
  990 + "REGEX" : ['PrimaryExpression'],
  991 + "STR" : ['PrimaryExpression'],
  992 + 'BooleanLiteral' : ['PrimaryExpression'],
  993 + 'DECIMAL' : ['PrimaryExpression'],
  994 + 'DOUBLE' : ['PrimaryExpression'],
  995 + 'INTEGER' : ['PrimaryExpression'],
  996 + 'IRI_REF' : ['PrimaryExpression'],
  997 + 'PNAME_LN' : ['PrimaryExpression'],
  998 + 'PNAME_NS' : ['PrimaryExpression'],
  999 + 'STRING_LITERAL1' : ['PrimaryExpression'],
  1000 + 'STRING_LITERAL2' : ['PrimaryExpression'],
  1001 + 'STRING_LITERAL_LONG1' : ['PrimaryExpression'],
  1002 + 'STRING_LITERAL_LONG2' : ['PrimaryExpression'],
  1003 + 'VAR1' : ['PrimaryExpression'],
  1004 + 'VAR2' : ['PrimaryExpression'],
  1005 + "ISBLANK" : ['PrimaryExpression'],
  1006 + "ISIRI" : ['PrimaryExpression'],
  1007 + "ISLITERAL" : ['PrimaryExpression'],
  1008 + "ISURI" : ['PrimaryExpression'],
  1009 + "SAMETERM" : ['PrimaryExpression'],
  1010 + },
  1011 + 'ValueLogical' : {
  1012 + "!" : ['RelationalExpression'],
  1013 + "(" : ['RelationalExpression'],
  1014 + "+" : ['RelationalExpression'],