text: // exports
  exports.SparqlParser = {};
  var SparqlParser = exports.SparqlParser;
  
  SparqlParser.parser = (function(){
    /*
     * Generated by PEG.js 0.7.0.
     *
     * http://pegjs.majda.cz/
     */
    
    function quote(s) {
      /*
       * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a
       * string literal except for the closing quote character, backslash,
       * carriage return, line separator, paragraph separator, and line feed.
       * Any character may appear in the form of an escape sequence.
       *
       * For portability, we also escape escape all control and non-ASCII
       * characters. Note that "\0" and "\v" escape sequences are not used
       * because JSHint does not like the first and IE the second.
       */
       return '"' + s
        .replace(/\\/g, '\\\\')  // backslash
        .replace(/"/g, '\\"')    // closing quote character
        .replace(/\x08/g, '\\b') // backspace
        .replace(/\t/g, '\\t')   // horizontal tab
        .replace(/\n/g, '\\n')   // line feed
        .replace(/\f/g, '\\f')   // form feed
        .replace(/\r/g, '\\r')   // carriage return
        .replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, escape)
        + '"';
    }
    
    var result = {
      /*
       * Parses the input with a generated parser. If the parsing is successfull,
       * returns a value explicitly or implicitly specified by the grammar from
       * which the parser was generated (see |PEG.buildParser|). If the parsing is
       * unsuccessful, throws |PEG.parser.SyntaxError| describing the error.
       */
      parse: function(input, startRule) {
        var parseFunctions = {
          "SPARQL": parse_SPARQL,
          "Query": parse_Query,
          "Prologue": parse_Prologue,
          "BaseDecl": parse_BaseDecl,
          "PrefixDecl": parse_PrefixDecl,
          "SelectQuery": parse_SelectQuery,
          "SubSelect": parse_SubSelect,
          "SelectClause": parse_SelectClause,
          "ConstructQuery": parse_ConstructQuery,
          "DescribeQuery": parse_DescribeQuery,
          "AskQuery": parse_AskQuery,
          "DatasetClause": parse_DatasetClause,
          "DefaultGraphClause": parse_DefaultGraphClause,
          "NamedGraphClause": parse_NamedGraphClause,
          "WhereClause": parse_WhereClause,
          "SolutionModifier": parse_SolutionModifier,
          "GroupClause": parse_GroupClause,
          "GroupCondition": parse_GroupCondition,
          "HavingClause": parse_HavingClause,
          "OrderClause": parse_OrderClause,
          "OrderCondition": parse_OrderCondition,
          "LimitOffsetClauses": parse_LimitOffsetClauses,
          "LimitClause": parse_LimitClause,
          "OffsetClause": parse_OffsetClause,
          "BindingsClause": parse_BindingsClause,
          "BindingValue": parse_BindingValue,
          "Update": parse_Update,
          "Update1": parse_Update1,
          "Load": parse_Load,
          "Clear": parse_Clear,
          "Drop": parse_Drop,
          "Create": parse_Create,
          "InsertData": parse_InsertData,
          "DeleteData": parse_DeleteData,
          "DeleteWhere": parse_DeleteWhere,
          "Modify": parse_Modify,
          "DeleteClause": parse_DeleteClause,
          "InsertClause": parse_InsertClause,
          "UsingClause": parse_UsingClause,
          "GraphRef": parse_GraphRef,
          "GraphRefAll": parse_GraphRefAll,
          "QuadPattern": parse_QuadPattern,
          "QuadData": parse_QuadData,
          "Quads": parse_Quads,
          "QuadsNotTriples": parse_QuadsNotTriples,
          "TriplesTemplate": parse_TriplesTemplate,
          "GroupGraphPattern": parse_GroupGraphPattern,
          "GroupGraphPatternSub": parse_GroupGraphPatternSub,
          "TriplesBlock": parse_TriplesBlock,
          "GraphPatternNotTriples": parse_GraphPatternNotTriples,
          "OptionalGraphPattern": parse_OptionalGraphPattern,
          "GraphGraphPattern": parse_GraphGraphPattern,
          "ServiceGraphPattern": parse_ServiceGraphPattern,
          "MinusGraphPattern": parse_MinusGraphPattern,
          "GroupOrUnionGraphPattern": parse_GroupOrUnionGraphPattern,
          "Filter": parse_Filter,
          "Constraint": parse_Constraint,
          "FunctionCall": parse_FunctionCall,
          "ArgList": parse_ArgList,
          "ExpressionList": parse_ExpressionList,
          "ConstructTemplate": parse_ConstructTemplate,
          "ConstructTriples": parse_ConstructTriples,
          "TriplesSameSubject": parse_TriplesSameSubject,
          "PropertyListNotEmpty": parse_PropertyListNotEmpty,
          "PropertyList": parse_PropertyList,
          "ObjectList": parse_ObjectList,
          "Verb": parse_Verb,
          "TriplesSameSubjectPath": parse_TriplesSameSubjectPath,
          "PropertyListNotEmptyPath": parse_PropertyListNotEmptyPath,
          "PropertyListPath": parse_PropertyListPath,
          "VerbPath": parse_VerbPath,
          "PathAlternative": parse_PathAlternative,
          "PathSequence": parse_PathSequence,
          "PathElt": parse_PathElt,
          "PathEltOrInverse": parse_PathEltOrInverse,
          "PathMod": parse_PathMod,
          "PathPrimary": parse_PathPrimary,
          "PathNegatedPropertySet": parse_PathNegatedPropertySet,
          "PathOneInPropertySet": parse_PathOneInPropertySet,
          "TriplesNode": parse_TriplesNode,
          "BlankNodePropertyList": parse_BlankNodePropertyList,
          "Collection": parse_Collection,
          "GraphNode": parse_GraphNode,
          "VarOrTerm": parse_VarOrTerm,
          "VarOrIRIref": parse_VarOrIRIref,
          "Var": parse_Var,
          "GraphTerm": parse_GraphTerm,
          "ConditionalOrExpression": parse_ConditionalOrExpression,
          "ConditionalAndExpression": parse_ConditionalAndExpression,
          "RelationalExpression": parse_RelationalExpression,
          "AdditiveExpression": parse_AdditiveExpression,
          "MultiplicativeExpression": parse_MultiplicativeExpression,
          "UnaryExpression": parse_UnaryExpression,
          "PrimaryExpression": parse_PrimaryExpression,
          "BrackettedExpression": parse_BrackettedExpression,
          "BuiltInCall": parse_BuiltInCall,
          "RegexExpression": parse_RegexExpression,
          "ExistsFunc": parse_ExistsFunc,
          "NotExistsFunc": parse_NotExistsFunc,
          "Aggregate": parse_Aggregate,
          "IRIrefOrFunction": parse_IRIrefOrFunction,
          "RDFLiteral": parse_RDFLiteral,
          "NumericLiteral": parse_NumericLiteral,
          "NumericLiteralUnsigned": parse_NumericLiteralUnsigned,
          "NumericLiteralPositive": parse_NumericLiteralPositive,
          "NumericLiteralNegative": parse_NumericLiteralNegative,
          "BooleanLiteral": parse_BooleanLiteral,
          "String": parse_String,
          "IRIref": parse_IRIref,
          "PrefixedName": parse_PrefixedName,
          "BlankNode": parse_BlankNode,
          "IRI_REF": parse_IRI_REF,
          "PNAME_NS": parse_PNAME_NS,
          "PNAME_LN": parse_PNAME_LN,
          "BLANK_NODE_LABEL": parse_BLANK_NODE_LABEL,
          "VAR1": parse_VAR1,
          "VAR2": parse_VAR2,
          "LANGTAG": parse_LANGTAG,
          "INTEGER": parse_INTEGER,
          "DECIMAL": parse_DECIMAL,
          "DOUBLE": parse_DOUBLE,
          "INTEGER_POSITIVE": parse_INTEGER_POSITIVE,
          "DECIMAL_POSITIVE": parse_DECIMAL_POSITIVE,
          "DOUBLE_POSITIVE": parse_DOUBLE_POSITIVE,
          "INTEGER_NEGATIVE": parse_INTEGER_NEGATIVE,
          "DECIMAL_NEGATIVE": parse_DECIMAL_NEGATIVE,
          "DOUBLE_NEGATIVE": parse_DOUBLE_NEGATIVE,
          "EXPONENT": parse_EXPONENT,
          "STRING_LITERAL1": parse_STRING_LITERAL1,
          "STRING_LITERAL2": parse_STRING_LITERAL2,
          "STRING_LITERAL_LONG1": parse_STRING_LITERAL_LONG1,
          "STRING_LITERAL_LONG2": parse_STRING_LITERAL_LONG2,
          "ECHAR": parse_ECHAR,
          "NIL": parse_NIL,
          "WS": parse_WS,
          "COMMENT": parse_COMMENT,
          "ANON": parse_ANON,
          "PN_CHARS_BASE": parse_PN_CHARS_BASE,
          "PN_CHARS_U": parse_PN_CHARS_U,
          "VARNAME": parse_VARNAME,
          "PN_CHARS": parse_PN_CHARS,
          "PN_PREFIX": parse_PN_PREFIX,
          "PN_LOCAL": parse_PN_LOCAL
        };
        
        if (startRule !== undefined) {
          if (parseFunctions[startRule] === undefined) {
            throw new Error("Invalid rule name: " + quote(startRule) + ".");
          }
        } else {
          startRule = "SPARQL";
        }
        
        var pos = 0;
        var reportFailures = 0;
        var rightmostFailuresPos = 0;
        var rightmostFailuresExpected = [];
        
        function padLeft(input, padding, length) {
          var result = input;
          
          var padLength = length - input.length;
          for (var i = 0; i < padLength; i++) {
            result = padding + result;
          }
          
          return result;
        }
        
        function escape(ch) {
          var charCode = ch.charCodeAt(0);
          var escapeChar;
          var length;
          
          if (charCode <= 0xFF) {
            escapeChar = 'x';
            length = 2;
          } else {
            escapeChar = 'u';
            length = 4;
          }
          
          return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length);
        }
        
        function matchFailed(failure) {
          if (pos < rightmostFailuresPos) {
            return;
          }
          
          if (pos > rightmostFailuresPos) {
            rightmostFailuresPos = pos;
            rightmostFailuresExpected = [];
          }
          
          rightmostFailuresExpected.push(failure);
        }
        
        function parse_SPARQL() {
          var result0;
          
          result0 = parse_Query();
          if (result0 === null) {
            result0 = parse_Update();
          }
          return result0;
        }
        
        function parse_Query() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_Prologue();
          if (result0 !== null) {
            result1 = parse_SelectQuery();
            if (result1 === null) {
              result1 = parse_ConstructQuery();
              if (result1 === null) {
                result1 = parse_DescribeQuery();
                if (result1 === null) {
                  result1 = parse_AskQuery();
                }
              }
            }
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, p, q) {
                return {token: 'query',
                        kind: 'query',
                        prologue: p,
                        units: [q]};
          })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[2] Query");
          }
          return result0;
        }
        
        function parse_Prologue() {
          var result0, result1, result2, result3;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_BaseDecl();
          result0 = result0 !== null ? result0 : "";
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = [];
              result3 = parse_PrefixDecl();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_PrefixDecl();
              }
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, b, pfx) {
                return { token: 'prologue',
                         base: b,
                         prefixes: pfx }
          })(pos0, result0[0], result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[3] Prologue");
          }
          return result0;
        }
        
        function parse_BaseDecl() {
          var result0, result1, result2, result3;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            if (input.substr(pos, 4) === "BASE") {
              result1 = "BASE";
              pos += 4;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("\"BASE\"");
              }
            }
            if (result1 === null) {
              if (input.substr(pos, 4) === "base") {
                result1 = "base";
                pos += 4;
              } else {
                result1 = null;
                if (reportFailures === 0) {
                  matchFailed("\"base\"");
                }
              }
            }
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                result3 = parse_IRI_REF();
                if (result3 !== null) {
                  result0 = [result0, result1, result2, result3];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, i) {
                registerDefaultPrefix(i);
          
                var base = {};
                base.token = 'base';
                base.value = i;
          
                return base;
          })(pos0, result0[3]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[4] BaseDecl");
          }
          return result0;
        }
        
        function parse_PrefixDecl() {
          var result0, result1, result2, result3, result4, result5;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            if (input.substr(pos, 6) === "PREFIX") {
              result1 = "PREFIX";
              pos += 6;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("\"PREFIX\"");
              }
            }
            if (result1 === null) {
              if (input.substr(pos, 6) === "prefix") {
                result1 = "prefix";
                pos += 6;
              } else {
                result1 = null;
                if (reportFailures === 0) {
                  matchFailed("\"prefix\"");
                }
              }
            }
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                result3 = parse_PNAME_NS();
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    result5 = parse_IRI_REF();
                    if (result5 !== null) {
                      result0 = [result0, result1, result2, result3, result4, result5];
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, p, l) {
          
                registerPrefix(p,l);
          
                var prefix = {};
                prefix.token = 'prefix';
                prefix.prefix = p;
                prefix.local = l;
          
                return prefix;
          })(pos0, result0[3], result0[5]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[5] PrefixDecl");
          }
          return result0;
        }
        
        function parse_SelectQuery() {
          var result0, result1, result2, result3, result4, result5, result6, result7, result8;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_SelectClause();
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = [];
              result3 = parse_DatasetClause();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_DatasetClause();
              }
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result4 = parse_WhereClause();
                  if (result4 !== null) {
                    result5 = [];
                    result6 = parse_WS();
                    while (result6 !== null) {
                      result5.push(result6);
                      result6 = parse_WS();
                    }
                    if (result5 !== null) {
                      result6 = parse_SolutionModifier();
                      if (result6 !== null) {
                        result7 = [];
                        result8 = parse_WS();
                        while (result8 !== null) {
                          result7.push(result8);
                          result8 = parse_WS();
                        }
                        if (result7 !== null) {
                          result8 = parse_BindingsClause();
                          if (result8 !== null) {
                            result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8];
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, s, gs, w, sm) {
          
                var dataset = {'named':[], 'implicit':[]};
                for(var i=0; i<gs.length; i++) {
                    var g = gs[i];
                    if(g.kind === 'default') {
                        dataset['implicit'].push(g.graph);
                    } else {
                        dataset['named'].push(g.graph)
                    }
                }
          
          
                if(dataset['named'].length === 0 && dataset['implicit'].length === 0) {
                    dataset['implicit'].push({token:'uri',
                                             prefix:null, 
                                             suffix:null, 
                                             value:'https://github.com/antoniogarrote/rdfstore-js#default_graph'});
                }
          
                var query = {};
                query.kind = 'select';
                query.token = 'executableunit'
                query.dataset = dataset;
                query.projection = s.vars;
                query.modifier = s.modifier;
                query.pattern = w
                
                if(sm!=null && sm.limit!=null) {
                    query.limit = sm.limit;
                }
                if(sm!=null && sm.offset!=null) {
                    query.offset = sm.offset;
                }
                if(sm!=null && (sm.order!=null && sm.order!="")) {
                    query.order = sm.order;
                }
                if(sm!=null && sm.group!=null) {
                    query.group = sm.group;
                }
          
                return query
          })(pos0, result0[0], result0[2], result0[4], result0[6]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[6] SelectQuery");
          }
          return result0;
        }
        
        function parse_SubSelect() {
          var result0, result1, result2;
          var pos0;
          
          reportFailures++;
          pos0 = pos;
          result0 = parse_SelectClause();
          if (result0 !== null) {
            result1 = parse_WhereClause();
            if (result1 !== null) {
              result2 = parse_SolutionModifier();
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos0;
              }
            } else {
              result0 = null;
              pos = pos0;
            }
          } else {
            result0 = null;
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[7] SubSelect");
          }
          return result0;
        }
        
        function parse_SelectClause() {
          var result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14, result15, result16, result17;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            if (input.substr(pos, 6) === "SELECT") {
              result1 = "SELECT";
              pos += 6;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("\"SELECT\"");
              }
            }
            if (result1 === null) {
              if (input.substr(pos, 6) === "select") {
                result1 = "select";
                pos += 6;
              } else {
                result1 = null;
                if (reportFailures === 0) {
                  matchFailed("\"select\"");
                }
              }
            }
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                if (input.substr(pos, 8) === "DISTINCT") {
                  result3 = "DISTINCT";
                  pos += 8;
                } else {
                  result3 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"DISTINCT\"");
                  }
                }
                if (result3 === null) {
                  if (input.substr(pos, 8) === "distinct") {
                    result3 = "distinct";
                    pos += 8;
                  } else {
                    result3 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"distinct\"");
                    }
                  }
                }
                if (result3 === null) {
                  if (input.substr(pos, 7) === "REDUCED") {
                    result3 = "REDUCED";
                    pos += 7;
                  } else {
                    result3 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"REDUCED\"");
                    }
                  }
                  if (result3 === null) {
                    if (input.substr(pos, 7) === "reduced") {
                      result3 = "reduced";
                      pos += 7;
                    } else {
                      result3 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"reduced\"");
                      }
                    }
                  }
                }
                result3 = result3 !== null ? result3 : "";
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    pos2 = pos;
                    result6 = [];
                    result7 = parse_WS();
                    while (result7 !== null) {
                      result6.push(result7);
                      result7 = parse_WS();
                    }
                    if (result6 !== null) {
                      result7 = parse_Var();
                      if (result7 !== null) {
                        result8 = [];
                        result9 = parse_WS();
                        while (result9 !== null) {
                          result8.push(result9);
                          result9 = parse_WS();
                        }
                        if (result8 !== null) {
                          result6 = [result6, result7, result8];
                        } else {
                          result6 = null;
                          pos = pos2;
                        }
                      } else {
                        result6 = null;
                        pos = pos2;
                      }
                    } else {
                      result6 = null;
                      pos = pos2;
                    }
                    if (result6 === null) {
                      pos2 = pos;
                      result6 = [];
                      result7 = parse_WS();
                      while (result7 !== null) {
                        result6.push(result7);
                        result7 = parse_WS();
                      }
                      if (result6 !== null) {
                        if (input.charCodeAt(pos) === 40) {
                          result7 = "(";
                          pos++;
                        } else {
                          result7 = null;
                          if (reportFailures === 0) {
                            matchFailed("\"(\"");
                          }
                        }
                        if (result7 !== null) {
                          result8 = [];
                          result9 = parse_WS();
                          while (result9 !== null) {
                            result8.push(result9);
                            result9 = parse_WS();
                          }
                          if (result8 !== null) {
                            result9 = parse_ConditionalOrExpression();
                            if (result9 !== null) {
                              result10 = [];
                              result11 = parse_WS();
                              while (result11 !== null) {
                                result10.push(result11);
                                result11 = parse_WS();
                              }
                              if (result10 !== null) {
                                if (input.substr(pos, 2) === "AS") {
                                  result11 = "AS";
                                  pos += 2;
                                } else {
                                  result11 = null;
                                  if (reportFailures === 0) {
                                    matchFailed("\"AS\"");
                                  }
                                }
                                if (result11 === null) {
                                  if (input.substr(pos, 2) === "as") {
                                    result11 = "as";
                                    pos += 2;
                                  } else {
                                    result11 = null;
                                    if (reportFailures === 0) {
                                      matchFailed("\"as\"");
                                    }
                                  }
                                }
                                if (result11 !== null) {
                                  result12 = [];
                                  result13 = parse_WS();
                                  while (result13 !== null) {
                                    result12.push(result13);
                                    result13 = parse_WS();
                                  }
                                  if (result12 !== null) {
                                    result13 = parse_Var();
                                    if (result13 !== null) {
                                      result14 = [];
                                      result15 = parse_WS();
                                      while (result15 !== null) {
                                        result14.push(result15);
                                        result15 = parse_WS();
                                      }
                                      if (result14 !== null) {
                                        if (input.charCodeAt(pos) === 41) {
                                          result15 = ")";
                                          pos++;
                                        } else {
                                          result15 = null;
                                          if (reportFailures === 0) {
                                            matchFailed("\")\"");
                                          }
                                        }
                                        if (result15 !== null) {
                                          result16 = [];
                                          result17 = parse_WS();
                                          while (result17 !== null) {
                                            result16.push(result17);
                                            result17 = parse_WS();
                                          }
                                          if (result16 !== null) {
                                            result6 = [result6, result7, result8, result9, result10, result11, result12, result13, result14, result15, result16];
                                          } else {
                                            result6 = null;
                                            pos = pos2;
                                          }
                                        } else {
                                          result6 = null;
                                          pos = pos2;
                                        }
                                      } else {
                                        result6 = null;
                                        pos = pos2;
                                      }
                                    } else {
                                      result6 = null;
                                      pos = pos2;
                                    }
                                  } else {
                                    result6 = null;
                                    pos = pos2;
                                  }
                                } else {
                                  result6 = null;
                                  pos = pos2;
                                }
                              } else {
                                result6 = null;
                                pos = pos2;
                              }
                            } else {
                              result6 = null;
                              pos = pos2;
                            }
                          } else {
                            result6 = null;
                            pos = pos2;
                          }
                        } else {
                          result6 = null;
                          pos = pos2;
                        }
                      } else {
                        result6 = null;
                        pos = pos2;
                      }
                    }
                    if (result6 !== null) {
                      result5 = [];
                      while (result6 !== null) {
                        result5.push(result6);
                        pos2 = pos;
                        result6 = [];
                        result7 = parse_WS();
                        while (result7 !== null) {
                          result6.push(result7);
                          result7 = parse_WS();
                        }
                        if (result6 !== null) {
                          result7 = parse_Var();
                          if (result7 !== null) {
                            result8 = [];
                            result9 = parse_WS();
                            while (result9 !== null) {
                              result8.push(result9);
                              result9 = parse_WS();
                            }
                            if (result8 !== null) {
                              result6 = [result6, result7, result8];
                            } else {
                              result6 = null;
                              pos = pos2;
                            }
                          } else {
                            result6 = null;
                            pos = pos2;
                          }
                        } else {
                          result6 = null;
                          pos = pos2;
                        }
                        if (result6 === null) {
                          pos2 = pos;
                          result6 = [];
                          result7 = parse_WS();
                          while (result7 !== null) {
                            result6.push(result7);
                            result7 = parse_WS();
                          }
                          if (result6 !== null) {
                            if (input.charCodeAt(pos) === 40) {
                              result7 = "(";
                              pos++;
                            } else {
                              result7 = null;
                              if (reportFailures === 0) {
                                matchFailed("\"(\"");
                              }
                            }
                            if (result7 !== null) {
                              result8 = [];
                              result9 = parse_WS();
                              while (result9 !== null) {
                                result8.push(result9);
                                result9 = parse_WS();
                              }
                              if (result8 !== null) {
                                result9 = parse_ConditionalOrExpression();
                                if (result9 !== null) {
                                  result10 = [];
                                  result11 = parse_WS();
                                  while (result11 !== null) {
                                    result10.push(result11);
                                    result11 = parse_WS();
                                  }
                                  if (result10 !== null) {
                                    if (input.substr(pos, 2) === "AS") {
                                      result11 = "AS";
                                      pos += 2;
                                    } else {
                                      result11 = null;
                                      if (reportFailures === 0) {
                                        matchFailed("\"AS\"");
                                      }
                                    }
                                    if (result11 === null) {
                                      if (input.substr(pos, 2) === "as") {
                                        result11 = "as";
                                        pos += 2;
                                      } else {
                                        result11 = null;
                                        if (reportFailures === 0) {
                                          matchFailed("\"as\"");
                                        }
                                      }
                                    }
                                    if (result11 !== null) {
                                      result12 = [];
                                      result13 = parse_WS();
                                      while (result13 !== null) {
                                        result12.push(result13);
                                        result13 = parse_WS();
                                      }
                                      if (result12 !== null) {
                                        result13 = parse_Var();
                                        if (result13 !== null) {
                                          result14 = [];
                                          result15 = parse_WS();
                                          while (result15 !== null) {
                                            result14.push(result15);
                                            result15 = parse_WS();
                                          }
                                          if (result14 !== null) {
                                            if (input.charCodeAt(pos) === 41) {
                                              result15 = ")";
                                              pos++;
                                            } else {
                                              result15 = null;
                                              if (reportFailures === 0) {
                                                matchFailed("\")\"");
                                              }
                                            }
                                            if (result15 !== null) {
                                              result16 = [];
                                              result17 = parse_WS();
                                              while (result17 !== null) {
                                                result16.push(result17);
                                                result17 = parse_WS();
                                              }
                                              if (result16 !== null) {
                                                result6 = [result6, result7, result8, result9, result10, result11, result12, result13, result14, result15, result16];
                                              } else {
                                                result6 = null;
                                                pos = pos2;
                                              }
                                            } else {
                                              result6 = null;
                                              pos = pos2;
                                            }
                                          } else {
                                            result6 = null;
                                            pos = pos2;
                                          }
                                        } else {
                                          result6 = null;
                                          pos = pos2;
                                        }
                                      } else {
                                        result6 = null;
                                        pos = pos2;
                                      }
                                    } else {
                                      result6 = null;
                                      pos = pos2;
                                    }
                                  } else {
                                    result6 = null;
                                    pos = pos2;
                                  }
                                } else {
                                  result6 = null;
                                  pos = pos2;
                                }
                              } else {
                                result6 = null;
                                pos = pos2;
                              }
                            } else {
                              result6 = null;
                              pos = pos2;
                            }
                          } else {
                            result6 = null;
                            pos = pos2;
                          }
                        }
                      }
                    } else {
                      result5 = null;
                    }
                    if (result5 === null) {
                      pos2 = pos;
                      result5 = [];
                      result6 = parse_WS();
                      while (result6 !== null) {
                        result5.push(result6);
                        result6 = parse_WS();
                      }
                      if (result5 !== null) {
                        if (input.charCodeAt(pos) === 42) {
                          result6 = "*";
                          pos++;
                        } else {
                          result6 = null;
                          if (reportFailures === 0) {
                            matchFailed("\"*\"");
                          }
                        }
                        if (result6 !== null) {
                          result7 = [];
                          result8 = parse_WS();
                          while (result8 !== null) {
                            result7.push(result8);
                            result8 = parse_WS();
                          }
                          if (result7 !== null) {
                            result5 = [result5, result6, result7];
                          } else {
                            result5 = null;
                            pos = pos2;
                          }
                        } else {
                          result5 = null;
                          pos = pos2;
                        }
                      } else {
                        result5 = null;
                        pos = pos2;
                      }
                    }
                    if (result5 !== null) {
                      result0 = [result0, result1, result2, result3, result4, result5];
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, mod, proj) {
               var vars = [];
                if(proj.length === 3 && proj[1]==="*") {
                    return {vars: [{token: 'variable', kind:'*'}], modifier:arrayToString(mod)};
                }
          
                for(var i=0; i< proj.length; i++) {
                    var aVar = proj[i];
          
                    if(aVar.length === 3) {
                        vars.push({token: 'variable', kind:'var', value:aVar[1]});
                    } else {
                        vars.push({token: 'variable', kind:'aliased', expression: aVar[3], alias:aVar[7]})
                    }
                }
          
                return {vars: vars, modifier:arrayToString(mod)};
          })(pos0, result0[3], result0[5]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[8] SelectClause");
          }
          return result0;
        }
        
        function parse_ConstructQuery() {
          var result0, result1, result2, result3, result4, result5, result6, result7, result8, result9;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            if (input.substr(pos, 9) === "CONSTRUCT") {
              result1 = "CONSTRUCT";
              pos += 9;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("\"CONSTRUCT\"");
              }
            }
            if (result1 === null) {
              if (input.substr(pos, 9) === "construct") {
                result1 = "construct";
                pos += 9;
              } else {
                result1 = null;
                if (reportFailures === 0) {
                  matchFailed("\"construct\"");
                }
              }
            }
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                result3 = parse_ConstructTemplate();
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    result5 = [];
                    result6 = parse_DatasetClause();
                    while (result6 !== null) {
                      result5.push(result6);
                      result6 = parse_DatasetClause();
                    }
                    if (result5 !== null) {
                      result6 = [];
                      result7 = parse_WS();
                      while (result7 !== null) {
                        result6.push(result7);
                        result7 = parse_WS();
                      }
                      if (result6 !== null) {
                        result7 = parse_WhereClause();
                        if (result7 !== null) {
                          result8 = [];
                          result9 = parse_WS();
                          while (result9 !== null) {
                            result8.push(result9);
                            result9 = parse_WS();
                          }
                          if (result8 !== null) {
                            result9 = parse_SolutionModifier();
                            if (result9 !== null) {
                              result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9];
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, t, gs, w, sm) {
                var dataset = {'named':[], 'implicit':[]};
                for(var i=0; i<gs.length; i++) {
                    var g = gs[i];
                    if(g.kind === 'default') {
                        dataset['implicit'].push(g.graph);
                    } else {
                        dataset['named'].push(g.graph)
                    }
                }
          
          
                if(dataset['named'].length === 0 && dataset['implicit'].length === 0) {
                    dataset['implicit'].push({token:'uri',
                                             prefix:null, 
                                             suffix:null, 
                                             value:'https://github.com/antoniogarrote/rdfstore-js#default_graph'});
                }
          
                var query = {};
                query.kind = 'construct';
                query.token = 'executableunit'
                query.dataset = dataset;
                query.template = t;
                query.pattern = w
                
                if(sm!=null && sm.limit!=null) {
                    query.limit = sm.limit;
                }
                if(sm!=null && sm.offset!=null) {
                    query.offset = sm.offset;
                }
                if(sm!=null && (sm.order!=null && sm.order!="")) {
                    query.order = sm.order;
                }
                return query
          
          })(pos0, result0[3], result0[5], result0[7], result0[9]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[9] ConstructQuery");
          }
          return result0;
        }
        
        function parse_DescribeQuery() {
          var result0, result1, result2, result3, result4;
          var pos0;
          
          reportFailures++;
          pos0 = pos;
          if (input.substr(pos, 8) === "DESCRIBE") {
            result0 = "DESCRIBE";
            pos += 8;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"DESCRIBE\"");
            }
          }
          if (result0 !== null) {
            result2 = parse_VarOrIRIref();
            if (result2 !== null) {
              result1 = [];
              while (result2 !== null) {
                result1.push(result2);
                result2 = parse_VarOrIRIref();
              }
            } else {
              result1 = null;
            }
            if (result1 === null) {
              if (input.charCodeAt(pos) === 42) {
                result1 = "*";
                pos++;
              } else {
                result1 = null;
                if (reportFailures === 0) {
                  matchFailed("\"*\"");
                }
              }
            }
            if (result1 !== null) {
              result2 = [];
              result3 = parse_DatasetClause();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_DatasetClause();
              }
              if (result2 !== null) {
                result3 = parse_WhereClause();
                result3 = result3 !== null ? result3 : "";
                if (result3 !== null) {
                  result4 = parse_SolutionModifier();
                  if (result4 !== null) {
                    result0 = [result0, result1, result2, result3, result4];
                  } else {
                    result0 = null;
                    pos = pos0;
                  }
                } else {
                  result0 = null;
                  pos = pos0;
                }
              } else {
                result0 = null;
                pos = pos0;
              }
            } else {
              result0 = null;
              pos = pos0;
            }
          } else {
            result0 = null;
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[10] DescribeQuery");
          }
          return result0;
        }
        
        function parse_AskQuery() {
          var result0, result1, result2, result3, result4, result5;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            if (input.substr(pos, 3) === "ASK") {
              result1 = "ASK";
              pos += 3;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("\"ASK\"");
              }
            }
            if (result1 === null) {
              if (input.substr(pos, 3) === "ask") {
                result1 = "ask";
                pos += 3;
              } else {
                result1 = null;
                if (reportFailures === 0) {
                  matchFailed("\"ask\"");
                }
              }
            }
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                result3 = [];
                result4 = parse_DatasetClause();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_DatasetClause();
                }
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    result5 = parse_WhereClause();
                    if (result5 !== null) {
                      result0 = [result0, result1, result2, result3, result4, result5];
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, gs, w) {
                var dataset = {'named':[], 'implicit':[]};
                for(var i=0; i<gs.length; i++) {
                    var g = gs[i];
                    if(g.kind === 'implicit') {
                        dataset['implicit'].push(g.graph);
                    } else {
                        dataset['named'].push(g.graph)
                    }
                }
          
          
                if(dataset['named'].length === 0 && dataset['implicit'].length === 0) {
                    dataset['implicit'].push({token:'uri',
                                              prefix:null,
                                              suffix:null,
                                              value:'https://github.com/antoniogarrote/rdfstore-js#default_graph'});
                }
          
                var query = {};
                query.kind = 'ask';
                query.token = 'executableunit'
                query.dataset = dataset;
                query.pattern = w
          
                return query
          })(pos0, result0[3], result0[5]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[11] AskQuery");
          }
          return result0;
        }
        
        function parse_DatasetClause() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 4) === "FROM") {
            result0 = "FROM";
            pos += 4;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"FROM\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 4) === "from") {
              result0 = "from";
              pos += 4;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"from\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = parse_DefaultGraphClause();
              if (result2 === null) {
                result2 = parse_NamedGraphClause();
              }
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result0 = [result0, result1, result2, result3];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, gs) {
                return gs;
          })(pos0, result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[12] DatasetClause");
          }
          return result0;
        }
        
        function parse_DefaultGraphClause() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            result1 = parse_IRIref();
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, s) {
              return {graph:s , kind:'default', token:'graphClause'}
          })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[13] DefaultGraphClause");
          }
          return result0;
        }
        
        function parse_NamedGraphClause() {
          var result0, result1, result2;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 5) === "NAMED") {
            result0 = "NAMED";
            pos += 5;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"NAMED\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 5) === "named") {
              result0 = "named";
              pos += 5;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"named\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = parse_IRIref();
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, s) {      
                return {graph:s, kind:'named', token:'graphCluase'};
          })(pos0, result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[14] NamedGraphClause");
          }
          return result0;
        }
        
        function parse_WhereClause() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 5) === "WHERE") {
            result0 = "WHERE";
            pos += 5;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"WHERE\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 5) === "where") {
              result0 = "where";
              pos += 5;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"where\"");
              }
            }
          }
          result0 = result0 !== null ? result0 : "";
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = parse_GroupGraphPattern();
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result0 = [result0, result1, result2, result3];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, g) {
                return g;
          })(pos0, result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[16] WhereClause");
          }
          return result0;
        }
        
        function parse_SolutionModifier() {
          var result0, result1, result2, result3;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_GroupClause();
          result0 = result0 !== null ? result0 : "";
          if (result0 !== null) {
            result1 = parse_HavingClause();
            result1 = result1 !== null ? result1 : "";
            if (result1 !== null) {
              result2 = parse_OrderClause();
              result2 = result2 !== null ? result2 : "";
              if (result2 !== null) {
                result3 = parse_LimitOffsetClauses();
                result3 = result3 !== null ? result3 : "";
                if (result3 !== null) {
                  result0 = [result0, result1, result2, result3];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, gc, oc, lo) {
                var acum = {};
                if(lo != null) {
                    if(lo.limit != null) {
                        acum.limit = lo.limit;
                    } 
                    if(lo.offset != null) {
                        acum.offset = lo.offset;
                    }
                }
          
                if(gc != null) {
                    acum.group = gc;
                }
          
                acum.order = oc;
          
                return acum
          })(pos0, result0[0], result0[2], result0[3]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[17] SolutionModifier");
          }
          return result0;
        }
        
        function parse_GroupClause() {
          var result0, result1, result2, result3, result4, result5;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 5) === "GROUP") {
            result0 = "GROUP";
            pos += 5;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"GROUP\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 5) === "group") {
              result0 = "group";
              pos += 5;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"group\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              if (input.substr(pos, 2) === "BY") {
                result2 = "BY";
                pos += 2;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"BY\"");
                }
              }
              if (result2 === null) {
                if (input.substr(pos, 2) === "by") {
                  result2 = "by";
                  pos += 2;
                } else {
                  result2 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"by\"");
                  }
                }
              }
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result5 = parse_GroupCondition();
                  if (result5 !== null) {
                    result4 = [];
                    while (result5 !== null) {
                      result4.push(result5);
                      result5 = parse_GroupCondition();
                    }
                  } else {
                    result4 = null;
                  }
                  if (result4 !== null) {
                    result0 = [result0, result1, result2, result3, result4];
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, conds) {
                return conds;
          })(pos0, result0[4]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[18] GroupClause");
          }
          return result0;
        }
        
        function parse_GroupCondition() {
          var result0, result1, result2, result3, result4, result5, result6, result7, result8, result9;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            result1 = parse_BuiltInCall();
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, b) {
                return b;
          })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            pos1 = pos;
            result0 = [];
            result1 = parse_WS();
            while (result1 !== null) {
              result0.push(result1);
              result1 = parse_WS();
            }
            if (result0 !== null) {
              result1 = parse_FunctionCall();
              if (result1 !== null) {
                result2 = [];
                result3 = parse_WS();
                while (result3 !== null) {
                  result2.push(result3);
                  result3 = parse_WS();
                }
                if (result2 !== null) {
                  result0 = [result0, result1, result2];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
            if (result0 !== null) {
              result0 = (function(offset, f) {
                  return f;
            })(pos0, result0[1]);
            }
            if (result0 === null) {
              pos = pos0;
            }
            if (result0 === null) {
              pos0 = pos;
              pos1 = pos;
              result0 = [];
              result1 = parse_WS();
              while (result1 !== null) {
                result0.push(result1);
                result1 = parse_WS();
              }
              if (result0 !== null) {
                if (input.charCodeAt(pos) === 40) {
                  result1 = "(";
                  pos++;
                } else {
                  result1 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"(\"");
                  }
                }
                if (result1 !== null) {
                  result2 = [];
                  result3 = parse_WS();
                  while (result3 !== null) {
                    result2.push(result3);
                    result3 = parse_WS();
                  }
                  if (result2 !== null) {
                    result3 = parse_ConditionalOrExpression();
                    if (result3 !== null) {
                      result4 = [];
                      result5 = parse_WS();
                      while (result5 !== null) {
                        result4.push(result5);
                        result5 = parse_WS();
                      }
                      if (result4 !== null) {
                        pos2 = pos;
                        if (input.substr(pos, 2) === "AS") {
                          result5 = "AS";
                          pos += 2;
                        } else {
                          result5 = null;
                          if (reportFailures === 0) {
                            matchFailed("\"AS\"");
                          }
                        }
                        if (result5 === null) {
                          if (input.substr(pos, 2) === "as") {
                            result5 = "as";
                            pos += 2;
                          } else {
                            result5 = null;
                            if (reportFailures === 0) {
                              matchFailed("\"as\"");
                            }
                          }
                        }
                        if (result5 !== null) {
                          result6 = [];
                          result7 = parse_WS();
                          while (result7 !== null) {
                            result6.push(result7);
                            result7 = parse_WS();
                          }
                          if (result6 !== null) {
                            result7 = parse_Var();
                            if (result7 !== null) {
                              result5 = [result5, result6, result7];
                            } else {
                              result5 = null;
                              pos = pos2;
                            }
                          } else {
                            result5 = null;
                            pos = pos2;
                          }
                        } else {
                          result5 = null;
                          pos = pos2;
                        }
                        result5 = result5 !== null ? result5 : "";
                        if (result5 !== null) {
                          result6 = [];
                          result7 = parse_WS();
                          while (result7 !== null) {
                            result6.push(result7);
                            result7 = parse_WS();
                          }
                          if (result6 !== null) {
                            if (input.charCodeAt(pos) === 41) {
                              result7 = ")";
                              pos++;
                            } else {
                              result7 = null;
                              if (reportFailures === 0) {
                                matchFailed("\")\"");
                              }
                            }
                            if (result7 !== null) {
                              result8 = [];
                              result9 = parse_WS();
                              while (result9 !== null) {
                                result8.push(result9);
                                result9 = parse_WS();
                              }
                              if (result8 !== null) {
                                result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8];
                              } else {
                                result0 = null;
                                pos = pos1;
                              }
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
              if (result0 !== null) {
                result0 = (function(offset, e, alias) {
                    if(alias.length != 0) {
                        return {token: 'aliased_expression',
                                expression: e,
                                alias: alias[2] };
                    } else {
                        return e;
                    }
              })(pos0, result0[3], result0[5]);
              }
              if (result0 === null) {
                pos = pos0;
              }
              if (result0 === null) {
                pos0 = pos;
                pos1 = pos;
                result0 = [];
                result1 = parse_WS();
                while (result1 !== null) {
                  result0.push(result1);
                  result1 = parse_WS();
                }
                if (result0 !== null) {
                  result1 = parse_Var();
                  if (result1 !== null) {
                    result2 = [];
                    result3 = parse_WS();
                    while (result3 !== null) {
                      result2.push(result3);
                      result3 = parse_WS();
                    }
                    if (result2 !== null) {
                      result0 = [result0, result1, result2];
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
                if (result0 !== null) {
                  result0 = (function(offset, v) {
                      return v;
                })(pos0, result0[1]);
                }
                if (result0 === null) {
                  pos = pos0;
                }
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[19] GroupCondition");
          }
          return result0;
        }
        
        function parse_HavingClause() {
          var result0, result1, result2;
          var pos0;
          
          reportFailures++;
          pos0 = pos;
          if (input.substr(pos, 6) === "HAVING") {
            result0 = "HAVING";
            pos += 6;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"HAVING\"");
            }
          }
          if (result0 !== null) {
            result2 = parse_Constraint();
            if (result2 !== null) {
              result1 = [];
              while (result2 !== null) {
                result1.push(result2);
                result2 = parse_Constraint();
              }
            } else {
              result1 = null;
            }
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos0;
            }
          } else {
            result0 = null;
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[20] HavingClause");
          }
          return result0;
        }
        
        function parse_OrderClause() {
          var result0, result1, result2, result3, result4, result5, result6;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 5) === "ORDER") {
            result0 = "ORDER";
            pos += 5;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"ORDER\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 5) === "order") {
              result0 = "order";
              pos += 5;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"order\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              if (input.substr(pos, 2) === "BY") {
                result2 = "BY";
                pos += 2;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"BY\"");
                }
              }
              if (result2 === null) {
                if (input.substr(pos, 2) === "by") {
                  result2 = "by";
                  pos += 2;
                } else {
                  result2 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"by\"");
                  }
                }
              }
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result5 = parse_OrderCondition();
                  if (result5 !== null) {
                    result4 = [];
                    while (result5 !== null) {
                      result4.push(result5);
                      result5 = parse_OrderCondition();
                    }
                  } else {
                    result4 = null;
                  }
                  if (result4 !== null) {
                    result5 = [];
                    result6 = parse_WS();
                    while (result6 !== null) {
                      result5.push(result6);
                      result6 = parse_WS();
                    }
                    if (result5 !== null) {
                      result0 = [result0, result1, result2, result3, result4, result5];
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, os) {
                return os;
          })(pos0, result0[4]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[22] OrderClause");
          }
          return result0;
        }
        
        function parse_OrderCondition() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 3) === "ASC") {
            result0 = "ASC";
            pos += 3;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"ASC\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 3) === "asc") {
              result0 = "asc";
              pos += 3;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"asc\"");
              }
            }
            if (result0 === null) {
              if (input.substr(pos, 4) === "DESC") {
                result0 = "DESC";
                pos += 4;
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("\"DESC\"");
                }
              }
              if (result0 === null) {
                if (input.substr(pos, 4) === "desc") {
                  result0 = "desc";
                  pos += 4;
                } else {
                  result0 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"desc\"");
                  }
                }
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = parse_BrackettedExpression();
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result0 = [result0, result1, result2, result3];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, direction, e) {
                return { direction: direction.toUpperCase(), expression:e };
          })(pos0, result0[0], result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            pos1 = pos;
            result0 = parse_Constraint();
            if (result0 === null) {
              result0 = parse_Var();
            }
            if (result0 !== null) {
              result1 = [];
              result2 = parse_WS();
              while (result2 !== null) {
                result1.push(result2);
                result2 = parse_WS();
              }
              if (result1 !== null) {
                result0 = [result0, result1];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
            if (result0 !== null) {
              result0 = (function(offset, e) {
                if(e.token === 'var') {
                    var e = { token:'expression',
                              expressionType:'atomic',
                              primaryexpression: 'var',
                              value: e };
                }
                return { direction: 'ASC', expression:e };
            })(pos0, result0[0]);
            }
            if (result0 === null) {
              pos = pos0;
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[23] OrderCondition");
          }
          return result0;
        }
        
        function parse_LimitOffsetClauses() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_LimitClause();
          if (result0 !== null) {
            result1 = parse_OffsetClause();
            result1 = result1 !== null ? result1 : "";
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 === null) {
            pos1 = pos;
            result0 = parse_OffsetClause();
            if (result0 !== null) {
              result1 = parse_LimitClause();
              result1 = result1 !== null ? result1 : "";
              if (result1 !== null) {
                result0 = [result0, result1];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          }
          if (result0 !== null) {
            result0 = (function(offset, cls) {
                var acum = {};
                for(var i=0; i<cls.length; i++) {
                    var cl = cls[i];
                    if(cl.limit != null) {
                        acum['limit'] = cl.limit;
                    } else if(cl.offset != null){
                        acum['offset'] = cl.offset;
                    }
                }
          
                return acum;
          })(pos0, result0);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[24] LimitOffsetClauses");
          }
          return result0;
        }
        
        function parse_LimitClause() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 5) === "LIMIT") {
            result0 = "LIMIT";
            pos += 5;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"LIMIT\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 5) === "limit") {
              result0 = "limit";
              pos += 5;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"limit\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = parse_INTEGER();
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result0 = [result0, result1, result2, result3];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, i) {
            return { limit:parseInt(i.value) };
          })(pos0, result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[25] LimitClause");
          }
          return result0;
        }
        
        function parse_OffsetClause() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 6) === "OFFSET") {
            result0 = "OFFSET";
            pos += 6;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"OFFSET\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 6) === "offset") {
              result0 = "offset";
              pos += 6;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"offset\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = parse_INTEGER();
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result0 = [result0, result1, result2, result3];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, i) {
            return { offset:parseInt(i.value) };
          })(pos0, result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[26] OffsetClause");
          }
          return result0;
        }
        
        function parse_BindingsClause() {
          var result0, result1, result2, result3, result4, result5, result6;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          if (input.substr(pos, 8) === "BINDINGS") {
            result0 = "BINDINGS";
            pos += 8;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"BINDINGS\"");
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_Var();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_Var();
            }
            if (result1 !== null) {
              if (input.charCodeAt(pos) === 123) {
                result2 = "{";
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"{\"");
                }
              }
              if (result2 !== null) {
                result3 = [];
                pos1 = pos;
                if (input.charCodeAt(pos) === 40) {
                  result4 = "(";
                  pos++;
                } else {
                  result4 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"(\"");
                  }
                }
                if (result4 !== null) {
                  result6 = parse_BindingValue();
                  if (result6 !== null) {
                    result5 = [];
                    while (result6 !== null) {
                      result5.push(result6);
                      result6 = parse_BindingValue();
                    }
                  } else {
                    result5 = null;
                  }
                  if (result5 !== null) {
                    if (input.charCodeAt(pos) === 41) {
                      result6 = ")";
                      pos++;
                    } else {
                      result6 = null;
                      if (reportFailures === 0) {
                        matchFailed("\")\"");
                      }
                    }
                    if (result6 !== null) {
                      result4 = [result4, result5, result6];
                    } else {
                      result4 = null;
                      pos = pos1;
                    }
                  } else {
                    result4 = null;
                    pos = pos1;
                  }
                } else {
                  result4 = null;
                  pos = pos1;
                }
                if (result4 === null) {
                  result4 = parse_NIL();
                }
                while (result4 !== null) {
                  result3.push(result4);
                  pos1 = pos;
                  if (input.charCodeAt(pos) === 40) {
                    result4 = "(";
                    pos++;
                  } else {
                    result4 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"(\"");
                    }
                  }
                  if (result4 !== null) {
                    result6 = parse_BindingValue();
                    if (result6 !== null) {
                      result5 = [];
                      while (result6 !== null) {
                        result5.push(result6);
                        result6 = parse_BindingValue();
                      }
                    } else {
                      result5 = null;
                    }
                    if (result5 !== null) {
                      if (input.charCodeAt(pos) === 41) {
                        result6 = ")";
                        pos++;
                      } else {
                        result6 = null;
                        if (reportFailures === 0) {
                          matchFailed("\")\"");
                        }
                      }
                      if (result6 !== null) {
                        result4 = [result4, result5, result6];
                      } else {
                        result4 = null;
                        pos = pos1;
                      }
                    } else {
                      result4 = null;
                      pos = pos1;
                    }
                  } else {
                    result4 = null;
                    pos = pos1;
                  }
                  if (result4 === null) {
                    result4 = parse_NIL();
                  }
                }
                if (result3 !== null) {
                  if (input.charCodeAt(pos) === 125) {
                    result4 = "}";
                    pos++;
                  } else {
                    result4 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"}\"");
                    }
                  }
                  if (result4 !== null) {
                    result0 = [result0, result1, result2, result3, result4];
                  } else {
                    result0 = null;
                    pos = pos0;
                  }
                } else {
                  result0 = null;
                  pos = pos0;
                }
              } else {
                result0 = null;
                pos = pos0;
              }
            } else {
              result0 = null;
              pos = pos0;
            }
          } else {
            result0 = null;
            pos = pos0;
          }
          result0 = result0 !== null ? result0 : "";
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[27] BindingsClause");
          }
          return result0;
        }
        
        function parse_BindingValue() {
          var result0;
          
          reportFailures++;
          result0 = parse_IRIref();
          if (result0 === null) {
            result0 = parse_RDFLiteral();
            if (result0 === null) {
              result0 = parse_NumericLiteral();
              if (result0 === null) {
                result0 = parse_BooleanLiteral();
                if (result0 === null) {
                  if (input.substr(pos, 5) === "UNDEF") {
                    result0 = "UNDEF";
                    pos += 5;
                  } else {
                    result0 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"UNDEF\"");
                    }
                  }
                }
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[28] BindingValue");
          }
          return result0;
        }
        
        function parse_Update() {
          var result0, result1, result2, result3, result4, result5, result6;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_Prologue();
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = parse_Update1();
              if (result2 !== null) {
                pos2 = pos;
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  if (input.charCodeAt(pos) === 59) {
                    result4 = ";";
                    pos++;
                  } else {
                    result4 = null;
                    if (reportFailures === 0) {
                      matchFailed("\";\"");
                    }
                  }
                  if (result4 !== null) {
                    result5 = [];
                    result6 = parse_WS();
                    while (result6 !== null) {
                      result5.push(result6);
                      result6 = parse_WS();
                    }
                    if (result5 !== null) {
                      result6 = parse_Update();
                      result6 = result6 !== null ? result6 : "";
                      if (result6 !== null) {
                        result3 = [result3, result4, result5, result6];
                      } else {
                        result3 = null;
                        pos = pos2;
                      }
                    } else {
                      result3 = null;
                      pos = pos2;
                    }
                  } else {
                    result3 = null;
                    pos = pos2;
                  }
                } else {
                  result3 = null;
                  pos = pos2;
                }
                result3 = result3 !== null ? result3 : "";
                if (result3 !== null) {
                  result0 = [result0, result1, result2, result3];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, p, u, us) {
          
                var query = {};
                query.token = 'query';
                query.kind = 'update'
                query.prologue = p;
          
               var units = [u];
          
               if(us.length != null && us[3] != null && us[3].units != null) {
                   units = units.concat(us[3].units);
               }
          
               query.units = units;
               return query;
          })(pos0, result0[0], result0[2], result0[3]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[30] Update");
          }
          return result0;
        }
        
        function parse_Update1() {
          var result0;
          
          reportFailures++;
          result0 = parse_Load();
          if (result0 === null) {
            result0 = parse_Clear();
            if (result0 === null) {
              result0 = parse_Drop();
              if (result0 === null) {
                result0 = parse_Create();
                if (result0 === null) {
                  result0 = parse_InsertData();
                  if (result0 === null) {
                    result0 = parse_DeleteData();
                    if (result0 === null) {
                      result0 = parse_DeleteWhere();
                      if (result0 === null) {
                        result0 = parse_Modify();
                      }
                    }
                  }
                }
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[31] Update1");
          }
          return result0;
        }
        
        function parse_Load() {
          var result0, result1, result2, result3, result4, result5, result6;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 4) === "LOAD") {
            result0 = "LOAD";
            pos += 4;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"LOAD\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 4) === "load") {
              result0 = "load";
              pos += 4;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"load\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = parse_IRIref();
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  pos2 = pos;
                  if (input.substr(pos, 4) === "INTO") {
                    result4 = "INTO";
                    pos += 4;
                  } else {
                    result4 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"INTO\"");
                    }
                  }
                  if (result4 === null) {
                    if (input.substr(pos, 4) === "into") {
                      result4 = "into";
                      pos += 4;
                    } else {
                      result4 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"into\"");
                      }
                    }
                  }
                  if (result4 !== null) {
                    result5 = [];
                    result6 = parse_WS();
                    while (result6 !== null) {
                      result5.push(result6);
                      result6 = parse_WS();
                    }
                    if (result5 !== null) {
                      result6 = parse_GraphRef();
                      if (result6 !== null) {
                        result4 = [result4, result5, result6];
                      } else {
                        result4 = null;
                        pos = pos2;
                      }
                    } else {
                      result4 = null;
                      pos = pos2;
                    }
                  } else {
                    result4 = null;
                    pos = pos2;
                  }
                  result4 = result4 !== null ? result4 : "";
                  if (result4 !== null) {
                    result0 = [result0, result1, result2, result3, result4];
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, sg, dg) {
                var query = {};
                query.kind = 'load';
                query.token = 'executableunit'
                query.sourceGraph = sg;
                query.destinyGraph = dg[2];
                
                return query;
          })(pos0, result0[2], result0[4]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[32] Load");
          }
          return result0;
        }
        
        function parse_Clear() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 5) === "CLEAR") {
            result0 = "CLEAR";
            pos += 5;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"CLEAR\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 5) === "clear") {
              result0 = "clear";
              pos += 5;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"clear\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              if (input.substr(pos, 6) === "SILENT") {
                result2 = "SILENT";
                pos += 6;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"SILENT\"");
                }
              }
              if (result2 === null) {
                if (input.substr(pos, 6) === "silent") {
                  result2 = "silent";
                  pos += 6;
                } else {
                  result2 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"silent\"");
                  }
                }
              }
              result2 = result2 !== null ? result2 : "";
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result4 = parse_GraphRefAll();
                  if (result4 !== null) {
                    result0 = [result0, result1, result2, result3, result4];
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, ref) {
                var query = {};
                query.kind = 'clear';
                query.token = 'executableunit'
                query.destinyGraph = ref;
                
                return query;
          })(pos0, result0[4]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[33] Clear");
          }
          return result0;
        }
        
        function parse_Drop() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 4) === "DROP") {
            result0 = "DROP";
            pos += 4;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"DROP\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 4) === "drop") {
              result0 = "drop";
              pos += 4;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"drop\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              if (input.substr(pos, 6) === "SILENT") {
                result2 = "SILENT";
                pos += 6;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"SILENT\"");
                }
              }
              if (result2 === null) {
                if (input.substr(pos, 6) === "silent") {
                  result2 = "silent";
                  pos += 6;
                } else {
                  result2 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"silent\"");
                  }
                }
              }
              result2 = result2 !== null ? result2 : "";
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result4 = parse_GraphRefAll();
                  if (result4 !== null) {
                    result0 = [result0, result1, result2, result3, result4];
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, ref) {
                var query = {};
                query.kind = 'drop';
                query.token = 'executableunit'
                query.destinyGraph = ref;
                
                return query;
          })(pos0, result0[4]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[34] Drop");
          }
          return result0;
        }
        
        function parse_Create() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 6) === "CREATE") {
            result0 = "CREATE";
            pos += 6;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"CREATE\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 6) === "create") {
              result0 = "create";
              pos += 6;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"create\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              if (input.substr(pos, 6) === "SILENT") {
                result2 = "SILENT";
                pos += 6;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"SILENT\"");
                }
              }
              if (result2 === null) {
                if (input.substr(pos, 6) === "silent") {
                  result2 = "silent";
                  pos += 6;
                } else {
                  result2 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"silent\"");
                  }
                }
              }
              result2 = result2 !== null ? result2 : "";
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result4 = parse_GraphRef();
                  if (result4 !== null) {
                    result0 = [result0, result1, result2, result3, result4];
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, ref) {
                var query = {};
                query.kind = 'create';
                query.token = 'executableunit'
                query.destinyGraph = ref;
                
                return query;
          })(pos0, result0[4]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[35] Create");
          }
          return result0;
        }
        
        function parse_InsertData() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 6) === "INSERT") {
            result0 = "INSERT";
            pos += 6;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"INSERT\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 6) === "insert") {
              result0 = "insert";
              pos += 6;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"insert\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              if (input.substr(pos, 4) === "DATA") {
                result2 = "DATA";
                pos += 4;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"DATA\"");
                }
              }
              if (result2 === null) {
                if (input.substr(pos, 4) === "data") {
                  result2 = "data";
                  pos += 4;
                } else {
                  result2 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"data\"");
                  }
                }
              }
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result4 = parse_QuadData();
                  if (result4 !== null) {
                    result0 = [result0, result1, result2, result3, result4];
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, qs) {
                var query = {};
                query.kind = 'insertdata';
                query.token = 'executableunit'
                query.quads = qs;
          
                return query;
          })(pos0, result0[4]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[36] InsertData");
          }
          return result0;
        }
        
        function parse_DeleteData() {
          var result0, result1, result2, result3;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 6) === "DELETE") {
            result0 = "DELETE";
            pos += 6;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"DELETE\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 6) === "delete") {
              result0 = "delete";
              pos += 6;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"delete\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              if (input.substr(pos, 4) === "DATA") {
                result2 = "DATA";
                pos += 4;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"DATA\"");
                }
              }
              if (result2 === null) {
                if (input.substr(pos, 4) === "data") {
                  result2 = "data";
                  pos += 4;
                } else {
                  result2 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"data\"");
                  }
                }
              }
              if (result2 !== null) {
                result3 = parse_QuadData();
                if (result3 !== null) {
                  result0 = [result0, result1, result2, result3];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, qs) {
                var query = {};
                query.kind = 'deletedata';
                query.token = 'executableunit'
                query.quads = qs;
          
                return query;
          })(pos0, result0[3]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[37] DeleteData");
          }
          return result0;
        }
        
        function parse_DeleteWhere() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 6) === "DELETE") {
            result0 = "DELETE";
            pos += 6;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"DELETE\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 6) === "delete") {
              result0 = "delete";
              pos += 6;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"delete\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              if (input.substr(pos, 5) === "WHERE") {
                result2 = "WHERE";
                pos += 5;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"WHERE\"");
                }
              }
              if (result2 === null) {
                if (input.substr(pos, 5) === "where") {
                  result2 = "where";
                  pos += 5;
                } else {
                  result2 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"where\"");
                  }
                }
              }
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result4 = parse_GroupGraphPattern();
                  if (result4 !== null) {
                    result0 = [result0, result1, result2, result3, result4];
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, p) {
                var query = {};
                query.kind = 'modify';
                query.pattern = p;
                query.with = null;
                query.using = null;
          
                var quads = [];
          
          
                var patternsCollection = p.patterns[0];
                if(patternsCollection.triplesContext == null && patternsCollection.patterns!=null) {
                    patternsCollection = patternsCollection.patterns[0].triplesContext;
                } else {
                    patternsCollection = patternsCollection.triplesContext;
                }
          
                for(var i=0; i<patternsCollection.length; i++) {
                    var quad = {};
                    var contextQuad = patternsCollection[i];
          
                    quad['subject'] = contextQuad['subject'];
                    quad['predicate'] = contextQuad['predicate'];
                    quad['object'] = contextQuad['object'];
                    quad['graph'] = contextQuad['graph'];
          
                    quads.push(quad);
                }
          
                query.delete = quads;
          
                return query;
          })(pos0, result0[4]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[38] DeleteWhere");
          }
          return result0;
        }
        
        function parse_Modify() {
          var result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          pos2 = pos;
          if (input.substr(pos, 4) === "WITH") {
            result0 = "WITH";
            pos += 4;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"WITH\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 4) === "with") {
              result0 = "with";
              pos += 4;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"with\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = parse_IRIref();
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos2;
              }
            } else {
              result0 = null;
              pos = pos2;
            }
          } else {
            result0 = null;
            pos = pos2;
          }
          result0 = result0 !== null ? result0 : "";
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              pos2 = pos;
              result2 = parse_DeleteClause();
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result4 = parse_InsertClause();
                  result4 = result4 !== null ? result4 : "";
                  if (result4 !== null) {
                    result2 = [result2, result3, result4];
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
              if (result2 === null) {
                result2 = parse_InsertClause();
              }
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_UsingClause();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_UsingClause();
                  }
                  if (result4 !== null) {
                    result5 = [];
                    result6 = parse_WS();
                    while (result6 !== null) {
                      result5.push(result6);
                      result6 = parse_WS();
                    }
                    if (result5 !== null) {
                      if (input.substr(pos, 5) === "WHERE") {
                        result6 = "WHERE";
                        pos += 5;
                      } else {
                        result6 = null;
                        if (reportFailures === 0) {
                          matchFailed("\"WHERE\"");
                        }
                      }
                      if (result6 === null) {
                        if (input.substr(pos, 5) === "where") {
                          result6 = "where";
                          pos += 5;
                        } else {
                          result6 = null;
                          if (reportFailures === 0) {
                            matchFailed("\"where\"");
                          }
                        }
                      }
                      if (result6 !== null) {
                        result7 = [];
                        result8 = parse_WS();
                        while (result8 !== null) {
                          result7.push(result8);
                          result8 = parse_WS();
                        }
                        if (result7 !== null) {
                          result8 = parse_GroupGraphPattern();
                          if (result8 !== null) {
                            result9 = [];
                            result10 = parse_WS();
                            while (result10 !== null) {
                              result9.push(result10);
                              result10 = parse_WS();
                            }
                            if (result9 !== null) {
                              result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9];
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, wg, dic, uc, p) {
                var query = {};
                query.kind = 'modify';
          
                if(wg != "") {
                    query.with = wg[2];
                } else {
                    query.with = null;
                }
          
          
                if(dic.length === 3 && dic[2] === '') {
                    query.delete = dic[0];
                    query.insert = null;
                } else if(dic.length === 3 && dic[0].length != null && dic[1].length != null && dic[2].length != null) {
                    query.delete = dic[0];
                    query.insert = dic[2];
                } else  {
                    query.insert = dic;
                    query.delete = null;
                }
          
                if(uc != '') {
                    query.using = uc;
                }
          
                query.pattern = p;
          
                return query;
          })(pos0, result0[0], result0[2], result0[4], result0[8]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[39] Modify");
          }
          return result0;
        }
        
        function parse_DeleteClause() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 6) === "DELETE") {
            result0 = "DELETE";
            pos += 6;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"DELETE\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 6) === "delete") {
              result0 = "delete";
              pos += 6;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"delete\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = parse_QuadPattern();
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, q) {
                return q;
          })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[40] DeleteClause");
          }
          return result0;
        }
        
        function parse_InsertClause() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 6) === "INSERT") {
            result0 = "INSERT";
            pos += 6;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"INSERT\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 6) === "insert") {
              result0 = "insert";
              pos += 6;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"insert\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = parse_QuadPattern();
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, q) {
            return q;
          })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[41] InsertClause");
          }
          return result0;
        }
        
        function parse_UsingClause() {
          var result0, result1, result2, result3, result4, result5;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            if (input.substr(pos, 5) === "USING") {
              result1 = "USING";
              pos += 5;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("\"USING\"");
              }
            }
            if (result1 === null) {
              if (input.substr(pos, 5) === "using") {
                result1 = "using";
                pos += 5;
              } else {
                result1 = null;
                if (reportFailures === 0) {
                  matchFailed("\"using\"");
                }
              }
            }
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                result3 = parse_IRIref();
                if (result3 === null) {
                  pos2 = pos;
                  if (input.substr(pos, 5) === "NAMED") {
                    result3 = "NAMED";
                    pos += 5;
                  } else {
                    result3 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"NAMED\"");
                    }
                  }
                  if (result3 === null) {
                    if (input.substr(pos, 5) === "named") {
                      result3 = "named";
                      pos += 5;
                    } else {
                      result3 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"named\"");
                      }
                    }
                  }
                  if (result3 !== null) {
                    result4 = [];
                    result5 = parse_WS();
                    while (result5 !== null) {
                      result4.push(result5);
                      result5 = parse_WS();
                    }
                    if (result4 !== null) {
                      result5 = parse_IRIref();
                      if (result5 !== null) {
                        result3 = [result3, result4, result5];
                      } else {
                        result3 = null;
                        pos = pos2;
                      }
                    } else {
                      result3 = null;
                      pos = pos2;
                    }
                  } else {
                    result3 = null;
                    pos = pos2;
                  }
                }
                if (result3 !== null) {
                  result0 = [result0, result1, result2, result3];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, g) {
                if(g.length!=null) {
                    return {kind: 'named', uri: g[2]};
                } else {
                    return {kind: 'default', uri: g};
                }
          })(pos0, result0[3]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[42] UsingClause");
          }
          return result0;
        }
        
        function parse_GraphRef() {
          var result0, result1, result2;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 5) === "GRAPH") {
            result0 = "GRAPH";
            pos += 5;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"GRAPH\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 5) === "graph") {
              result0 = "graph";
              pos += 5;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"graph\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = parse_IRIref();
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, i) {
                return i;
          })(pos0, result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[43] GraphRef");
          }
          return result0;
        }
        
        function parse_GraphRefAll() {
          var result0;
          var pos0;
          
          reportFailures++;
          pos0 = pos;
          result0 = parse_GraphRef();
          if (result0 !== null) {
            result0 = (function(offset, g) {
                return g;
          })(pos0, result0);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            if (input.substr(pos, 7) === "DEFAULT") {
              result0 = "DEFAULT";
              pos += 7;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"DEFAULT\"");
              }
            }
            if (result0 === null) {
              if (input.substr(pos, 7) === "default") {
                result0 = "default";
                pos += 7;
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("\"default\"");
                }
              }
            }
            if (result0 !== null) {
              result0 = (function(offset) {
                  return 'default';
            })(pos0);
            }
            if (result0 === null) {
              pos = pos0;
            }
            if (result0 === null) {
              pos0 = pos;
              if (input.substr(pos, 5) === "NAMED") {
                result0 = "NAMED";
                pos += 5;
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("\"NAMED\"");
                }
              }
              if (result0 === null) {
                if (input.substr(pos, 5) === "named") {
                  result0 = "named";
                  pos += 5;
                } else {
                  result0 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"named\"");
                  }
                }
              }
              if (result0 !== null) {
                result0 = (function(offset) {
                    return 'named';
              })(pos0);
              }
              if (result0 === null) {
                pos = pos0;
              }
              if (result0 === null) {
                pos0 = pos;
                if (input.substr(pos, 3) === "ALL") {
                  result0 = "ALL";
                  pos += 3;
                } else {
                  result0 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"ALL\"");
                  }
                }
                if (result0 === null) {
                  if (input.substr(pos, 3) === "all") {
                    result0 = "all";
                    pos += 3;
                  } else {
                    result0 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"all\"");
                    }
                  }
                }
                if (result0 !== null) {
                  result0 = (function(offset) {
                      return 'all';
                })(pos0);
                }
                if (result0 === null) {
                  pos = pos0;
                }
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[44] GraphRefAll");
          }
          return result0;
        }
        
        function parse_QuadPattern() {
          var result0, result1, result2, result3, result4, result5, result6, result7;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            if (input.charCodeAt(pos) === 123) {
              result1 = "{";
              pos++;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("\"{\"");
              }
            }
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                result3 = parse_Quads();
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    if (input.charCodeAt(pos) === 125) {
                      result5 = "}";
                      pos++;
                    } else {
                      result5 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"}\"");
                      }
                    }
                    if (result5 !== null) {
                      result6 = [];
                      result7 = parse_WS();
                      while (result7 !== null) {
                        result6.push(result7);
                        result7 = parse_WS();
                      }
                      if (result6 !== null) {
                        result0 = [result0, result1, result2, result3, result4, result5, result6];
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, qs) {
                return qs.quadsContext;
          })(pos0, result0[3]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[45] QuadPattern");
          }
          return result0;
        }
        
        function parse_QuadData() {
          var result0, result1, result2, result3, result4, result5, result6, result7;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            if (input.charCodeAt(pos) === 123) {
              result1 = "{";
              pos++;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("\"{\"");
              }
            }
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                result3 = parse_Quads();
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    if (input.charCodeAt(pos) === 125) {
                      result5 = "}";
                      pos++;
                    } else {
                      result5 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"}\"");
                      }
                    }
                    if (result5 !== null) {
                      result6 = [];
                      result7 = parse_WS();
                      while (result7 !== null) {
                        result6.push(result7);
                        result7 = parse_WS();
                      }
                      if (result6 !== null) {
                        result0 = [result0, result1, result2, result3, result4, result5, result6];
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, qs) {
                return qs.quadsContext;
          })(pos0, result0[3]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[46] QuadData");
          }
          return result0;
        }
        
        function parse_Quads() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_TriplesTemplate();
          result0 = result0 !== null ? result0 : "";
          if (result0 !== null) {
            result1 = [];
            pos2 = pos;
            result2 = parse_QuadsNotTriples();
            if (result2 !== null) {
              if (input.charCodeAt(pos) === 46) {
                result3 = ".";
                pos++;
              } else {
                result3 = null;
                if (reportFailures === 0) {
                  matchFailed("\".\"");
                }
              }
              result3 = result3 !== null ? result3 : "";
              if (result3 !== null) {
                result4 = parse_TriplesTemplate();
                result4 = result4 !== null ? result4 : "";
                if (result4 !== null) {
                  result2 = [result2, result3, result4];
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
            } else {
              result2 = null;
              pos = pos2;
            }
            while (result2 !== null) {
              result1.push(result2);
              pos2 = pos;
              result2 = parse_QuadsNotTriples();
              if (result2 !== null) {
                if (input.charCodeAt(pos) === 46) {
                  result3 = ".";
                  pos++;
                } else {
                  result3 = null;
                  if (reportFailures === 0) {
                    matchFailed("\".\"");
                  }
                }
                result3 = result3 !== null ? result3 : "";
                if (result3 !== null) {
                  result4 = parse_TriplesTemplate();
                  result4 = result4 !== null ? result4 : "";
                  if (result4 !== null) {
                    result2 = [result2, result3, result4];
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
            }
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, ts, qs) {
                var quads = []
                if(ts.triplesContext != null && ts.triplesContext != null) {
                  for(var i=0; i<ts.triplesContext.length; i++) {
                      var triple = ts.triplesContext[i]
                      triple.graph = null;
                      quads.push(triple)
                  }
                }
          
                if(qs && qs.length>0 && qs[0].length > 0) {
                    quads = quads.concat(qs[0][0].quadsContext);
          
                    if( qs[0][2] != null && qs[0][2].triplesContext != null) {
                      for(var i=0; i<qs[0][2].triplesContext.length; i++) {
                          var triple = qs[0][2].triplesContext[i]
                          triple.graph = null;
                          quads.push(triple)
                      }
                    }
                }
          
                return {token:'quads',
                        quadsContext: quads}
          })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[47] Quads");
          }
          return result0;
        }
        
        function parse_QuadsNotTriples() {
          var result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            if (input.substr(pos, 5) === "GRAPH") {
              result1 = "GRAPH";
              pos += 5;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("\"GRAPH\"");
              }
            }
            if (result1 === null) {
              if (input.substr(pos, 5) === "graph") {
                result1 = "graph";
                pos += 5;
              } else {
                result1 = null;
                if (reportFailures === 0) {
                  matchFailed("\"graph\"");
                }
              }
            }
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                result3 = parse_VarOrIRIref();
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    if (input.charCodeAt(pos) === 123) {
                      result5 = "{";
                      pos++;
                    } else {
                      result5 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"{\"");
                      }
                    }
                    if (result5 !== null) {
                      result6 = [];
                      result7 = parse_WS();
                      while (result7 !== null) {
                        result6.push(result7);
                        result7 = parse_WS();
                      }
                      if (result6 !== null) {
                        result7 = parse_TriplesTemplate();
                        result7 = result7 !== null ? result7 : "";
                        if (result7 !== null) {
                          result8 = [];
                          result9 = parse_WS();
                          while (result9 !== null) {
                            result8.push(result9);
                            result9 = parse_WS();
                          }
                          if (result8 !== null) {
                            if (input.charCodeAt(pos) === 125) {
                              result9 = "}";
                              pos++;
                            } else {
                              result9 = null;
                              if (reportFailures === 0) {
                                matchFailed("\"}\"");
                              }
                            }
                            if (result9 !== null) {
                              result10 = [];
                              result11 = parse_WS();
                              while (result11 !== null) {
                                result10.push(result11);
                                result11 = parse_WS();
                              }
                              if (result10 !== null) {
                                result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10];
                              } else {
                                result0 = null;
                                pos = pos1;
                              }
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, g, ts) {
                var quads = []
                for(var i=0; i<ts.triplesContext.length; i++) {
                    var triple = ts.triplesContext[i]
                    triple.graph = g;
                    quads.push(triple)
                }
          
                return {token:'quadsnottriples',
                        quadsContext: quads}
          })(pos0, result0[3], result0[7]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[48] QuadsNotTriples");
          }
          return result0;
        }
        
        function parse_TriplesTemplate() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_TriplesSameSubject();
          if (result0 !== null) {
            pos2 = pos;
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              if (input.charCodeAt(pos) === 46) {
                result2 = ".";
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\".\"");
                }
              }
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result4 = parse_TriplesTemplate();
                  result4 = result4 !== null ? result4 : "";
                  if (result4 !== null) {
                    result1 = [result1, result2, result3, result4];
                  } else {
                    result1 = null;
                    pos = pos2;
                  }
                } else {
                  result1 = null;
                  pos = pos2;
                }
              } else {
                result1 = null;
                pos = pos2;
              }
            } else {
              result1 = null;
              pos = pos2;
            }
            result1 = result1 !== null ? result1 : "";
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, b, bs) {
               var triples = b.triplesContext;
               var toTest = null;
                if(typeof(bs) === 'object') {
                      if(bs.length != null) {
                            if(bs[3].triplesContext!=null) {
                               triples = triples.concat(bs[3].triplesContext);
                        }
                     }
                }
          
               return {token:'triplestemplate',
                       triplesContext: triples}
          })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[49] TriplesTemplate");
          }
          return result0;
        }
        
        function parse_GroupGraphPattern() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.charCodeAt(pos) === 123) {
            result0 = "{";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"{\"");
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = parse_SubSelect();
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  if (input.charCodeAt(pos) === 125) {
                    result4 = "}";
                    pos++;
                  } else {
                    result4 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"}\"");
                    }
                  }
                  if (result4 !== null) {
                    result0 = [result0, result1, result2, result3, result4];
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, p) {
                return p;
          })(pos0, result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            pos1 = pos;
            if (input.charCodeAt(pos) === 123) {
              result0 = "{";
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"{\"");
              }
            }
            if (result0 !== null) {
              result1 = [];
              result2 = parse_WS();
              while (result2 !== null) {
                result1.push(result2);
                result2 = parse_WS();
              }
              if (result1 !== null) {
                result2 = parse_GroupGraphPatternSub();
                if (result2 !== null) {
                  result3 = [];
                  result4 = parse_WS();
                  while (result4 !== null) {
                    result3.push(result4);
                    result4 = parse_WS();
                  }
                  if (result3 !== null) {
                    if (input.charCodeAt(pos) === 125) {
                      result4 = "}";
                      pos++;
                    } else {
                      result4 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"}\"");
                      }
                    }
                    if (result4 !== null) {
                      result0 = [result0, result1, result2, result3, result4];
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
            if (result0 !== null) {
              result0 = (function(offset, p) {
                  return p;
            })(pos0, result0[2]);
            }
            if (result0 === null) {
              pos = pos0;
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[50] GroupGraphPattern");
          }
          return result0;
        }
        
        function parse_GroupGraphPatternSub() {
          var result0, result1, result2, result3, result4, result5, result6, result7;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_TriplesBlock();
          result0 = result0 !== null ? result0 : "";
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = [];
              pos2 = pos;
              result3 = parse_GraphPatternNotTriples();
              if (result3 !== null) {
                result4 = [];
                result5 = parse_WS();
                while (result5 !== null) {
                  result4.push(result5);
                  result5 = parse_WS();
                }
                if (result4 !== null) {
                  if (input.charCodeAt(pos) === 46) {
                    result5 = ".";
                    pos++;
                  } else {
                    result5 = null;
                    if (reportFailures === 0) {
                      matchFailed("\".\"");
                    }
                  }
                  result5 = result5 !== null ? result5 : "";
                  if (result5 !== null) {
                    result6 = [];
                    result7 = parse_WS();
                    while (result7 !== null) {
                      result6.push(result7);
                      result7 = parse_WS();
                    }
                    if (result6 !== null) {
                      result7 = parse_TriplesBlock();
                      result7 = result7 !== null ? result7 : "";
                      if (result7 !== null) {
                        result3 = [result3, result4, result5, result6, result7];
                      } else {
                        result3 = null;
                        pos = pos2;
                      }
                    } else {
                      result3 = null;
                      pos = pos2;
                    }
                  } else {
                    result3 = null;
                    pos = pos2;
                  }
                } else {
                  result3 = null;
                  pos = pos2;
                }
              } else {
                result3 = null;
                pos = pos2;
              }
              while (result3 !== null) {
                result2.push(result3);
                pos2 = pos;
                result3 = parse_GraphPatternNotTriples();
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    if (input.charCodeAt(pos) === 46) {
                      result5 = ".";
                      pos++;
                    } else {
                      result5 = null;
                      if (reportFailures === 0) {
                        matchFailed("\".\"");
                      }
                    }
                    result5 = result5 !== null ? result5 : "";
                    if (result5 !== null) {
                      result6 = [];
                      result7 = parse_WS();
                      while (result7 !== null) {
                        result6.push(result7);
                        result7 = parse_WS();
                      }
                      if (result6 !== null) {
                        result7 = parse_TriplesBlock();
                        result7 = result7 !== null ? result7 : "";
                        if (result7 !== null) {
                          result3 = [result3, result4, result5, result6, result7];
                        } else {
                          result3 = null;
                          pos = pos2;
                        }
                      } else {
                        result3 = null;
                        pos = pos2;
                      }
                    } else {
                      result3 = null;
                      pos = pos2;
                    }
                  } else {
                    result3 = null;
                    pos = pos2;
                  }
                } else {
                  result3 = null;
                  pos = pos2;
                }
              }
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, tb, tbs) {
                var subpatterns = [];
                if(tb != null && tb != []) {
                    subpatterns.push(tb);
                }
          
                for(var i=0; i<tbs.length; i++) {
                    for(var j=0; j< tbs[i].length; j++) {
                        if(tbs[i][j].token != null) {
                            subpatterns.push(tbs[i][j]);
                        }
                    }
                }
          
                var compactedSubpatterns = [];
          
                var currentBasicGraphPatterns = [];
                var currentFilters = [];
          
                for(var i=0; i<subpatterns.length; i++) {
                    if(subpatterns[i].token!='triplespattern' && subpatterns[i].token != 'filter') {
                        if(currentBasicGraphPatterns.length != 0 || currentFilters.length != 0) {
                            var triplesContext = [];
                            for(var j=0; j<currentBasicGraphPatterns.length; j++) {
                                triplesContext = triplesContext.concat(currentBasicGraphPatterns[j].triplesContext);
                            }
                            if(triplesContext.length > 0) {  
                                compactedSubpatterns.push({token: 'basicgraphpattern',
                                                           triplesContext: triplesContext});
                            }
                            currentBasicGraphPatterns = [];
                        }
                        compactedSubpatterns.push(subpatterns[i]);
                    } else {
                        if(subpatterns[i].token === 'triplespattern') {
                            currentBasicGraphPatterns.push(subpatterns[i]);
                        } else {
                            currentFilters.push(subpatterns[i]);
                        }
                    }
                }
          
                if(currentBasicGraphPatterns.length != 0 || currentFilters.length != 0) {
                    var triplesContext = [];
                    for(var j=0; j<currentBasicGraphPatterns.length; j++) {
                        triplesContext = triplesContext.concat(currentBasicGraphPatterns[j].triplesContext);
                    }
                    if(triplesContext.length > 0) {
                      compactedSubpatterns.push({token: 'basicgraphpattern',
                                                 triplesContext: triplesContext});
                    }
                }
          
          //      if(compactedSubpatterns.length == 1) {
          //          compactedSubpatterns[0].filters = currentFilters;
          //          return compactedSubpatterns[0];
          //      } else  {
                    return { token: 'groupgraphpattern',
                             patterns: compactedSubpatterns,
                             filters: currentFilters }
          //      }
          })(pos0, result0[0], result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[51] GroupGraphPatternSub");
          }
          return result0;
        }
        
        function parse_TriplesBlock() {
          var result0, result1, result2, result3;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_TriplesSameSubjectPath();
          if (result0 !== null) {
            pos2 = pos;
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              if (input.charCodeAt(pos) === 46) {
                result2 = ".";
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\".\"");
                }
              }
              if (result2 !== null) {
                result3 = parse_TriplesBlock();
                result3 = result3 !== null ? result3 : "";
                if (result3 !== null) {
                  result1 = [result1, result2, result3];
                } else {
                  result1 = null;
                  pos = pos2;
                }
              } else {
                result1 = null;
                pos = pos2;
              }
            } else {
              result1 = null;
              pos = pos2;
            }
            result1 = result1 !== null ? result1 : "";
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, b, bs) {
               var triples = b.triplesContext;
               var toTest = null;
                if(typeof(bs) === 'object') {
                      if(bs.length != null) {
                            if(bs[2].triplesContext!=null) {
                               triples = triples.concat(bs[2].triplesContext);
                        }
                     }
                }
          
               return {token:'triplespattern',
                       triplesContext: triples}
          })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[54] TriplesBlock");
          }
          return result0;
        }
        
        function parse_GraphPatternNotTriples() {
          var result0;
          
          reportFailures++;
          result0 = parse_GroupOrUnionGraphPattern();
          if (result0 === null) {
            result0 = parse_OptionalGraphPattern();
            if (result0 === null) {
              result0 = parse_MinusGraphPattern();
              if (result0 === null) {
                result0 = parse_GraphGraphPattern();
                if (result0 === null) {
                  result0 = parse_ServiceGraphPattern();
                  if (result0 === null) {
                    result0 = parse_Filter();
                  }
                }
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[53] GraphPatternNotTriples");
          }
          return result0;
        }
        
        function parse_OptionalGraphPattern() {
          var result0, result1, result2, result3;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            if (input.substr(pos, 8) === "OPTIONAL") {
              result1 = "OPTIONAL";
              pos += 8;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("\"OPTIONAL\"");
              }
            }
            if (result1 === null) {
              if (input.substr(pos, 8) === "optional") {
                result1 = "optional";
                pos += 8;
              } else {
                result1 = null;
                if (reportFailures === 0) {
                  matchFailed("\"optional\"");
                }
              }
            }
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                result3 = parse_GroupGraphPattern();
                if (result3 !== null) {
                  result0 = [result0, result1, result2, result3];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, v) {
                return { token: 'optionalgraphpattern',
                         value: v }
          })(pos0, result0[3]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[54] OptionalGraphPattern");
          }
          return result0;
        }
        
        function parse_GraphGraphPattern() {
          var result0, result1, result2, result3, result4, result5;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            if (input.substr(pos, 5) === "GRAPH") {
              result1 = "GRAPH";
              pos += 5;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("\"GRAPH\"");
              }
            }
            if (result1 === null) {
              if (input.substr(pos, 5) === "graph") {
                result1 = "graph";
                pos += 5;
              } else {
                result1 = null;
                if (reportFailures === 0) {
                  matchFailed("\"graph\"");
                }
              }
            }
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                result3 = parse_VarOrIRIref();
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    result5 = parse_GroupGraphPattern();
                    if (result5 !== null) {
                      result0 = [result0, result1, result2, result3, result4, result5];
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, g, gg) {
                for(var i=0; i<gg.patterns.length; i++) {
                  var quads = []
                  var ts = gg.patterns[i];
                  for(var j=0; j<ts.triplesContext.length; j++) {
                      var triple = ts.triplesContext[j]
                      triple.graph = g;
                  }
                }
          
                gg.token = 'groupgraphpattern'
                return gg;
          })(pos0, result0[3], result0[5]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[55] GraphGraphPattern");
          }
          return result0;
        }
        
        function parse_ServiceGraphPattern() {
          var result0, result1, result2;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 7) === "SERVICE") {
            result0 = "SERVICE";
            pos += 7;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"SERVICE\"");
            }
          }
          if (result0 !== null) {
            result1 = parse_VarOrIRIref();
            if (result1 !== null) {
              result2 = parse_GroupGraphPattern();
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, v, ts) {
                return {token: 'servicegraphpattern',
                        status: 'todo',
                        value: [v,ts] }
          })(pos0, result0[1], result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[56] ServiceGraphPattern");
          }
          return result0;
        }
        
        function parse_MinusGraphPattern() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 5) === "MINUS") {
            result0 = "MINUS";
            pos += 5;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"MINUS\"");
            }
          }
          if (result0 !== null) {
            result1 = parse_GroupGraphPattern();
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, ts) {
                return {token: 'minusgraphpattern',
                        status: 'todo',
                        value: ts}
          })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[57] MinusGraphPattern");
          }
          return result0;
        }
        
        function parse_GroupOrUnionGraphPattern() {
          var result0, result1, result2, result3, result4, result5;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_GroupGraphPattern();
          if (result0 !== null) {
            result1 = [];
            pos2 = pos;
            result2 = [];
            result3 = parse_WS();
            while (result3 !== null) {
              result2.push(result3);
              result3 = parse_WS();
            }
            if (result2 !== null) {
              if (input.substr(pos, 5) === "UNION") {
                result3 = "UNION";
                pos += 5;
              } else {
                result3 = null;
                if (reportFailures === 0) {
                  matchFailed("\"UNION\"");
                }
              }
              if (result3 === null) {
                if (input.substr(pos, 5) === "union") {
                  result3 = "union";
                  pos += 5;
                } else {
                  result3 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"union\"");
                  }
                }
              }
              if (result3 !== null) {
                result4 = [];
                result5 = parse_WS();
                while (result5 !== null) {
                  result4.push(result5);
                  result5 = parse_WS();
                }
                if (result4 !== null) {
                  result5 = parse_GroupGraphPattern();
                  if (result5 !== null) {
                    result2 = [result2, result3, result4, result5];
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
            } else {
              result2 = null;
              pos = pos2;
            }
            while (result2 !== null) {
              result1.push(result2);
              pos2 = pos;
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                if (input.substr(pos, 5) === "UNION") {
                  result3 = "UNION";
                  pos += 5;
                } else {
                  result3 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"UNION\"");
                  }
                }
                if (result3 === null) {
                  if (input.substr(pos, 5) === "union") {
                    result3 = "union";
                    pos += 5;
                  } else {
                    result3 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"union\"");
                    }
                  }
                }
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    result5 = parse_GroupGraphPattern();
                    if (result5 !== null) {
                      result2 = [result2, result3, result4, result5];
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
            }
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, a, b) {
                if(b.length === 0) {
                    return a;
                } else {
          
                    var lastToken = {token: 'graphunionpattern',
                                     value: [a]};
          
                    for(var i=0; i<b.length; i++) {
                        if(i==b.length-1) {
                            lastToken.value.push(b[i][3]);
                        } else {
                            lastToken.value.push(b[i][3]);
                            var newToken = {token: 'graphunionpattern',
                                            value: [lastToken]}
          
                            lastToken = newToken;
                        }
                    }
          
                    return lastToken;
          
                }
          })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[58] GroupOrUnionGraphPattern");
          }
          return result0;
        }
        
        function parse_Filter() {
          var result0, result1, result2, result3;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            if (input.substr(pos, 6) === "FILTER") {
              result1 = "FILTER";
              pos += 6;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("\"FILTER\"");
              }
            }
            if (result1 === null) {
              if (input.substr(pos, 6) === "filter") {
                result1 = "filter";
                pos += 6;
              } else {
                result1 = null;
                if (reportFailures === 0) {
                  matchFailed("\"filter\"");
                }
              }
            }
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                result3 = parse_Constraint();
                if (result3 !== null) {
                  result0 = [result0, result1, result2, result3];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, c) {
                return {token: 'filter',
                        value: c}
          })(pos0, result0[3]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[59] Filter");
          }
          return result0;
        }
        
        function parse_Constraint() {
          var result0;
          
          reportFailures++;
          result0 = parse_BrackettedExpression();
          if (result0 === null) {
            result0 = parse_BuiltInCall();
            if (result0 === null) {
              result0 = parse_FunctionCall();
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[60] Constraint");
          }
          return result0;
        }
        
        function parse_FunctionCall() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_IRIref();
          if (result0 !== null) {
            result1 = parse_ArgList();
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, i, args) {
                var fcall = {};
                fcall.token = "expression";
                fcall.expressionType = 'irireforfunction'
                fcall.iriref = i;
                fcall.args = args.value;
          
                return fcall;
          })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[61] FunctionCall");
          }
          return result0;
        }
        
        function parse_ArgList() {
          var result0, result1, result2, result3, result4, result5;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          result0 = parse_NIL();
          if (result0 !== null) {
            result0 = (function(offset) {
                var args = {};
                args.token = 'args';
                args.value = [];
                return args;
          })(pos0);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            pos1 = pos;
            if (input.charCodeAt(pos) === 40) {
              result0 = "(";
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"(\"");
              }
            }
            if (result0 !== null) {
              if (input.substr(pos, 8) === "DISTINCT") {
                result1 = "DISTINCT";
                pos += 8;
              } else {
                result1 = null;
                if (reportFailures === 0) {
                  matchFailed("\"DISTINCT\"");
                }
              }
              if (result1 === null) {
                if (input.substr(pos, 8) === "distinct") {
                  result1 = "distinct";
                  pos += 8;
                } else {
                  result1 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"distinct\"");
                  }
                }
              }
              result1 = result1 !== null ? result1 : "";
              if (result1 !== null) {
                result2 = parse_ConditionalOrExpression();
                if (result2 !== null) {
                  result3 = [];
                  pos2 = pos;
                  if (input.charCodeAt(pos) === 44) {
                    result4 = ",";
                    pos++;
                  } else {
                    result4 = null;
                    if (reportFailures === 0) {
                      matchFailed("\",\"");
                    }
                  }
                  if (result4 !== null) {
                    result5 = parse_ConditionalOrExpression();
                    if (result5 !== null) {
                      result4 = [result4, result5];
                    } else {
                      result4 = null;
                      pos = pos2;
                    }
                  } else {
                    result4 = null;
                    pos = pos2;
                  }
                  while (result4 !== null) {
                    result3.push(result4);
                    pos2 = pos;
                    if (input.charCodeAt(pos) === 44) {
                      result4 = ",";
                      pos++;
                    } else {
                      result4 = null;
                      if (reportFailures === 0) {
                        matchFailed("\",\"");
                      }
                    }
                    if (result4 !== null) {
                      result5 = parse_ConditionalOrExpression();
                      if (result5 !== null) {
                        result4 = [result4, result5];
                      } else {
                        result4 = null;
                        pos = pos2;
                      }
                    } else {
                      result4 = null;
                      pos = pos2;
                    }
                  }
                  if (result3 !== null) {
                    if (input.charCodeAt(pos) === 41) {
                      result4 = ")";
                      pos++;
                    } else {
                      result4 = null;
                      if (reportFailures === 0) {
                        matchFailed("\")\"");
                      }
                    }
                    if (result4 !== null) {
                      result0 = [result0, result1, result2, result3, result4];
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
            if (result0 !== null) {
              result0 = (function(offset, d, e, es) {
                  var cleanEx = [];
            
                  for(var i=0; i<es.length; i++) {
                      cleanEx.push(es[i][1]);
                  }
                  var args = {};
                  args.token = 'args';
                  args.value = [e].concat(cleanEx);
            
                  if(d!=null && d.toUpperCase()==="DISTINCT") {
                      args.distinct = true;
                  } else {
                      args.distinct = false;
                  }
            
                  return args;
            })(pos0, result0[1], result0[2], result0[3]);
            }
            if (result0 === null) {
              pos = pos0;
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[62] ArgList");
          }
          return result0;
        }
        
        function parse_ExpressionList() {
          var result0, result1, result2, result3, result4, result5, result6;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          result0 = parse_NIL();
          if (result0 !== null) {
            result0 = (function(offset) {
                var args = {};
                args.token = 'args';
                args.value = [];
                return args;
          })(pos0);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            pos1 = pos;
            if (input.charCodeAt(pos) === 40) {
              result0 = "(";
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"(\"");
              }
            }
            if (result0 !== null) {
              result1 = parse_ConditionalOrExpression();
              if (result1 !== null) {
                result2 = [];
                pos2 = pos;
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  if (input.charCodeAt(pos) === 44) {
                    result4 = ",";
                    pos++;
                  } else {
                    result4 = null;
                    if (reportFailures === 0) {
                      matchFailed("\",\"");
                    }
                  }
                  if (result4 !== null) {
                    result5 = [];
                    result6 = parse_WS();
                    while (result6 !== null) {
                      result5.push(result6);
                      result6 = parse_WS();
                    }
                    if (result5 !== null) {
                      result6 = parse_ConditionalOrExpression();
                      if (result6 !== null) {
                        result3 = [result3, result4, result5, result6];
                      } else {
                        result3 = null;
                        pos = pos2;
                      }
                    } else {
                      result3 = null;
                      pos = pos2;
                    }
                  } else {
                    result3 = null;
                    pos = pos2;
                  }
                } else {
                  result3 = null;
                  pos = pos2;
                }
                while (result3 !== null) {
                  result2.push(result3);
                  pos2 = pos;
                  result3 = [];
                  result4 = parse_WS();
                  while (result4 !== null) {
                    result3.push(result4);
                    result4 = parse_WS();
                  }
                  if (result3 !== null) {
                    if (input.charCodeAt(pos) === 44) {
                      result4 = ",";
                      pos++;
                    } else {
                      result4 = null;
                      if (reportFailures === 0) {
                        matchFailed("\",\"");
                      }
                    }
                    if (result4 !== null) {
                      result5 = [];
                      result6 = parse_WS();
                      while (result6 !== null) {
                        result5.push(result6);
                        result6 = parse_WS();
                      }
                      if (result5 !== null) {
                        result6 = parse_ConditionalOrExpression();
                        if (result6 !== null) {
                          result3 = [result3, result4, result5, result6];
                        } else {
                          result3 = null;
                          pos = pos2;
                        }
                      } else {
                        result3 = null;
                        pos = pos2;
                      }
                    } else {
                      result3 = null;
                      pos = pos2;
                    }
                  } else {
                    result3 = null;
                    pos = pos2;
                  }
                }
                if (result2 !== null) {
                  if (input.charCodeAt(pos) === 41) {
                    result3 = ")";
                    pos++;
                  } else {
                    result3 = null;
                    if (reportFailures === 0) {
                      matchFailed("\")\"");
                    }
                  }
                  if (result3 !== null) {
                    result0 = [result0, result1, result2, result3];
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
            if (result0 !== null) {
              result0 = (function(offset, e, es) {
                  var cleanEx = [];
            
                  for(var i=0; i<es.length; i++) {
                      cleanEx.push(es[i][3]);
                  }
                  var args = {};
                  args.token = 'args';
                  args.value = [e].concat(cleanEx);
            
                  return args;
            })(pos0, result0[1], result0[2]);
            }
            if (result0 === null) {
              pos = pos0;
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[63] ExpressionList");
          }
          return result0;
        }
        
        function parse_ConstructTemplate() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.charCodeAt(pos) === 123) {
            result0 = "{";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"{\"");
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = parse_ConstructTriples();
              result2 = result2 !== null ? result2 : "";
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  if (input.charCodeAt(pos) === 125) {
                    result4 = "}";
                    pos++;
                  } else {
                    result4 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"}\"");
                    }
                  }
                  if (result4 !== null) {
                    result0 = [result0, result1, result2, result3, result4];
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, ts) {
                return ts;
          })(pos0, result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[64] ConstructTemplate");
          }
          return result0;
        }
        
        function parse_ConstructTriples() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_TriplesSameSubject();
          if (result0 !== null) {
            pos2 = pos;
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              if (input.charCodeAt(pos) === 46) {
                result2 = ".";
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\".\"");
                }
              }
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result4 = parse_ConstructTriples();
                  result4 = result4 !== null ? result4 : "";
                  if (result4 !== null) {
                    result1 = [result1, result2, result3, result4];
                  } else {
                    result1 = null;
                    pos = pos2;
                  }
                } else {
                  result1 = null;
                  pos = pos2;
                }
              } else {
                result1 = null;
                pos = pos2;
              }
            } else {
              result1 = null;
              pos = pos2;
            }
            result1 = result1 !== null ? result1 : "";
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, b, bs) {
               var triples = b.triplesContext;
               var toTest = null;
                if(typeof(bs) === 'object') {
                      if(bs.length != null) {
                            if(bs[3].triplesContext!=null) {
                               triples = triples.concat(bs[3].triplesContext);
                        }
                     }
                }
          
               return {token:'triplestemplate',
                       triplesContext: triples}
          })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[65] ConstructTriples");
          }
          return result0;
        }
        
        function parse_TriplesSameSubject() {
          var result0, result1, result2, result3;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            result1 = parse_VarOrTerm();
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                result3 = parse_PropertyListNotEmpty();
                if (result3 !== null) {
                  result0 = [result0, result1, result2, result3];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, s, pairs) {
                var triplesContext = pairs.triplesContext;
                var subject = s;
                if(pairs.pairs) {
                  for(var i=0; i< pairs.pairs.length; i++) {
                      var pair = pairs.pairs[i];
                      var triple = null;
          	    if(pair[1].length != null)
          	      pair[1] = pair[1][0]
                      if(subject.token && subject.token==='triplesnodecollection') {
                          triple = {subject: subject.chainSubject[0], predicate: pair[0], object: pair[1]}
                          triplesContext.push(triple);
                          triplesContext = triplesContext.concat(subject.triplesContext);
                      } else {
                          triple = {subject: subject, predicate: pair[0], object: pair[1]}
                          triplesContext.push(triple);
                      }
                  }
                }
          
                var token = {};
                token.token = "triplessamesubject";
                token.triplesContext = triplesContext;
                token.chainSubject = subject;
          
                return token;
            })(pos0, result0[1], result0[3]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            pos1 = pos;
            result0 = [];
            result1 = parse_WS();
            while (result1 !== null) {
              result0.push(result1);
              result1 = parse_WS();
            }
            if (result0 !== null) {
              result1 = parse_TriplesNode();
              if (result1 !== null) {
                result2 = [];
                result3 = parse_WS();
                while (result3 !== null) {
                  result2.push(result3);
                  result3 = parse_WS();
                }
                if (result2 !== null) {
                  result3 = parse_PropertyList();
                  if (result3 !== null) {
                    result0 = [result0, result1, result2, result3];
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
            if (result0 !== null) {
              result0 = (function(offset, tn, pairs) {
                  var triplesContext = tn.triplesContext;
                  var subject = tn.chainSubject;
            
                  if(pairs.pairs) {
                    for(var i=0; i< pairs.pairs.length; i++) {
                        var pair = pairs.pairs[i];
                        if(pair[1].length != null)
            	      pair[1] = pair[1][0]
            
                        if(tn.token === "triplesnodecollection") {
                            for(var j=0; j<subject.length; j++) {
                                var subj = subject[j];
                                if(subj.triplesContext != null) {
                                    var triple = {subject: subj.chainSubject, predicate: pair[0], object: pair[1]}
                                    triplesContext.concat(subj.triplesContext);
                                } else {
                                    var triple = {subject: subject[j], predicate: pair[0], object: pair[1]}
                                    triplesContext.push(triple);
                                }
                            }
                        } else {
                            var triple = {subject: subject, predicate: pair[0], object: pair[1]}
                            triplesContext.push(triple);
                        }
                    }
                  }
            
                  var token = {};
                  token.token = "triplessamesubject";
                  token.triplesContext = triplesContext;
                  token.chainSubject = subject;
            
                  return token;
              })(pos0, result0[1], result0[3]);
            }
            if (result0 === null) {
              pos = pos0;
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[66] TriplesSameSubject");
          }
          return result0;
        }
        
        function parse_PropertyListNotEmpty() {
          var result0, result1, result2, result3, result4, result5, result6, result7, result8, result9;
          var pos0, pos1, pos2, pos3;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_Verb();
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = parse_ObjectList();
              if (result2 !== null) {
                result3 = [];
                pos2 = pos;
                result4 = [];
                result5 = parse_WS();
                while (result5 !== null) {
                  result4.push(result5);
                  result5 = parse_WS();
                }
                if (result4 !== null) {
                  if (input.charCodeAt(pos) === 59) {
                    result5 = ";";
                    pos++;
                  } else {
                    result5 = null;
                    if (reportFailures === 0) {
                      matchFailed("\";\"");
                    }
                  }
                  if (result5 !== null) {
                    result6 = [];
                    result7 = parse_WS();
                    while (result7 !== null) {
                      result6.push(result7);
                      result7 = parse_WS();
                    }
                    if (result6 !== null) {
                      pos3 = pos;
                      result7 = parse_Verb();
                      if (result7 !== null) {
                        result8 = [];
                        result9 = parse_WS();
                        while (result9 !== null) {
                          result8.push(result9);
                          result9 = parse_WS();
                        }
                        if (result8 !== null) {
                          result9 = parse_ObjectList();
                          if (result9 !== null) {
                            result7 = [result7, result8, result9];
                          } else {
                            result7 = null;
                            pos = pos3;
                          }
                        } else {
                          result7 = null;
                          pos = pos3;
                        }
                      } else {
                        result7 = null;
                        pos = pos3;
                      }
                      result7 = result7 !== null ? result7 : "";
                      if (result7 !== null) {
                        result4 = [result4, result5, result6, result7];
                      } else {
                        result4 = null;
                        pos = pos2;
                      }
                    } else {
                      result4 = null;
                      pos = pos2;
                    }
                  } else {
                    result4 = null;
                    pos = pos2;
                  }
                } else {
                  result4 = null;
                  pos = pos2;
                }
                while (result4 !== null) {
                  result3.push(result4);
                  pos2 = pos;
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    if (input.charCodeAt(pos) === 59) {
                      result5 = ";";
                      pos++;
                    } else {
                      result5 = null;
                      if (reportFailures === 0) {
                        matchFailed("\";\"");
                      }
                    }
                    if (result5 !== null) {
                      result6 = [];
                      result7 = parse_WS();
                      while (result7 !== null) {
                        result6.push(result7);
                        result7 = parse_WS();
                      }
                      if (result6 !== null) {
                        pos3 = pos;
                        result7 = parse_Verb();
                        if (result7 !== null) {
                          result8 = [];
                          result9 = parse_WS();
                          while (result9 !== null) {
                            result8.push(result9);
                            result9 = parse_WS();
                          }
                          if (result8 !== null) {
                            result9 = parse_ObjectList();
                            if (result9 !== null) {
                              result7 = [result7, result8, result9];
                            } else {
                              result7 = null;
                              pos = pos3;
                            }
                          } else {
                            result7 = null;
                            pos = pos3;
                          }
                        } else {
                          result7 = null;
                          pos = pos3;
                        }
                        result7 = result7 !== null ? result7 : "";
                        if (result7 !== null) {
                          result4 = [result4, result5, result6, result7];
                        } else {
                          result4 = null;
                          pos = pos2;
                        }
                      } else {
                        result4 = null;
                        pos = pos2;
                      }
                    } else {
                      result4 = null;
                      pos = pos2;
                    }
                  } else {
                    result4 = null;
                    pos = pos2;
                  }
                }
                if (result3 !== null) {
                  result0 = [result0, result1, result2, result3];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, v, ol, rest) {
                var token = {}
                token.token = 'propertylist';
                var triplesContext = [];
                var pairs = [];
                var test = [];
          
                for( var i=0; i<ol.length; i++) {
          
                   if(ol[i].triplesContext != null) {
                       triplesContext = triplesContext.concat(ol[i].triplesContext);
                       if(ol[i].token==='triplesnodecollection' && ol[i].chainSubject.length != null) {
                           pairs.push([v, ol[i].chainSubject[0]]);
                       } else {
                           pairs.push([v, ol[i].chainSubject]);
                       }
          
                    } else {
                        pairs.push([v, ol[i]])
                    }
          
                }
          
          
                for(var i=0; i<rest.length; i++) {
                    var tok = rest[i][3];
                    var newVerb  = tok[0];
                    var newObjsList = tok[2] || [];
          
                    for(var j=0; j<newObjsList.length; j++) {
                     if(newObjsList[j].triplesContext != null) {
                        triplesContext = triplesContext.concat(newObjsList[j].triplesContext);
                       pairs.push([newVerb, newObjsList[j].chainSubject]);
                      } else {
                        pairs.push([newVerb, newObjsList[j]])
                      }
                    }
                }
          
                token.pairs = pairs;
                token.triplesContext = triplesContext;
          
                return token;
          
          })(pos0, result0[0], result0[2], result0[3]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[67] PropertyListNotEmpty");
          }
          return result0;
        }
        
        function parse_PropertyList() {
          var result0;
          
          reportFailures++;
          result0 = parse_PropertyListNotEmpty();
          result0 = result0 !== null ? result0 : "";
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[68] PropertyList");
          }
          return result0;
        }
        
        function parse_ObjectList() {
          var result0, result1, result2, result3, result4, result5;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_GraphNode();
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = [];
              pos2 = pos;
              if (input.charCodeAt(pos) === 44) {
                result3 = ",";
                pos++;
              } else {
                result3 = null;
                if (reportFailures === 0) {
                  matchFailed("\",\"");
                }
              }
              if (result3 !== null) {
                result4 = [];
                result5 = parse_WS();
                while (result5 !== null) {
                  result4.push(result5);
                  result5 = parse_WS();
                }
                if (result4 !== null) {
                  result5 = parse_GraphNode();
                  if (result5 !== null) {
                    result3 = [result3, result4, result5];
                  } else {
                    result3 = null;
                    pos = pos2;
                  }
                } else {
                  result3 = null;
                  pos = pos2;
                }
              } else {
                result3 = null;
                pos = pos2;
              }
              while (result3 !== null) {
                result2.push(result3);
                pos2 = pos;
                if (input.charCodeAt(pos) === 44) {
                  result3 = ",";
                  pos++;
                } else {
                  result3 = null;
                  if (reportFailures === 0) {
                    matchFailed("\",\"");
                  }
                }
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    result5 = parse_GraphNode();
                    if (result5 !== null) {
                      result3 = [result3, result4, result5];
                    } else {
                      result3 = null;
                      pos = pos2;
                    }
                  } else {
                    result3 = null;
                    pos = pos2;
                  }
                } else {
                  result3 = null;
                  pos = pos2;
                }
              }
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, obj, objs) {
          
                  var toReturn = [];
          
                  toReturn.push(obj);
          
                  for(var i=0; i<objs.length; i++) {
                      for(var j=0; j<objs[i].length; j++) {
                          if(typeof(objs[i][j])=="object" && objs[i][j].token != null) {
                              toReturn.push(objs[i][j]);
                          }
                      }
                  }
          
                  return toReturn;
              })(pos0, result0[0], result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[69] ObjectList");
          }
          return result0;
        }
        
        function parse_Verb() {
          var result0;
          var pos0;
          
          reportFailures++;
          result0 = parse_VarOrIRIref();
          if (result0 === null) {
            pos0 = pos;
            if (input.charCodeAt(pos) === 97) {
              result0 = "a";
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"a\"");
              }
            }
            if (result0 !== null) {
              result0 = (function(offset) {
                  return{token: 'uri', prefix:null, suffix:null, value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}
              })(pos0);
            }
            if (result0 === null) {
              pos = pos0;
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[71] Verb");
          }
          return result0;
        }
        
        function parse_TriplesSameSubjectPath() {
          var result0, result1, result2, result3;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            result1 = parse_VarOrTerm();
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                result3 = parse_PropertyListNotEmptyPath();
                if (result3 !== null) {
                  result0 = [result0, result1, result2, result3];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, s, pairs) {
                var triplesContext = pairs.triplesContext;
                var subject = s;
                if(pairs.pairs) {
                  for(var i=0; i< pairs.pairs.length; i++) {
                      var pair = pairs.pairs[i];
                      var triple = null;
          	    if(pair[1].length != null)
          	      pair[1] = pair[1][0]
                      if(subject.token && subject.token==='triplesnodecollection') {
                          triple = {subject: subject.chainSubject[0], predicate: pair[0], object: pair[1]}
                          triplesContext.push(triple);
                          triplesContext = triplesContext.concat(subject.triplesContext);
                      } else {
                          triple = {subject: subject, predicate: pair[0], object: pair[1]}
                          triplesContext.push(triple);
                      }
                  }
                }
          
                var token = {};
                token.token = "triplessamesubject";
                token.triplesContext = triplesContext;
                token.chainSubject = subject;
          
                return token;
            })(pos0, result0[1], result0[3]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            pos1 = pos;
            result0 = [];
            result1 = parse_WS();
            while (result1 !== null) {
              result0.push(result1);
              result1 = parse_WS();
            }
            if (result0 !== null) {
              result1 = parse_TriplesNode();
              if (result1 !== null) {
                result2 = [];
                result3 = parse_WS();
                while (result3 !== null) {
                  result2.push(result3);
                  result3 = parse_WS();
                }
                if (result2 !== null) {
                  result3 = parse_PropertyListPath();
                  if (result3 !== null) {
                    result0 = [result0, result1, result2, result3];
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
            if (result0 !== null) {
              result0 = (function(offset, tn, pairs) {
                  var triplesContext = tn.triplesContext;
                  var subject = tn.chainSubject;
            
                  if(pairs.pairs) {
                    for(var i=0; i< pairs.pairs.length; i++) {
                        var pair = pairs.pairs[i];
                        if(pair[1].length != null)
            	      pair[1] = pair[1][0]
            
                        if(tn.token === "triplesnodecollection") {
                            for(var j=0; j<subject.length; j++) {
                                var subj = subject[j];
                                if(subj.triplesContext != null) {
                                    var triple = {subject: subj.chainSubject, predicate: pair[0], object: pair[1]}
                                    triplesContext.concat(subj.triplesContext);
                                } else {
                                    var triple = {subject: subject[j], predicate: pair[0], object: pair[1]}
                                    triplesContext.push(triple);
                                }
                            }
                        } else {
                            var triple = {subject: subject, predicate: pair[0], object: pair[1]}
                            triplesContext.push(triple);
                        }
                    }
                  }
            
                  var token = {};
                  token.token = "triplessamesubject";
                  token.triplesContext = triplesContext;
                  token.chainSubject = subject;
            
                  return token;
            
                })(pos0, result0[1], result0[3]);
            }
            if (result0 === null) {
              pos = pos0;
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[72] TriplesSameSubjectPath");
          }
          return result0;
        }
        
        function parse_PropertyListNotEmptyPath() {
          var result0, result1, result2, result3, result4, result5, result6, result7, result8;
          var pos0, pos1, pos2, pos3;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_VerbPath();
          if (result0 === null) {
            result0 = parse_Var();
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = parse_ObjectList();
              if (result2 !== null) {
                result3 = [];
                pos2 = pos;
                result4 = [];
                result5 = parse_WS();
                while (result5 !== null) {
                  result4.push(result5);
                  result5 = parse_WS();
                }
                if (result4 !== null) {
                  if (input.charCodeAt(pos) === 59) {
                    result5 = ";";
                    pos++;
                  } else {
                    result5 = null;
                    if (reportFailures === 0) {
                      matchFailed("\";\"");
                    }
                  }
                  if (result5 !== null) {
                    result6 = [];
                    result7 = parse_WS();
                    while (result7 !== null) {
                      result6.push(result7);
                      result7 = parse_WS();
                    }
                    if (result6 !== null) {
                      pos3 = pos;
                      result7 = parse_VerbPath();
                      if (result7 === null) {
                        result7 = parse_Var();
                      }
                      if (result7 !== null) {
                        result8 = parse_ObjectList();
                        if (result8 !== null) {
                          result7 = [result7, result8];
                        } else {
                          result7 = null;
                          pos = pos3;
                        }
                      } else {
                        result7 = null;
                        pos = pos3;
                      }
                      result7 = result7 !== null ? result7 : "";
                      if (result7 !== null) {
                        result4 = [result4, result5, result6, result7];
                      } else {
                        result4 = null;
                        pos = pos2;
                      }
                    } else {
                      result4 = null;
                      pos = pos2;
                    }
                  } else {
                    result4 = null;
                    pos = pos2;
                  }
                } else {
                  result4 = null;
                  pos = pos2;
                }
                while (result4 !== null) {
                  result3.push(result4);
                  pos2 = pos;
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    if (input.charCodeAt(pos) === 59) {
                      result5 = ";";
                      pos++;
                    } else {
                      result5 = null;
                      if (reportFailures === 0) {
                        matchFailed("\";\"");
                      }
                    }
                    if (result5 !== null) {
                      result6 = [];
                      result7 = parse_WS();
                      while (result7 !== null) {
                        result6.push(result7);
                        result7 = parse_WS();
                      }
                      if (result6 !== null) {
                        pos3 = pos;
                        result7 = parse_VerbPath();
                        if (result7 === null) {
                          result7 = parse_Var();
                        }
                        if (result7 !== null) {
                          result8 = parse_ObjectList();
                          if (result8 !== null) {
                            result7 = [result7, result8];
                          } else {
                            result7 = null;
                            pos = pos3;
                          }
                        } else {
                          result7 = null;
                          pos = pos3;
                        }
                        result7 = result7 !== null ? result7 : "";
                        if (result7 !== null) {
                          result4 = [result4, result5, result6, result7];
                        } else {
                          result4 = null;
                          pos = pos2;
                        }
                      } else {
                        result4 = null;
                        pos = pos2;
                      }
                    } else {
                      result4 = null;
                      pos = pos2;
                    }
                  } else {
                    result4 = null;
                    pos = pos2;
                  }
                }
                if (result3 !== null) {
                  result0 = [result0, result1, result2, result3];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, v, ol, rest) {
                token = {}
                token.token = 'propertylist';
                var triplesContext = [];
                var pairs = [];
                var test = [];
          
                for( var i=0; i<ol.length; i++) {
          
                   if(ol[i].triplesContext != null) {
                       triplesContext = triplesContext.concat(ol[i].triplesContext);
                       if(ol[i].token==='triplesnodecollection' && ol[i].chainSubject.length != null) {
                           pairs.push([v, ol[i].chainSubject[0]]);
                       } else {
                           pairs.push([v, ol[i].chainSubject]);
                       }
          
                    } else {
                        pairs.push([v, ol[i]])
                    }
          
                }
          
          
                for(var i=0; i<rest.length; i++) {
                    var tok = rest[i][3];
                    var newVerb  = tok[0];
                    var newObjsList = tok[1] || [];
          
                    for(var j=0; j<newObjsList.length; j++) {
                     if(newObjsList[j].triplesContext != null) {
                        triplesContext = triplesContext.concat(newObjsList[j].triplesContext);
                       pairs.push([newVerb, newObjsList[j].chainSubject]);
                      } else {
                        pairs.push([newVerb, newObjsList[j]])
                      }
                    }
                }
          
                token.pairs = pairs;
                token.triplesContext = triplesContext;
          
                return token;
          })(pos0, result0[0], result0[2], result0[3]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[73] PropertyListNotEmptyPath");
          }
          return result0;
        }
        
        function parse_PropertyListPath() {
          var result0;
          
          reportFailures++;
          result0 = parse_PropertyListNotEmpty();
          result0 = result0 !== null ? result0 : "";
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[74] PropertyListPath");
          }
          return result0;
        }
        
        function parse_VerbPath() {
          var result0;
          var pos0;
          
          reportFailures++;
          pos0 = pos;
          result0 = parse_PathAlternative();
          if (result0 !== null) {
            result0 = (function(offset, p) {
                var path = {};
                path.token = 'path';
                path.kind = 'element';
                path.value = p;
          
                return p;
            })(pos0, result0);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[75]");
          }
          return result0;
        }
        
        function parse_PathAlternative() {
          var result0, result1, result2, result3;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_PathSequence();
          if (result0 !== null) {
            result1 = [];
            pos2 = pos;
            if (input.charCodeAt(pos) === 124) {
              result2 = "|";
              pos++;
            } else {
              result2 = null;
              if (reportFailures === 0) {
                matchFailed("\"|\"");
              }
            }
            if (result2 !== null) {
              result3 = parse_PathSequence();
              if (result3 !== null) {
                result2 = [result2, result3];
              } else {
                result2 = null;
                pos = pos2;
              }
            } else {
              result2 = null;
              pos = pos2;
            }
            while (result2 !== null) {
              result1.push(result2);
              pos2 = pos;
              if (input.charCodeAt(pos) === 124) {
                result2 = "|";
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"|\"");
                }
              }
              if (result2 !== null) {
                result3 = parse_PathSequence();
                if (result3 !== null) {
                  result2 = [result2, result3];
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
            }
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, first, rest) {
          	if(rest == null || rest.length === 0) {
          	    return first;
          	} else {
          	    var acum = [];
          	    for(var i=0; i<rest.length; i++)
          		acum.push(rest[1]);
          
          	    var path = {};
          	    path.token = 'path';
          	    path.kind = 'alternative';
          	    path.value = acum;
          
          	    return path;
          	}
              })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[78] PathAlternative");
          }
          return result0;
        }
        
        function parse_PathSequence() {
          var result0, result1, result2, result3;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_PathEltOrInverse();
          if (result0 !== null) {
            result1 = [];
            pos2 = pos;
            if (input.charCodeAt(pos) === 47) {
              result2 = "/";
              pos++;
            } else {
              result2 = null;
              if (reportFailures === 0) {
                matchFailed("\"/\"");
              }
            }
            if (result2 !== null) {
              result3 = parse_PathEltOrInverse();
              if (result3 !== null) {
                result2 = [result2, result3];
              } else {
                result2 = null;
                pos = pos2;
              }
            } else {
              result2 = null;
              pos = pos2;
            }
            while (result2 !== null) {
              result1.push(result2);
              pos2 = pos;
              if (input.charCodeAt(pos) === 47) {
                result2 = "/";
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"/\"");
                }
              }
              if (result2 !== null) {
                result3 = parse_PathEltOrInverse();
                if (result3 !== null) {
                  result2 = [result2, result3];
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
            }
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, first, rest) {
          	if(rest == null || rest.length === 0) {
          	    return first;
          	} else {
          	    var acum = [first];
          
          	    for(var i=0; i<rest.length; i++) 
          		acum.push(rest[i][1]);
          
          	    var path = {};
          	    path.token = 'path';
          	    path.kind = 'sequence';
          	
          	    path.value = acum;
          		
          	    return path;
          	}
              })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[79] PathSequence");
          }
          return result0;
        }
        
        function parse_PathElt() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_PathPrimary();
          if (result0 !== null) {
            result1 = parse_PathMod();
            result1 = result1 !== null ? result1 : "";
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, p, mod) {
          	if(p.token && p.token != 'path' && mod == '') {
          	    return p;
          	} else if(p.token && p.token != path && mod != '') {
          	    var path = {};
          	    path.token = 'path';
          	    path.kind = 'element';
          	    path.value = p;
          	    path.modifier = mod;
          	    return path;
          	} else {
          	    p.modifier = mod;
          	    return p;
          	}
              })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[88] PathElt");
          }
          return result0;
        }
        
        function parse_PathEltOrInverse() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          result0 = parse_PathElt();
          if (result0 === null) {
            pos0 = pos;
            pos1 = pos;
            if (input.charCodeAt(pos) === 94) {
              result0 = "^";
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"^\"");
              }
            }
            if (result0 !== null) {
              result1 = parse_PathElt();
              if (result1 !== null) {
                result0 = [result0, result1];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
            if (result0 !== null) {
              result0 = (function(offset, elt) {
            	var path = {};
            	path.token = 'path';
            	path.kind = 'inversePath';
            	path.value = elt;
            
            	return path;
                })(pos0, result0[1]);
            }
            if (result0 === null) {
              pos = pos0;
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[81] PathEltOrInverse");
          }
          return result0;
        }
        
        function parse_PathMod() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1, pos2, pos3;
          
          reportFailures++;
          if (input.charCodeAt(pos) === 42) {
            result0 = "*";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"*\"");
            }
          }
          if (result0 === null) {
            if (input.charCodeAt(pos) === 63) {
              result0 = "?";
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"?\"");
              }
            }
            if (result0 === null) {
              if (input.charCodeAt(pos) === 43) {
                result0 = "+";
                pos++;
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("\"+\"");
                }
              }
              if (result0 === null) {
                pos0 = pos;
                if (input.charCodeAt(pos) === 123) {
                  result0 = "{";
                  pos++;
                } else {
                  result0 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"{\"");
                  }
                }
                if (result0 !== null) {
                  pos1 = pos;
                  result1 = parse_INTEGER();
                  if (result1 !== null) {
                    pos2 = pos;
                    if (input.charCodeAt(pos) === 44) {
                      result2 = ",";
                      pos++;
                    } else {
                      result2 = null;
                      if (reportFailures === 0) {
                        matchFailed("\",\"");
                      }
                    }
                    if (result2 !== null) {
                      if (input.charCodeAt(pos) === 125) {
                        result3 = "}";
                        pos++;
                      } else {
                        result3 = null;
                        if (reportFailures === 0) {
                          matchFailed("\"}\"");
                        }
                      }
                      if (result3 === null) {
                        pos3 = pos;
                        result3 = parse_INTEGER();
                        if (result3 !== null) {
                          if (input.charCodeAt(pos) === 125) {
                            result4 = "}";
                            pos++;
                          } else {
                            result4 = null;
                            if (reportFailures === 0) {
                              matchFailed("\"}\"");
                            }
                          }
                          if (result4 !== null) {
                            result3 = [result3, result4];
                          } else {
                            result3 = null;
                            pos = pos3;
                          }
                        } else {
                          result3 = null;
                          pos = pos3;
                        }
                      }
                      if (result3 !== null) {
                        result2 = [result2, result3];
                      } else {
                        result2 = null;
                        pos = pos2;
                      }
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                    if (result2 === null) {
                      if (input.charCodeAt(pos) === 125) {
                        result2 = "}";
                        pos++;
                      } else {
                        result2 = null;
                        if (reportFailures === 0) {
                          matchFailed("\"}\"");
                        }
                      }
                    }
                    if (result2 !== null) {
                      result1 = [result1, result2];
                    } else {
                      result1 = null;
                      pos = pos1;
                    }
                  } else {
                    result1 = null;
                    pos = pos1;
                  }
                  if (result1 === null) {
                    pos1 = pos;
                    if (input.charCodeAt(pos) === 44) {
                      result1 = ",";
                      pos++;
                    } else {
                      result1 = null;
                      if (reportFailures === 0) {
                        matchFailed("\",\"");
                      }
                    }
                    if (result1 !== null) {
                      result2 = parse_INTEGER();
                      if (result2 !== null) {
                        if (input.charCodeAt(pos) === 125) {
                          result3 = "}";
                          pos++;
                        } else {
                          result3 = null;
                          if (reportFailures === 0) {
                            matchFailed("\"}\"");
                          }
                        }
                        if (result3 !== null) {
                          result1 = [result1, result2, result3];
                        } else {
                          result1 = null;
                          pos = pos1;
                        }
                      } else {
                        result1 = null;
                        pos = pos1;
                      }
                    } else {
                      result1 = null;
                      pos = pos1;
                    }
                  }
                  if (result1 !== null) {
                    result0 = [result0, result1];
                  } else {
                    result0 = null;
                    pos = pos0;
                  }
                } else {
                  result0 = null;
                  pos = pos0;
                }
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[82] PathMod");
          }
          return result0;
        }
        
        function parse_PathPrimary() {
          var result0, result1, result2;
          var pos0, pos1;
          
          reportFailures++;
          result0 = parse_IRIref();
          if (result0 === null) {
            pos0 = pos;
            if (input.charCodeAt(pos) === 97) {
              result0 = "a";
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"a\"");
              }
            }
            if (result0 !== null) {
              result0 = (function(offset) {
            	return{token: 'uri', prefix:null, suffix:null, value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}
                })(pos0);
            }
            if (result0 === null) {
              pos = pos0;
            }
            if (result0 === null) {
              pos0 = pos;
              if (input.charCodeAt(pos) === 33) {
                result0 = "!";
                pos++;
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("\"!\"");
                }
              }
              if (result0 !== null) {
                result1 = parse_PathNegatedPropertySet();
                if (result1 !== null) {
                  result0 = [result0, result1];
                } else {
                  result0 = null;
                  pos = pos0;
                }
              } else {
                result0 = null;
                pos = pos0;
              }
              if (result0 === null) {
                pos0 = pos;
                pos1 = pos;
                if (input.charCodeAt(pos) === 40) {
                  result0 = "(";
                  pos++;
                } else {
                  result0 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"(\"");
                  }
                }
                if (result0 !== null) {
                  result1 = parse_PathAlternative();
                  if (result1 !== null) {
                    if (input.charCodeAt(pos) === 41) {
                      result2 = ")";
                      pos++;
                    } else {
                      result2 = null;
                      if (reportFailures === 0) {
                        matchFailed("\")\"");
                      }
                    }
                    if (result2 !== null) {
                      result0 = [result0, result1, result2];
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
                if (result0 !== null) {
                  result0 = (function(offset, p) {
                	return p;
                    })(pos0, result0[1]);
                }
                if (result0 === null) {
                  pos = pos0;
                }
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[83] PathPrimary");
          }
          return result0;
        }
        
        function parse_PathNegatedPropertySet() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1, pos2;
          
          result0 = parse_PathOneInPropertySet();
          if (result0 === null) {
            pos0 = pos;
            if (input.charCodeAt(pos) === 40) {
              result0 = "(";
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"(\"");
              }
            }
            if (result0 !== null) {
              pos1 = pos;
              result1 = parse_PathOneInPropertySet();
              if (result1 !== null) {
                result2 = [];
                pos2 = pos;
                if (input.charCodeAt(pos) === 124) {
                  result3 = "|";
                  pos++;
                } else {
                  result3 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"|\"");
                  }
                }
                if (result3 !== null) {
                  result4 = parse_PathOneInPropertySet();
                  if (result4 !== null) {
                    result3 = [result3, result4];
                  } else {
                    result3 = null;
                    pos = pos2;
                  }
                } else {
                  result3 = null;
                  pos = pos2;
                }
                while (result3 !== null) {
                  result2.push(result3);
                  pos2 = pos;
                  if (input.charCodeAt(pos) === 124) {
                    result3 = "|";
                    pos++;
                  } else {
                    result3 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"|\"");
                    }
                  }
                  if (result3 !== null) {
                    result4 = parse_PathOneInPropertySet();
                    if (result4 !== null) {
                      result3 = [result3, result4];
                    } else {
                      result3 = null;
                      pos = pos2;
                    }
                  } else {
                    result3 = null;
                    pos = pos2;
                  }
                }
                if (result2 !== null) {
                  result1 = [result1, result2];
                } else {
                  result1 = null;
                  pos = pos1;
                }
              } else {
                result1 = null;
                pos = pos1;
              }
              result1 = result1 !== null ? result1 : "";
              if (result1 !== null) {
                if (input.charCodeAt(pos) === 41) {
                  result2 = ")";
                  pos++;
                } else {
                  result2 = null;
                  if (reportFailures === 0) {
                    matchFailed("\")\"");
                  }
                }
                if (result2 !== null) {
                  result0 = [result0, result1, result2];
                } else {
                  result0 = null;
                  pos = pos0;
                }
              } else {
                result0 = null;
                pos = pos0;
              }
            } else {
              result0 = null;
              pos = pos0;
            }
          }
          return result0;
        }
        
        function parse_PathOneInPropertySet() {
          var result0, result1;
          var pos0;
          
          reportFailures++;
          result0 = parse_IRIref();
          if (result0 === null) {
            if (input.charCodeAt(pos) === 97) {
              result0 = "a";
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"a\"");
              }
            }
            if (result0 === null) {
              pos0 = pos;
              if (input.charCodeAt(pos) === 94) {
                result0 = "^";
                pos++;
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("\"^\"");
                }
              }
              if (result0 !== null) {
                result1 = parse_IRIref();
                if (result1 === null) {
                  if (input.charCodeAt(pos) === 97) {
                    result1 = "a";
                    pos++;
                  } else {
                    result1 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"a\"");
                    }
                  }
                }
                if (result1 !== null) {
                  result0 = [result0, result1];
                } else {
                  result0 = null;
                  pos = pos0;
                }
              } else {
                result0 = null;
                pos = pos0;
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[85] PathOneInPropertySet");
          }
          return result0;
        }
        
        function parse_TriplesNode() {
          var result0;
          var pos0;
          
          reportFailures++;
          pos0 = pos;
          result0 = parse_Collection();
          if (result0 !== null) {
            result0 = (function(offset, c) {
                var triplesContext = [];
                var chainSubject = [];
          
                var triple = null;
          
                // catch NIL
                /*
                if(c.length == 1 && c[0].token && c[0].token === 'nil') {
                    GlobalBlankNodeCounter++;
                    return  {token: "triplesnodecollection", 
                             triplesContext:[{subject: {token:'blank', value:("_:"+GlobalBlankNodeCounter)},
                                              predicate:{token:'uri', prefix:null, suffix:null, value:'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest'},
                                              object:  {token:'blank', value:("_:"+(GlobalBlankNodeCounter+1))}}], 
                             chainSubject:{token:'blank', value:("_:"+GlobalBlankNodeCounter)}};
          
                }
                */
          
                // other cases
                for(var i=0; i<c.length; i++) {
                    GlobalBlankNodeCounter++;
                    //_:b0  rdf:first  1 ;
                    //rdf:rest   _:b1 .
                    var nextObject = null;
                    if(c[i].chainSubject == null && c[i].triplesContext == null) {
                        nextObject = c[i];
                    } else {
                        nextObject = c[i].chainSubject;
                        triplesContext = triplesContext.concat(nextSubject.triplesContext);
                    }
                    var currentSubject = null;
                    triple = {subject: {token:'blank', value:("_:"+GlobalBlankNodeCounter)},
                              predicate:{token:'uri', prefix:null, suffix:null, value:'http://www.w3.org/1999/02/22-rdf-syntax-ns#first'},
                              object:nextObject };
          
                    if(i==0) {
                        chainSubject.push(triple.subject);
                    }
          
                    triplesContext.push(triple);
          
                    if(i===(c.length-1)) {
                        triple = {subject: {token:'blank', value:("_:"+GlobalBlankNodeCounter)},
                                  predicate:{token:'uri', prefix:null, suffix:null, value:'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest'},
                                  object:   {token:'uri', prefix:null, suffix:null, value:'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'}};
                    } else {
                        triple = {subject: {token:'blank', value:("_:"+GlobalBlankNodeCounter)},
                                  predicate:{token:'uri', prefix:null, suffix:null, value:'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest'},
                                  object:  {token:'blank', value:("_:"+(GlobalBlankNodeCounter+1))} };
                    }
          
                    triplesContext.push(triple);
                }
          
                return {token:"triplesnodecollection", triplesContext:triplesContext, chainSubject:chainSubject};
          })(pos0, result0);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            result0 = parse_BlankNodePropertyList();
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[87] TriplesNode");
          }
          return result0;
        }
        
        function parse_BlankNodePropertyList() {
          var result0, result1, result2, result3, result4, result5, result6, result7;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            if (input.charCodeAt(pos) === 91) {
              result1 = "[";
              pos++;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("\"[\"");
              }
            }
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                result3 = parse_PropertyListNotEmpty();
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    if (input.charCodeAt(pos) === 93) {
                      result5 = "]";
                      pos++;
                    } else {
                      result5 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"]\"");
                      }
                    }
                    if (result5 !== null) {
                      result6 = [];
                      result7 = parse_WS();
                      while (result7 !== null) {
                        result6.push(result7);
                        result7 = parse_WS();
                      }
                      if (result6 !== null) {
                        result0 = [result0, result1, result2, result3, result4, result5, result6];
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, pl) {
          
                GlobalBlankNodeCounter++;
                var subject = {token:'blank', value:'_:'+GlobalBlankNodeCounter};
                var newTriples =  [];
          
                for(var i=0; i< pl.pairs.length; i++) {
                    var pair = pl.pairs[i];
                    var triple = {}
                    triple.subject = subject;
                    triple.predicate = pair[0];
                    if(pair[1].length != null)
          	    pair[1] = pair[1][0]
                    triple.object = pair[1];
                    newTriples.push(triple);
                }
          
                return {token: 'triplesnode',
                        kind: 'blanknodepropertylist',
                        triplesContext: pl.triplesContext.concat(newTriples),
                        chainSubject: subject};
          })(pos0, result0[3]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[88] BlankNodePropertyList");
          }
          return result0;
        }
        
        function parse_Collection() {
          var result0, result1, result2, result3, result4, result5, result6, result7;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            if (input.charCodeAt(pos) === 40) {
              result1 = "(";
              pos++;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("\"(\"");
              }
            }
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                result4 = parse_GraphNode();
                if (result4 !== null) {
                  result3 = [];
                  while (result4 !== null) {
                    result3.push(result4);
                    result4 = parse_GraphNode();
                  }
                } else {
                  result3 = null;
                }
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    if (input.charCodeAt(pos) === 41) {
                      result5 = ")";
                      pos++;
                    } else {
                      result5 = null;
                      if (reportFailures === 0) {
                        matchFailed("\")\"");
                      }
                    }
                    if (result5 !== null) {
                      result6 = [];
                      result7 = parse_WS();
                      while (result7 !== null) {
                        result6.push(result7);
                        result7 = parse_WS();
                      }
                      if (result6 !== null) {
                        result0 = [result0, result1, result2, result3, result4, result5, result6];
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, gn) {
                return gn;
          })(pos0, result0[3]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[89] Collection");
          }
          return result0;
        }
        
        function parse_GraphNode() {
          var result0, result1, result2, result3;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = [];
          result1 = parse_WS();
          while (result1 !== null) {
            result0.push(result1);
            result1 = parse_WS();
          }
          if (result0 !== null) {
            result1 = parse_VarOrTerm();
            if (result1 !== null) {
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 === null) {
            pos1 = pos;
            result0 = [];
            result1 = parse_WS();
            while (result1 !== null) {
              result0.push(result1);
              result1 = parse_WS();
            }
            if (result0 !== null) {
              result1 = parse_TriplesNode();
              if (result1 !== null) {
                result2 = [];
                result3 = parse_WS();
                while (result3 !== null) {
                  result2.push(result3);
                  result3 = parse_WS();
                }
                if (result2 !== null) {
                  result0 = [result0, result1, result2];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          }
          if (result0 !== null) {
            result0 = (function(offset, gn) {
            return gn[1];
          })(pos0, result0);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[90] GraphNode");
          }
          return result0;
        }
        
        function parse_VarOrTerm() {
          var result0;
          
          reportFailures++;
          result0 = parse_Var();
          if (result0 === null) {
            result0 = parse_GraphTerm();
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[91] VarOrTerm");
          }
          return result0;
        }
        
        function parse_VarOrIRIref() {
          var result0;
          
          reportFailures++;
          result0 = parse_Var();
          if (result0 === null) {
            result0 = parse_IRIref();
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[92] VarOrIRIref");
          }
          return result0;
        }
        
        function parse_Var() {
          var result0;
          var pos0;
          
          reportFailures++;
          pos0 = pos;
          result0 = parse_VAR1();
          if (result0 === null) {
            result0 = parse_VAR2();
          }
          if (result0 !== null) {
            result0 = (function(offset, v) {
                var term = {};
                term.token = 'var';
                term.value = v;
                return term;
            })(pos0, result0);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[93] Var");
          }
          return result0;
        }
        
        function parse_GraphTerm() {
          var result0;
          
          reportFailures++;
          result0 = parse_IRIref();
          if (result0 === null) {
            result0 = parse_RDFLiteral();
            if (result0 === null) {
              result0 = parse_NumericLiteral();
              if (result0 === null) {
                result0 = parse_BooleanLiteral();
                if (result0 === null) {
                  result0 = parse_BlankNode();
                  if (result0 === null) {
                    result0 = parse_NIL();
                  }
                }
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[94] GraphTerm");
          }
          return result0;
        }
        
        function parse_ConditionalOrExpression() {
          var result0, result1, result2, result3, result4, result5;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_ConditionalAndExpression();
          if (result0 !== null) {
            result1 = [];
            pos2 = pos;
            result2 = [];
            result3 = parse_WS();
            while (result3 !== null) {
              result2.push(result3);
              result3 = parse_WS();
            }
            if (result2 !== null) {
              if (input.substr(pos, 2) === "||") {
                result3 = "||";
                pos += 2;
              } else {
                result3 = null;
                if (reportFailures === 0) {
                  matchFailed("\"||\"");
                }
              }
              if (result3 !== null) {
                result4 = [];
                result5 = parse_WS();
                while (result5 !== null) {
                  result4.push(result5);
                  result5 = parse_WS();
                }
                if (result4 !== null) {
                  result5 = parse_ConditionalAndExpression();
                  if (result5 !== null) {
                    result2 = [result2, result3, result4, result5];
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
            } else {
              result2 = null;
              pos = pos2;
            }
            while (result2 !== null) {
              result1.push(result2);
              pos2 = pos;
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                if (input.substr(pos, 2) === "||") {
                  result3 = "||";
                  pos += 2;
                } else {
                  result3 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"||\"");
                  }
                }
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    result5 = parse_ConditionalAndExpression();
                    if (result5 !== null) {
                      result2 = [result2, result3, result4, result5];
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
            }
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, v, vs) {
                if(vs.length === 0) {
                    return v;
                }
          
                var exp = {};
                exp.token = "expression";
                exp.expressionType = "conditionalor";
                var ops = [v];
          
                for(var i=0; i<vs.length; i++) {
                    ops.push(vs[i][3]);
                }
          
                exp.operands = ops;
          
                return exp;
          })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[96] ConditionalOrExpression");
          }
          return result0;
        }
        
        function parse_ConditionalAndExpression() {
          var result0, result1, result2, result3, result4, result5;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_RelationalExpression();
          if (result0 !== null) {
            result1 = [];
            pos2 = pos;
            result2 = [];
            result3 = parse_WS();
            while (result3 !== null) {
              result2.push(result3);
              result3 = parse_WS();
            }
            if (result2 !== null) {
              if (input.substr(pos, 2) === "&&") {
                result3 = "&&";
                pos += 2;
              } else {
                result3 = null;
                if (reportFailures === 0) {
                  matchFailed("\"&&\"");
                }
              }
              if (result3 !== null) {
                result4 = [];
                result5 = parse_WS();
                while (result5 !== null) {
                  result4.push(result5);
                  result5 = parse_WS();
                }
                if (result4 !== null) {
                  result5 = parse_RelationalExpression();
                  if (result5 !== null) {
                    result2 = [result2, result3, result4, result5];
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
            } else {
              result2 = null;
              pos = pos2;
            }
            while (result2 !== null) {
              result1.push(result2);
              pos2 = pos;
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                if (input.substr(pos, 2) === "&&") {
                  result3 = "&&";
                  pos += 2;
                } else {
                  result3 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"&&\"");
                  }
                }
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    result5 = parse_RelationalExpression();
                    if (result5 !== null) {
                      result2 = [result2, result3, result4, result5];
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
            }
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, v, vs) {
                if(vs.length === 0) {
                    return v;
                }
                var exp = {};
                exp.token = "expression";
                exp.expressionType = "conditionaland";
                var ops = [v];
          
                for(var i=0; i<vs.length; i++) {
                    ops.push(vs[i][3]);
                }
          
                exp.operands = ops;
          
                return exp;
          })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[97] ConditionalAndExpression");
          }
          return result0;
        }
        
        function parse_RelationalExpression() {
          var result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_AdditiveExpression();
          if (result0 !== null) {
            result1 = [];
            pos2 = pos;
            result2 = [];
            result3 = parse_WS();
            while (result3 !== null) {
              result2.push(result3);
              result3 = parse_WS();
            }
            if (result2 !== null) {
              if (input.charCodeAt(pos) === 61) {
                result3 = "=";
                pos++;
              } else {
                result3 = null;
                if (reportFailures === 0) {
                  matchFailed("\"=\"");
                }
              }
              if (result3 !== null) {
                result4 = [];
                result5 = parse_WS();
                while (result5 !== null) {
                  result4.push(result5);
                  result5 = parse_WS();
                }
                if (result4 !== null) {
                  result5 = parse_AdditiveExpression();
                  if (result5 !== null) {
                    result2 = [result2, result3, result4, result5];
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
            } else {
              result2 = null;
              pos = pos2;
            }
            if (result2 === null) {
              pos2 = pos;
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                if (input.substr(pos, 2) === "!=") {
                  result3 = "!=";
                  pos += 2;
                } else {
                  result3 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"!=\"");
                  }
                }
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    result5 = parse_AdditiveExpression();
                    if (result5 !== null) {
                      result2 = [result2, result3, result4, result5];
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
              if (result2 === null) {
                pos2 = pos;
                result2 = [];
                result3 = parse_WS();
                while (result3 !== null) {
                  result2.push(result3);
                  result3 = parse_WS();
                }
                if (result2 !== null) {
                  if (input.charCodeAt(pos) === 60) {
                    result3 = "<";
                    pos++;
                  } else {
                    result3 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"<\"");
                    }
                  }
                  if (result3 !== null) {
                    result4 = [];
                    result5 = parse_WS();
                    while (result5 !== null) {
                      result4.push(result5);
                      result5 = parse_WS();
                    }
                    if (result4 !== null) {
                      result5 = parse_AdditiveExpression();
                      if (result5 !== null) {
                        result2 = [result2, result3, result4, result5];
                      } else {
                        result2 = null;
                        pos = pos2;
                      }
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
                if (result2 === null) {
                  pos2 = pos;
                  result2 = [];
                  result3 = parse_WS();
                  while (result3 !== null) {
                    result2.push(result3);
                    result3 = parse_WS();
                  }
                  if (result2 !== null) {
                    if (input.charCodeAt(pos) === 62) {
                      result3 = ">";
                      pos++;
                    } else {
                      result3 = null;
                      if (reportFailures === 0) {
                        matchFailed("\">\"");
                      }
                    }
                    if (result3 !== null) {
                      result4 = [];
                      result5 = parse_WS();
                      while (result5 !== null) {
                        result4.push(result5);
                        result5 = parse_WS();
                      }
                      if (result4 !== null) {
                        result5 = parse_AdditiveExpression();
                        if (result5 !== null) {
                          result2 = [result2, result3, result4, result5];
                        } else {
                          result2 = null;
                          pos = pos2;
                        }
                      } else {
                        result2 = null;
                        pos = pos2;
                      }
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                  if (result2 === null) {
                    pos2 = pos;
                    result2 = [];
                    result3 = parse_WS();
                    while (result3 !== null) {
                      result2.push(result3);
                      result3 = parse_WS();
                    }
                    if (result2 !== null) {
                      if (input.substr(pos, 2) === "<=") {
                        result3 = "<=";
                        pos += 2;
                      } else {
                        result3 = null;
                        if (reportFailures === 0) {
                          matchFailed("\"<=\"");
                        }
                      }
                      if (result3 !== null) {
                        result4 = [];
                        result5 = parse_WS();
                        while (result5 !== null) {
                          result4.push(result5);
                          result5 = parse_WS();
                        }
                        if (result4 !== null) {
                          result5 = parse_AdditiveExpression();
                          if (result5 !== null) {
                            result2 = [result2, result3, result4, result5];
                          } else {
                            result2 = null;
                            pos = pos2;
                          }
                        } else {
                          result2 = null;
                          pos = pos2;
                        }
                      } else {
                        result2 = null;
                        pos = pos2;
                      }
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                    if (result2 === null) {
                      pos2 = pos;
                      result2 = [];
                      result3 = parse_WS();
                      while (result3 !== null) {
                        result2.push(result3);
                        result3 = parse_WS();
                      }
                      if (result2 !== null) {
                        if (input.substr(pos, 2) === ">=") {
                          result3 = ">=";
                          pos += 2;
                        } else {
                          result3 = null;
                          if (reportFailures === 0) {
                            matchFailed("\">=\"");
                          }
                        }
                        if (result3 !== null) {
                          result4 = [];
                          result5 = parse_WS();
                          while (result5 !== null) {
                            result4.push(result5);
                            result5 = parse_WS();
                          }
                          if (result4 !== null) {
                            result5 = parse_AdditiveExpression();
                            if (result5 !== null) {
                              result2 = [result2, result3, result4, result5];
                            } else {
                              result2 = null;
                              pos = pos2;
                            }
                          } else {
                            result2 = null;
                            pos = pos2;
                          }
                        } else {
                          result2 = null;
                          pos = pos2;
                        }
                      } else {
                        result2 = null;
                        pos = pos2;
                      }
                      if (result2 === null) {
                        pos2 = pos;
                        result2 = [];
                        result3 = parse_WS();
                        while (result3 !== null) {
                          result2.push(result3);
                          result3 = parse_WS();
                        }
                        if (result2 !== null) {
                          if (input.charCodeAt(pos) === 73) {
                            result3 = "I";
                            pos++;
                          } else {
                            result3 = null;
                            if (reportFailures === 0) {
                              matchFailed("\"I\"");
                            }
                          }
                          if (result3 === null) {
                            if (input.charCodeAt(pos) === 105) {
                              result3 = "i";
                              pos++;
                            } else {
                              result3 = null;
                              if (reportFailures === 0) {
                                matchFailed("\"i\"");
                              }
                            }
                          }
                          if (result3 !== null) {
                            if (input.charCodeAt(pos) === 78) {
                              result4 = "N";
                              pos++;
                            } else {
                              result4 = null;
                              if (reportFailures === 0) {
                                matchFailed("\"N\"");
                              }
                            }
                            if (result4 === null) {
                              if (input.charCodeAt(pos) === 110) {
                                result4 = "n";
                                pos++;
                              } else {
                                result4 = null;
                                if (reportFailures === 0) {
                                  matchFailed("\"n\"");
                                }
                              }
                            }
                            if (result4 !== null) {
                              result5 = [];
                              result6 = parse_WS();
                              while (result6 !== null) {
                                result5.push(result6);
                                result6 = parse_WS();
                              }
                              if (result5 !== null) {
                                result6 = parse_ExpressionList();
                                if (result6 !== null) {
                                  result2 = [result2, result3, result4, result5, result6];
                                } else {
                                  result2 = null;
                                  pos = pos2;
                                }
                              } else {
                                result2 = null;
                                pos = pos2;
                              }
                            } else {
                              result2 = null;
                              pos = pos2;
                            }
                          } else {
                            result2 = null;
                            pos = pos2;
                          }
                        } else {
                          result2 = null;
                          pos = pos2;
                        }
                        if (result2 === null) {
                          pos2 = pos;
                          result2 = [];
                          result3 = parse_WS();
                          while (result3 !== null) {
                            result2.push(result3);
                            result3 = parse_WS();
                          }
                          if (result2 !== null) {
                            if (input.charCodeAt(pos) === 78) {
                              result3 = "N";
                              pos++;
                            } else {
                              result3 = null;
                              if (reportFailures === 0) {
                                matchFailed("\"N\"");
                              }
                            }
                            if (result3 === null) {
                              if (input.charCodeAt(pos) === 110) {
                                result3 = "n";
                                pos++;
                              } else {
                                result3 = null;
                                if (reportFailures === 0) {
                                  matchFailed("\"n\"");
                                }
                              }
                            }
                            if (result3 !== null) {
                              if (input.charCodeAt(pos) === 79) {
                                result4 = "O";
                                pos++;
                              } else {
                                result4 = null;
                                if (reportFailures === 0) {
                                  matchFailed("\"O\"");
                                }
                              }
                              if (result4 === null) {
                                if (input.charCodeAt(pos) === 111) {
                                  result4 = "o";
                                  pos++;
                                } else {
                                  result4 = null;
                                  if (reportFailures === 0) {
                                    matchFailed("\"o\"");
                                  }
                                }
                              }
                              if (result4 !== null) {
                                if (input.charCodeAt(pos) === 84) {
                                  result5 = "T";
                                  pos++;
                                } else {
                                  result5 = null;
                                  if (reportFailures === 0) {
                                    matchFailed("\"T\"");
                                  }
                                }
                                if (result5 === null) {
                                  if (input.charCodeAt(pos) === 116) {
                                    result5 = "t";
                                    pos++;
                                  } else {
                                    result5 = null;
                                    if (reportFailures === 0) {
                                      matchFailed("\"t\"");
                                    }
                                  }
                                }
                                if (result5 !== null) {
                                  result6 = [];
                                  result7 = parse_WS();
                                  while (result7 !== null) {
                                    result6.push(result7);
                                    result7 = parse_WS();
                                  }
                                  if (result6 !== null) {
                                    if (input.charCodeAt(pos) === 73) {
                                      result7 = "I";
                                      pos++;
                                    } else {
                                      result7 = null;
                                      if (reportFailures === 0) {
                                        matchFailed("\"I\"");
                                      }
                                    }
                                    if (result7 === null) {
                                      if (input.charCodeAt(pos) === 105) {
                                        result7 = "i";
                                        pos++;
                                      } else {
                                        result7 = null;
                                        if (reportFailures === 0) {
                                          matchFailed("\"i\"");
                                        }
                                      }
                                    }
                                    if (result7 !== null) {
                                      if (input.charCodeAt(pos) === 78) {
                                        result8 = "N";
                                        pos++;
                                      } else {
                                        result8 = null;
                                        if (reportFailures === 0) {
                                          matchFailed("\"N\"");
                                        }
                                      }
                                      if (result8 === null) {
                                        if (input.charCodeAt(pos) === 110) {
                                          result8 = "n";
                                          pos++;
                                        } else {
                                          result8 = null;
                                          if (reportFailures === 0) {
                                            matchFailed("\"n\"");
                                          }
                                        }
                                      }
                                      if (result8 !== null) {
                                        result9 = [];
                                        result10 = parse_WS();
                                        while (result10 !== null) {
                                          result9.push(result10);
                                          result10 = parse_WS();
                                        }
                                        if (result9 !== null) {
                                          result10 = parse_ExpressionList();
                                          if (result10 !== null) {
                                            result2 = [result2, result3, result4, result5, result6, result7, result8, result9, result10];
                                          } else {
                                            result2 = null;
                                            pos = pos2;
                                          }
                                        } else {
                                          result2 = null;
                                          pos = pos2;
                                        }
                                      } else {
                                        result2 = null;
                                        pos = pos2;
                                      }
                                    } else {
                                      result2 = null;
                                      pos = pos2;
                                    }
                                  } else {
                                    result2 = null;
                                    pos = pos2;
                                  }
                                } else {
                                  result2 = null;
                                  pos = pos2;
                                }
                              } else {
                                result2 = null;
                                pos = pos2;
                              }
                            } else {
                              result2 = null;
                              pos = pos2;
                            }
                          } else {
                            result2 = null;
                            pos = pos2;
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
            while (result2 !== null) {
              result1.push(result2);
              pos2 = pos;
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                if (input.charCodeAt(pos) === 61) {
                  result3 = "=";
                  pos++;
                } else {
                  result3 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"=\"");
                  }
                }
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    result5 = parse_AdditiveExpression();
                    if (result5 !== null) {
                      result2 = [result2, result3, result4, result5];
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
              if (result2 === null) {
                pos2 = pos;
                result2 = [];
                result3 = parse_WS();
                while (result3 !== null) {
                  result2.push(result3);
                  result3 = parse_WS();
                }
                if (result2 !== null) {
                  if (input.substr(pos, 2) === "!=") {
                    result3 = "!=";
                    pos += 2;
                  } else {
                    result3 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"!=\"");
                    }
                  }
                  if (result3 !== null) {
                    result4 = [];
                    result5 = parse_WS();
                    while (result5 !== null) {
                      result4.push(result5);
                      result5 = parse_WS();
                    }
                    if (result4 !== null) {
                      result5 = parse_AdditiveExpression();
                      if (result5 !== null) {
                        result2 = [result2, result3, result4, result5];
                      } else {
                        result2 = null;
                        pos = pos2;
                      }
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
                if (result2 === null) {
                  pos2 = pos;
                  result2 = [];
                  result3 = parse_WS();
                  while (result3 !== null) {
                    result2.push(result3);
                    result3 = parse_WS();
                  }
                  if (result2 !== null) {
                    if (input.charCodeAt(pos) === 60) {
                      result3 = "<";
                      pos++;
                    } else {
                      result3 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"<\"");
                      }
                    }
                    if (result3 !== null) {
                      result4 = [];
                      result5 = parse_WS();
                      while (result5 !== null) {
                        result4.push(result5);
                        result5 = parse_WS();
                      }
                      if (result4 !== null) {
                        result5 = parse_AdditiveExpression();
                        if (result5 !== null) {
                          result2 = [result2, result3, result4, result5];
                        } else {
                          result2 = null;
                          pos = pos2;
                        }
                      } else {
                        result2 = null;
                        pos = pos2;
                      }
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                  if (result2 === null) {
                    pos2 = pos;
                    result2 = [];
                    result3 = parse_WS();
                    while (result3 !== null) {
                      result2.push(result3);
                      result3 = parse_WS();
                    }
                    if (result2 !== null) {
                      if (input.charCodeAt(pos) === 62) {
                        result3 = ">";
                        pos++;
                      } else {
                        result3 = null;
                        if (reportFailures === 0) {
                          matchFailed("\">\"");
                        }
                      }
                      if (result3 !== null) {
                        result4 = [];
                        result5 = parse_WS();
                        while (result5 !== null) {
                          result4.push(result5);
                          result5 = parse_WS();
                        }
                        if (result4 !== null) {
                          result5 = parse_AdditiveExpression();
                          if (result5 !== null) {
                            result2 = [result2, result3, result4, result5];
                          } else {
                            result2 = null;
                            pos = pos2;
                          }
                        } else {
                          result2 = null;
                          pos = pos2;
                        }
                      } else {
                        result2 = null;
                        pos = pos2;
                      }
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                    if (result2 === null) {
                      pos2 = pos;
                      result2 = [];
                      result3 = parse_WS();
                      while (result3 !== null) {
                        result2.push(result3);
                        result3 = parse_WS();
                      }
                      if (result2 !== null) {
                        if (input.substr(pos, 2) === "<=") {
                          result3 = "<=";
                          pos += 2;
                        } else {
                          result3 = null;
                          if (reportFailures === 0) {
                            matchFailed("\"<=\"");
                          }
                        }
                        if (result3 !== null) {
                          result4 = [];
                          result5 = parse_WS();
                          while (result5 !== null) {
                            result4.push(result5);
                            result5 = parse_WS();
                          }
                          if (result4 !== null) {
                            result5 = parse_AdditiveExpression();
                            if (result5 !== null) {
                              result2 = [result2, result3, result4, result5];
                            } else {
                              result2 = null;
                              pos = pos2;
                            }
                          } else {
                            result2 = null;
                            pos = pos2;
                          }
                        } else {
                          result2 = null;
                          pos = pos2;
                        }
                      } else {
                        result2 = null;
                        pos = pos2;
                      }
                      if (result2 === null) {
                        pos2 = pos;
                        result2 = [];
                        result3 = parse_WS();
                        while (result3 !== null) {
                          result2.push(result3);
                          result3 = parse_WS();
                        }
                        if (result2 !== null) {
                          if (input.substr(pos, 2) === ">=") {
                            result3 = ">=";
                            pos += 2;
                          } else {
                            result3 = null;
                            if (reportFailures === 0) {
                              matchFailed("\">=\"");
                            }
                          }
                          if (result3 !== null) {
                            result4 = [];
                            result5 = parse_WS();
                            while (result5 !== null) {
                              result4.push(result5);
                              result5 = parse_WS();
                            }
                            if (result4 !== null) {
                              result5 = parse_AdditiveExpression();
                              if (result5 !== null) {
                                result2 = [result2, result3, result4, result5];
                              } else {
                                result2 = null;
                                pos = pos2;
                              }
                            } else {
                              result2 = null;
                              pos = pos2;
                            }
                          } else {
                            result2 = null;
                            pos = pos2;
                          }
                        } else {
                          result2 = null;
                          pos = pos2;
                        }
                        if (result2 === null) {
                          pos2 = pos;
                          result2 = [];
                          result3 = parse_WS();
                          while (result3 !== null) {
                            result2.push(result3);
                            result3 = parse_WS();
                          }
                          if (result2 !== null) {
                            if (input.charCodeAt(pos) === 73) {
                              result3 = "I";
                              pos++;
                            } else {
                              result3 = null;
                              if (reportFailures === 0) {
                                matchFailed("\"I\"");
                              }
                            }
                            if (result3 === null) {
                              if (input.charCodeAt(pos) === 105) {
                                result3 = "i";
                                pos++;
                              } else {
                                result3 = null;
                                if (reportFailures === 0) {
                                  matchFailed("\"i\"");
                                }
                              }
                            }
                            if (result3 !== null) {
                              if (input.charCodeAt(pos) === 78) {
                                result4 = "N";
                                pos++;
                              } else {
                                result4 = null;
                                if (reportFailures === 0) {
                                  matchFailed("\"N\"");
                                }
                              }
                              if (result4 === null) {
                                if (input.charCodeAt(pos) === 110) {
                                  result4 = "n";
                                  pos++;
                                } else {
                                  result4 = null;
                                  if (reportFailures === 0) {
                                    matchFailed("\"n\"");
                                  }
                                }
                              }
                              if (result4 !== null) {
                                result5 = [];
                                result6 = parse_WS();
                                while (result6 !== null) {
                                  result5.push(result6);
                                  result6 = parse_WS();
                                }
                                if (result5 !== null) {
                                  result6 = parse_ExpressionList();
                                  if (result6 !== null) {
                                    result2 = [result2, result3, result4, result5, result6];
                                  } else {
                                    result2 = null;
                                    pos = pos2;
                                  }
                                } else {
                                  result2 = null;
                                  pos = pos2;
                                }
                              } else {
                                result2 = null;
                                pos = pos2;
                              }
                            } else {
                              result2 = null;
                              pos = pos2;
                            }
                          } else {
                            result2 = null;
                            pos = pos2;
                          }
                          if (result2 === null) {
                            pos2 = pos;
                            result2 = [];
                            result3 = parse_WS();
                            while (result3 !== null) {
                              result2.push(result3);
                              result3 = parse_WS();
                            }
                            if (result2 !== null) {
                              if (input.charCodeAt(pos) === 78) {
                                result3 = "N";
                                pos++;
                              } else {
                                result3 = null;
                                if (reportFailures === 0) {
                                  matchFailed("\"N\"");
                                }
                              }
                              if (result3 === null) {
                                if (input.charCodeAt(pos) === 110) {
                                  result3 = "n";
                                  pos++;
                                } else {
                                  result3 = null;
                                  if (reportFailures === 0) {
                                    matchFailed("\"n\"");
                                  }
                                }
                              }
                              if (result3 !== null) {
                                if (input.charCodeAt(pos) === 79) {
                                  result4 = "O";
                                  pos++;
                                } else {
                                  result4 = null;
                                  if (reportFailures === 0) {
                                    matchFailed("\"O\"");
                                  }
                                }
                                if (result4 === null) {
                                  if (input.charCodeAt(pos) === 111) {
                                    result4 = "o";
                                    pos++;
                                  } else {
                                    result4 = null;
                                    if (reportFailures === 0) {
                                      matchFailed("\"o\"");
                                    }
                                  }
                                }
                                if (result4 !== null) {
                                  if (input.charCodeAt(pos) === 84) {
                                    result5 = "T";
                                    pos++;
                                  } else {
                                    result5 = null;
                                    if (reportFailures === 0) {
                                      matchFailed("\"T\"");
                                    }
                                  }
                                  if (result5 === null) {
                                    if (input.charCodeAt(pos) === 116) {
                                      result5 = "t";
                                      pos++;
                                    } else {
                                      result5 = null;
                                      if (reportFailures === 0) {
                                        matchFailed("\"t\"");
                                      }
                                    }
                                  }
                                  if (result5 !== null) {
                                    result6 = [];
                                    result7 = parse_WS();
                                    while (result7 !== null) {
                                      result6.push(result7);
                                      result7 = parse_WS();
                                    }
                                    if (result6 !== null) {
                                      if (input.charCodeAt(pos) === 73) {
                                        result7 = "I";
                                        pos++;
                                      } else {
                                        result7 = null;
                                        if (reportFailures === 0) {
                                          matchFailed("\"I\"");
                                        }
                                      }
                                      if (result7 === null) {
                                        if (input.charCodeAt(pos) === 105) {
                                          result7 = "i";
                                          pos++;
                                        } else {
                                          result7 = null;
                                          if (reportFailures === 0) {
                                            matchFailed("\"i\"");
                                          }
                                        }
                                      }
                                      if (result7 !== null) {
                                        if (input.charCodeAt(pos) === 78) {
                                          result8 = "N";
                                          pos++;
                                        } else {
                                          result8 = null;
                                          if (reportFailures === 0) {
                                            matchFailed("\"N\"");
                                          }
                                        }
                                        if (result8 === null) {
                                          if (input.charCodeAt(pos) === 110) {
                                            result8 = "n";
                                            pos++;
                                          } else {
                                            result8 = null;
                                            if (reportFailures === 0) {
                                              matchFailed("\"n\"");
                                            }
                                          }
                                        }
                                        if (result8 !== null) {
                                          result9 = [];
                                          result10 = parse_WS();
                                          while (result10 !== null) {
                                            result9.push(result10);
                                            result10 = parse_WS();
                                          }
                                          if (result9 !== null) {
                                            result10 = parse_ExpressionList();
                                            if (result10 !== null) {
                                              result2 = [result2, result3, result4, result5, result6, result7, result8, result9, result10];
                                            } else {
                                              result2 = null;
                                              pos = pos2;
                                            }
                                          } else {
                                            result2 = null;
                                            pos = pos2;
                                          }
                                        } else {
                                          result2 = null;
                                          pos = pos2;
                                        }
                                      } else {
                                        result2 = null;
                                        pos = pos2;
                                      }
                                    } else {
                                      result2 = null;
                                      pos = pos2;
                                    }
                                  } else {
                                    result2 = null;
                                    pos = pos2;
                                  }
                                } else {
                                  result2 = null;
                                  pos = pos2;
                                }
                              } else {
                                result2 = null;
                                pos = pos2;
                              }
                            } else {
                              result2 = null;
                              pos = pos2;
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, op1, op2) {
                if(op2.length === 0) {
                    return op1;
                } else if(op2[0][1] === 'i' || op2[0][1] === 'I' || op2[0][1] === 'n' || op2[0][1] === 'N'){
                  var exp = {};
          
                  if(op2[0][1] === 'i' || op2[0][1] === 'I') {
                    var operator = "=";
                    exp.expressionType = "conditionalor"         
                  } else {
                    var operator = "!=";
                    exp.expressionType = "conditionaland"         
                  }
                  var lop = op1;
                  var rops = []
                  for(var opi=0; opi<op2[0].length; opi++) {
                    if(op2[0][opi].token ==="args") {
                      rops = op2[0][opi].value;
                      break;
                    }
                  }       
          
                  exp.token = "expression";
                  exp.operands = [];
                  for(var i=0; i<rops.length; i++) {
                    var nextOperand = {};
                    nextOperand.token = "expression";
                    nextOperand.expressionType = "relationalexpression";
                    nextOperand.operator = operator;
                    nextOperand.op1 = lop;
                    nextOperand.op2 = rops[i];
          
                    exp.operands.push(nextOperand);
                  }       
                  return exp;
                } else {
                  var exp = {};
                  exp.expressionType = "relationalexpression"
                  exp.operator = op2[0][1];
                  exp.op1 = op1;
                  exp.op2 = op2[0][3];
                  exp.token = "expression";
          
                  return exp;
                }
            })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[99] RelationalExpression");
          }
          return result0;
        }
        
        function parse_AdditiveExpression() {
          var result0, result1, result2, result3, result4, result5, result6;
          var pos0, pos1, pos2, pos3;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_MultiplicativeExpression();
          if (result0 !== null) {
            result1 = [];
            pos2 = pos;
            result2 = [];
            result3 = parse_WS();
            while (result3 !== null) {
              result2.push(result3);
              result3 = parse_WS();
            }
            if (result2 !== null) {
              if (input.charCodeAt(pos) === 43) {
                result3 = "+";
                pos++;
              } else {
                result3 = null;
                if (reportFailures === 0) {
                  matchFailed("\"+\"");
                }
              }
              if (result3 !== null) {
                result4 = [];
                result5 = parse_WS();
                while (result5 !== null) {
                  result4.push(result5);
                  result5 = parse_WS();
                }
                if (result4 !== null) {
                  result5 = parse_MultiplicativeExpression();
                  if (result5 !== null) {
                    result2 = [result2, result3, result4, result5];
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
            } else {
              result2 = null;
              pos = pos2;
            }
            if (result2 === null) {
              pos2 = pos;
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                if (input.charCodeAt(pos) === 45) {
                  result3 = "-";
                  pos++;
                } else {
                  result3 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"-\"");
                  }
                }
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    result5 = parse_MultiplicativeExpression();
                    if (result5 !== null) {
                      result2 = [result2, result3, result4, result5];
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
              if (result2 === null) {
                pos2 = pos;
                result2 = parse_NumericLiteralNegative();
                if (result2 === null) {
                  result2 = parse_NumericLiteralNegative();
                }
                if (result2 !== null) {
                  pos3 = pos;
                  result3 = [];
                  result4 = parse_WS();
                  while (result4 !== null) {
                    result3.push(result4);
                    result4 = parse_WS();
                  }
                  if (result3 !== null) {
                    if (input.charCodeAt(pos) === 42) {
                      result4 = "*";
                      pos++;
                    } else {
                      result4 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"*\"");
                      }
                    }
                    if (result4 !== null) {
                      result5 = [];
                      result6 = parse_WS();
                      while (result6 !== null) {
                        result5.push(result6);
                        result6 = parse_WS();
                      }
                      if (result5 !== null) {
                        result6 = parse_UnaryExpression();
                        if (result6 !== null) {
                          result3 = [result3, result4, result5, result6];
                        } else {
                          result3 = null;
                          pos = pos3;
                        }
                      } else {
                        result3 = null;
                        pos = pos3;
                      }
                    } else {
                      result3 = null;
                      pos = pos3;
                    }
                  } else {
                    result3 = null;
                    pos = pos3;
                  }
                  if (result3 === null) {
                    pos3 = pos;
                    result3 = [];
                    result4 = parse_WS();
                    while (result4 !== null) {
                      result3.push(result4);
                      result4 = parse_WS();
                    }
                    if (result3 !== null) {
                      if (input.charCodeAt(pos) === 47) {
                        result4 = "/";
                        pos++;
                      } else {
                        result4 = null;
                        if (reportFailures === 0) {
                          matchFailed("\"/\"");
                        }
                      }
                      if (result4 !== null) {
                        result5 = [];
                        result6 = parse_WS();
                        while (result6 !== null) {
                          result5.push(result6);
                          result6 = parse_WS();
                        }
                        if (result5 !== null) {
                          result6 = parse_UnaryExpression();
                          if (result6 !== null) {
                            result3 = [result3, result4, result5, result6];
                          } else {
                            result3 = null;
                            pos = pos3;
                          }
                        } else {
                          result3 = null;
                          pos = pos3;
                        }
                      } else {
                        result3 = null;
                        pos = pos3;
                      }
                    } else {
                      result3 = null;
                      pos = pos3;
                    }
                  }
                  result3 = result3 !== null ? result3 : "";
                  if (result3 !== null) {
                    result2 = [result2, result3];
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              }
            }
            while (result2 !== null) {
              result1.push(result2);
              pos2 = pos;
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                if (input.charCodeAt(pos) === 43) {
                  result3 = "+";
                  pos++;
                } else {
                  result3 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"+\"");
                  }
                }
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    result5 = parse_MultiplicativeExpression();
                    if (result5 !== null) {
                      result2 = [result2, result3, result4, result5];
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
              if (result2 === null) {
                pos2 = pos;
                result2 = [];
                result3 = parse_WS();
                while (result3 !== null) {
                  result2.push(result3);
                  result3 = parse_WS();
                }
                if (result2 !== null) {
                  if (input.charCodeAt(pos) === 45) {
                    result3 = "-";
                    pos++;
                  } else {
                    result3 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"-\"");
                    }
                  }
                  if (result3 !== null) {
                    result4 = [];
                    result5 = parse_WS();
                    while (result5 !== null) {
                      result4.push(result5);
                      result5 = parse_WS();
                    }
                    if (result4 !== null) {
                      result5 = parse_MultiplicativeExpression();
                      if (result5 !== null) {
                        result2 = [result2, result3, result4, result5];
                      } else {
                        result2 = null;
                        pos = pos2;
                      }
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
                if (result2 === null) {
                  pos2 = pos;
                  result2 = parse_NumericLiteralNegative();
                  if (result2 === null) {
                    result2 = parse_NumericLiteralNegative();
                  }
                  if (result2 !== null) {
                    pos3 = pos;
                    result3 = [];
                    result4 = parse_WS();
                    while (result4 !== null) {
                      result3.push(result4);
                      result4 = parse_WS();
                    }
                    if (result3 !== null) {
                      if (input.charCodeAt(pos) === 42) {
                        result4 = "*";
                        pos++;
                      } else {
                        result4 = null;
                        if (reportFailures === 0) {
                          matchFailed("\"*\"");
                        }
                      }
                      if (result4 !== null) {
                        result5 = [];
                        result6 = parse_WS();
                        while (result6 !== null) {
                          result5.push(result6);
                          result6 = parse_WS();
                        }
                        if (result5 !== null) {
                          result6 = parse_UnaryExpression();
                          if (result6 !== null) {
                            result3 = [result3, result4, result5, result6];
                          } else {
                            result3 = null;
                            pos = pos3;
                          }
                        } else {
                          result3 = null;
                          pos = pos3;
                        }
                      } else {
                        result3 = null;
                        pos = pos3;
                      }
                    } else {
                      result3 = null;
                      pos = pos3;
                    }
                    if (result3 === null) {
                      pos3 = pos;
                      result3 = [];
                      result4 = parse_WS();
                      while (result4 !== null) {
                        result3.push(result4);
                        result4 = parse_WS();
                      }
                      if (result3 !== null) {
                        if (input.charCodeAt(pos) === 47) {
                          result4 = "/";
                          pos++;
                        } else {
                          result4 = null;
                          if (reportFailures === 0) {
                            matchFailed("\"/\"");
                          }
                        }
                        if (result4 !== null) {
                          result5 = [];
                          result6 = parse_WS();
                          while (result6 !== null) {
                            result5.push(result6);
                            result6 = parse_WS();
                          }
                          if (result5 !== null) {
                            result6 = parse_UnaryExpression();
                            if (result6 !== null) {
                              result3 = [result3, result4, result5, result6];
                            } else {
                              result3 = null;
                              pos = pos3;
                            }
                          } else {
                            result3 = null;
                            pos = pos3;
                          }
                        } else {
                          result3 = null;
                          pos = pos3;
                        }
                      } else {
                        result3 = null;
                        pos = pos3;
                      }
                    }
                    result3 = result3 !== null ? result3 : "";
                    if (result3 !== null) {
                      result2 = [result2, result3];
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                }
              }
            }
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, op1, ops) {
                if(ops.length === 0) {
                    return op1;
                }
          
                var ex = {};
                ex.token = 'expression';
                ex.expressionType = 'additiveexpression';
                ex.summand = op1;
                ex.summands = [];
          
                for(var i=0; i<ops.length; i++) {
                    var summand = ops[i];
                    var sum = {};
                    if(summand.length == 4 && typeof(summand[1]) === "string") {
                        sum.operator = summand[1];
                        sum.expression = summand[3];
                    } else {
                        var subexp = {}
                        var firstFactor = sum[0];
                        var operator = sum[1][1];
                        var secondFactor = sum[1][3];
                        var operator = null;
                        if(firstFactor.value < 0) {
                            sum.operator = '-';
                            firstFactor.value = - firstFactor.value;
                        } else {
                            sum.operator = '+';
                        }
                        subexp.token = 'expression';
                        subexp.expressionType = 'multiplicativeexpression';
                        subexp.operator = firstFactor;
                        subexp.factors = [{operator: operator, expression: secondFactor}];
          
                        sum.expression = subexp;
                    }
                    ex.summands.push(sum);
                }
          
                return ex;
          })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[101] AdditiveExpression");
          }
          return result0;
        }
        
        function parse_MultiplicativeExpression() {
          var result0, result1, result2, result3, result4, result5;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_UnaryExpression();
          if (result0 !== null) {
            result1 = [];
            pos2 = pos;
            result2 = [];
            result3 = parse_WS();
            while (result3 !== null) {
              result2.push(result3);
              result3 = parse_WS();
            }
            if (result2 !== null) {
              if (input.charCodeAt(pos) === 42) {
                result3 = "*";
                pos++;
              } else {
                result3 = null;
                if (reportFailures === 0) {
                  matchFailed("\"*\"");
                }
              }
              if (result3 !== null) {
                result4 = [];
                result5 = parse_WS();
                while (result5 !== null) {
                  result4.push(result5);
                  result5 = parse_WS();
                }
                if (result4 !== null) {
                  result5 = parse_UnaryExpression();
                  if (result5 !== null) {
                    result2 = [result2, result3, result4, result5];
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
            } else {
              result2 = null;
              pos = pos2;
            }
            if (result2 === null) {
              pos2 = pos;
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                if (input.charCodeAt(pos) === 47) {
                  result3 = "/";
                  pos++;
                } else {
                  result3 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"/\"");
                  }
                }
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    result5 = parse_UnaryExpression();
                    if (result5 !== null) {
                      result2 = [result2, result3, result4, result5];
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
            }
            while (result2 !== null) {
              result1.push(result2);
              pos2 = pos;
              result2 = [];
              result3 = parse_WS();
              while (result3 !== null) {
                result2.push(result3);
                result3 = parse_WS();
              }
              if (result2 !== null) {
                if (input.charCodeAt(pos) === 42) {
                  result3 = "*";
                  pos++;
                } else {
                  result3 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"*\"");
                  }
                }
                if (result3 !== null) {
                  result4 = [];
                  result5 = parse_WS();
                  while (result5 !== null) {
                    result4.push(result5);
                    result5 = parse_WS();
                  }
                  if (result4 !== null) {
                    result5 = parse_UnaryExpression();
                    if (result5 !== null) {
                      result2 = [result2, result3, result4, result5];
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              } else {
                result2 = null;
                pos = pos2;
              }
              if (result2 === null) {
                pos2 = pos;
                result2 = [];
                result3 = parse_WS();
                while (result3 !== null) {
                  result2.push(result3);
                  result3 = parse_WS();
                }
                if (result2 !== null) {
                  if (input.charCodeAt(pos) === 47) {
                    result3 = "/";
                    pos++;
                  } else {
                    result3 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"/\"");
                    }
                  }
                  if (result3 !== null) {
                    result4 = [];
                    result5 = parse_WS();
                    while (result5 !== null) {
                      result4.push(result5);
                      result5 = parse_WS();
                    }
                    if (result4 !== null) {
                      result5 = parse_UnaryExpression();
                      if (result5 !== null) {
                        result2 = [result2, result3, result4, result5];
                      } else {
                        result2 = null;
                        pos = pos2;
                      }
                    } else {
                      result2 = null;
                      pos = pos2;
                    }
                  } else {
                    result2 = null;
                    pos = pos2;
                  }
                } else {
                  result2 = null;
                  pos = pos2;
                }
              }
            }
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, exp, exps) {
                if(exps.length === 0) {
                    return exp;
                }
          
                var ex = {};
                ex.token = 'expression';
                ex.expressionType = 'multiplicativeexpression';
                ex.factor = exp;
                ex.factors = [];
                for(var i=0; i<exps.length; i++) {
                    var factor = exps[i];
                    var fact = {};
                    fact.operator = factor[1];
                    fact.expression = factor[3];
                    ex.factors.push(fact);
                }
          
                return ex;
          })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[102] MultiplicativeExpression");
          }
          return result0;
        }
        
        function parse_UnaryExpression() {
          var result0, result1, result2;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.charCodeAt(pos) === 33) {
            result0 = "!";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"!\"");
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = parse_PrimaryExpression();
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, e) {
                var ex = {};
                ex.token = 'expression';
                ex.expressionType = 'unaryexpression';
                ex.unaryexpression = "!";
                ex.expression = e;
          
                return ex;
            })(pos0, result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            pos1 = pos;
            if (input.charCodeAt(pos) === 43) {
              result0 = "+";
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"+\"");
              }
            }
            if (result0 !== null) {
              result1 = [];
              result2 = parse_WS();
              while (result2 !== null) {
                result1.push(result2);
                result2 = parse_WS();
              }
              if (result1 !== null) {
                result2 = parse_PrimaryExpression();
                if (result2 !== null) {
                  result0 = [result0, result1, result2];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
            if (result0 !== null) {
              result0 = (function(offset, v) {
                  var ex = {};
                  ex.token = 'expression';
                  ex.expressionType = 'unaryexpression';
                  ex.unaryexpression = "+";
                  ex.expression = v;
            
                  return ex;
              })(pos0, result0[2]);
            }
            if (result0 === null) {
              pos = pos0;
            }
            if (result0 === null) {
              pos0 = pos;
              pos1 = pos;
              if (input.charCodeAt(pos) === 45) {
                result0 = "-";
                pos++;
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("\"-\"");
                }
              }
              if (result0 !== null) {
                result1 = [];
                result2 = parse_WS();
                while (result2 !== null) {
                  result1.push(result2);
                  result2 = parse_WS();
                }
                if (result1 !== null) {
                  result2 = parse_PrimaryExpression();
                  if (result2 !== null) {
                    result0 = [result0, result1, result2];
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
              if (result0 !== null) {
                result0 = (function(offset, v) {
                    var ex = {};
                    ex.token = 'expression';
                    ex.expressionType = 'unaryexpression';
                    ex.unaryexpression = "-";
                    ex.expression = v;
              
                    return ex;
                })(pos0, result0[2]);
              }
              if (result0 === null) {
                pos = pos0;
              }
              if (result0 === null) {
                result0 = parse_PrimaryExpression();
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[103] UnaryExpression");
          }
          return result0;
        }
        
        function parse_PrimaryExpression() {
          var result0;
          var pos0;
          
          reportFailures++;
          result0 = parse_BrackettedExpression();
          if (result0 === null) {
            result0 = parse_BuiltInCall();
            if (result0 === null) {
              result0 = parse_IRIrefOrFunction();
              if (result0 === null) {
                pos0 = pos;
                result0 = parse_RDFLiteral();
                if (result0 !== null) {
                  result0 = (function(offset, v) {
                      var ex = {};
                      ex.token = 'expression';
                      ex.expressionType = 'atomic';
                      ex.primaryexpression = 'rdfliteral';
                      ex.value = v;
                
                      return ex;
                  })(pos0, result0);
                }
                if (result0 === null) {
                  pos = pos0;
                }
                if (result0 === null) {
                  pos0 = pos;
                  result0 = parse_NumericLiteral();
                  if (result0 !== null) {
                    result0 = (function(offset, v) {
                        var ex = {};
                        ex.token = 'expression';
                        ex.expressionType = 'atomic';
                        ex.primaryexpression = 'numericliteral';
                        ex.value = v;
                  
                        return ex;
                    })(pos0, result0);
                  }
                  if (result0 === null) {
                    pos = pos0;
                  }
                  if (result0 === null) {
                    pos0 = pos;
                    result0 = parse_BooleanLiteral();
                    if (result0 !== null) {
                      result0 = (function(offset, v) {
                          var ex = {};
                          ex.token = 'expression';
                          ex.expressionType = 'atomic';
                          ex.primaryexpression = 'booleanliteral';
                          ex.value = v;
                    
                          return ex;
                      })(pos0, result0);
                    }
                    if (result0 === null) {
                      pos = pos0;
                    }
                    if (result0 === null) {
                      result0 = parse_Aggregate();
                      if (result0 === null) {
                        pos0 = pos;
                        result0 = parse_Var();
                        if (result0 !== null) {
                          result0 = (function(offset, v) {
                              var ex = {};
                              ex.token = 'expression';
                              ex.expressionType = 'atomic';
                              ex.primaryexpression = 'var';
                              ex.value = v;
                        
                              return ex;
                          })(pos0, result0);
                        }
                        if (result0 === null) {
                          pos = pos0;
                        }
                      }
                    }
                  }
                }
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[104] PrimaryExpression");
          }
          return result0;
        }
        
        function parse_BrackettedExpression() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.charCodeAt(pos) === 40) {
            result0 = "(";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"(\"");
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = parse_ConditionalOrExpression();
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  if (input.charCodeAt(pos) === 41) {
                    result4 = ")";
                    pos++;
                  } else {
                    result4 = null;
                    if (reportFailures === 0) {
                      matchFailed("\")\"");
                    }
                  }
                  if (result4 !== null) {
                    result0 = [result0, result1, result2, result3, result4];
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, e) {
                return e;
          })(pos0, result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[105] BrackettedExpression");
          }
          return result0;
        }
        
        function parse_BuiltInCall() {
          var result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 3) === "STR") {
            result0 = "STR";
            pos += 3;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"STR\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 3) === "str") {
              result0 = "str";
              pos += 3;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"str\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              if (input.charCodeAt(pos) === 40) {
                result2 = "(";
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"(\"");
                }
              }
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result4 = parse_ConditionalOrExpression();
                  if (result4 !== null) {
                    result5 = [];
                    result6 = parse_WS();
                    while (result6 !== null) {
                      result5.push(result6);
                      result6 = parse_WS();
                    }
                    if (result5 !== null) {
                      if (input.charCodeAt(pos) === 41) {
                        result6 = ")";
                        pos++;
                      } else {
                        result6 = null;
                        if (reportFailures === 0) {
                          matchFailed("\")\"");
                        }
                      }
                      if (result6 !== null) {
                        result0 = [result0, result1, result2, result3, result4, result5, result6];
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, e) {
                var ex = {};
                ex.token = 'expression'
                ex.expressionType = 'builtincall'
                ex.builtincall = 'str'
                ex.args = [e]
          
                return ex;
            })(pos0, result0[4]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            pos1 = pos;
            if (input.substr(pos, 4) === "LANG") {
              result0 = "LANG";
              pos += 4;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"LANG\"");
              }
            }
            if (result0 === null) {
              if (input.substr(pos, 4) === "lang") {
                result0 = "lang";
                pos += 4;
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("\"lang\"");
                }
              }
            }
            if (result0 !== null) {
              result1 = [];
              result2 = parse_WS();
              while (result2 !== null) {
                result1.push(result2);
                result2 = parse_WS();
              }
              if (result1 !== null) {
                if (input.charCodeAt(pos) === 40) {
                  result2 = "(";
                  pos++;
                } else {
                  result2 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"(\"");
                  }
                }
                if (result2 !== null) {
                  result3 = [];
                  result4 = parse_WS();
                  while (result4 !== null) {
                    result3.push(result4);
                    result4 = parse_WS();
                  }
                  if (result3 !== null) {
                    result4 = parse_ConditionalOrExpression();
                    if (result4 !== null) {
                      result5 = [];
                      result6 = parse_WS();
                      while (result6 !== null) {
                        result5.push(result6);
                        result6 = parse_WS();
                      }
                      if (result5 !== null) {
                        if (input.charCodeAt(pos) === 41) {
                          result6 = ")";
                          pos++;
                        } else {
                          result6 = null;
                          if (reportFailures === 0) {
                            matchFailed("\")\"");
                          }
                        }
                        if (result6 !== null) {
                          result0 = [result0, result1, result2, result3, result4, result5, result6];
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
            if (result0 !== null) {
              result0 = (function(offset, e) {
                  var ex = {};
                  ex.token = 'expression'
                  ex.expressionType = 'builtincall'
                  ex.builtincall = 'lang'
                  ex.args = [e]
            
                  return ex;
            })(pos0, result0[4]);
            }
            if (result0 === null) {
              pos = pos0;
            }
            if (result0 === null) {
              pos0 = pos;
              pos1 = pos;
              if (input.substr(pos, 11) === "LANGMATCHES") {
                result0 = "LANGMATCHES";
                pos += 11;
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("\"LANGMATCHES\"");
                }
              }
              if (result0 === null) {
                if (input.substr(pos, 11) === "langmatches") {
                  result0 = "langmatches";
                  pos += 11;
                } else {
                  result0 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"langmatches\"");
                  }
                }
              }
              if (result0 !== null) {
                result1 = [];
                result2 = parse_WS();
                while (result2 !== null) {
                  result1.push(result2);
                  result2 = parse_WS();
                }
                if (result1 !== null) {
                  if (input.charCodeAt(pos) === 40) {
                    result2 = "(";
                    pos++;
                  } else {
                    result2 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"(\"");
                    }
                  }
                  if (result2 !== null) {
                    result3 = [];
                    result4 = parse_WS();
                    while (result4 !== null) {
                      result3.push(result4);
                      result4 = parse_WS();
                    }
                    if (result3 !== null) {
                      result4 = parse_ConditionalOrExpression();
                      if (result4 !== null) {
                        result5 = [];
                        result6 = parse_WS();
                        while (result6 !== null) {
                          result5.push(result6);
                          result6 = parse_WS();
                        }
                        if (result5 !== null) {
                          if (input.charCodeAt(pos) === 44) {
                            result6 = ",";
                            pos++;
                          } else {
                            result6 = null;
                            if (reportFailures === 0) {
                              matchFailed("\",\"");
                            }
                          }
                          if (result6 !== null) {
                            result7 = [];
                            result8 = parse_WS();
                            while (result8 !== null) {
                              result7.push(result8);
                              result8 = parse_WS();
                            }
                            if (result7 !== null) {
                              result8 = parse_ConditionalOrExpression();
                              if (result8 !== null) {
                                result9 = [];
                                result10 = parse_WS();
                                while (result10 !== null) {
                                  result9.push(result10);
                                  result10 = parse_WS();
                                }
                                if (result9 !== null) {
                                  if (input.charCodeAt(pos) === 41) {
                                    result10 = ")";
                                    pos++;
                                  } else {
                                    result10 = null;
                                    if (reportFailures === 0) {
                                      matchFailed("\")\"");
                                    }
                                  }
                                  if (result10 !== null) {
                                    result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10];
                                  } else {
                                    result0 = null;
                                    pos = pos1;
                                  }
                                } else {
                                  result0 = null;
                                  pos = pos1;
                                }
                              } else {
                                result0 = null;
                                pos = pos1;
                              }
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
              if (result0 !== null) {
                result0 = (function(offset, e1, e2) {
                    var ex = {};
                    ex.token = 'expression'
                    ex.expressionType = 'builtincall'
                    ex.builtincall = 'langmatches'
                    ex.args = [e1,e2]
              
                    return ex;
              })(pos0, result0[4], result0[8]);
              }
              if (result0 === null) {
                pos = pos0;
              }
              if (result0 === null) {
                pos0 = pos;
                pos1 = pos;
                if (input.substr(pos, 8) === "DATATYPE") {
                  result0 = "DATATYPE";
                  pos += 8;
                } else {
                  result0 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"DATATYPE\"");
                  }
                }
                if (result0 === null) {
                  if (input.substr(pos, 8) === "datatype") {
                    result0 = "datatype";
                    pos += 8;
                  } else {
                    result0 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"datatype\"");
                    }
                  }
                }
                if (result0 !== null) {
                  result1 = [];
                  result2 = parse_WS();
                  while (result2 !== null) {
                    result1.push(result2);
                    result2 = parse_WS();
                  }
                  if (result1 !== null) {
                    if (input.charCodeAt(pos) === 40) {
                      result2 = "(";
                      pos++;
                    } else {
                      result2 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"(\"");
                      }
                    }
                    if (result2 !== null) {
                      result3 = [];
                      result4 = parse_WS();
                      while (result4 !== null) {
                        result3.push(result4);
                        result4 = parse_WS();
                      }
                      if (result3 !== null) {
                        result4 = parse_ConditionalOrExpression();
                        if (result4 !== null) {
                          result5 = [];
                          result6 = parse_WS();
                          while (result6 !== null) {
                            result5.push(result6);
                            result6 = parse_WS();
                          }
                          if (result5 !== null) {
                            if (input.charCodeAt(pos) === 41) {
                              result6 = ")";
                              pos++;
                            } else {
                              result6 = null;
                              if (reportFailures === 0) {
                                matchFailed("\")\"");
                              }
                            }
                            if (result6 !== null) {
                              result0 = [result0, result1, result2, result3, result4, result5, result6];
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
                if (result0 !== null) {
                  result0 = (function(offset, e) {
                      var ex = {};
                      ex.token = 'expression'
                      ex.expressionType = 'builtincall'
                      ex.builtincall = 'datatype'
                      ex.args = [e]
                
                      return ex;
                })(pos0, result0[4]);
                }
                if (result0 === null) {
                  pos = pos0;
                }
                if (result0 === null) {
                  pos0 = pos;
                  pos1 = pos;
                  if (input.substr(pos, 5) === "BOUND") {
                    result0 = "BOUND";
                    pos += 5;
                  } else {
                    result0 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"BOUND\"");
                    }
                  }
                  if (result0 === null) {
                    if (input.substr(pos, 5) === "bound") {
                      result0 = "bound";
                      pos += 5;
                    } else {
                      result0 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"bound\"");
                      }
                    }
                  }
                  if (result0 !== null) {
                    result1 = [];
                    result2 = parse_WS();
                    while (result2 !== null) {
                      result1.push(result2);
                      result2 = parse_WS();
                    }
                    if (result1 !== null) {
                      if (input.charCodeAt(pos) === 40) {
                        result2 = "(";
                        pos++;
                      } else {
                        result2 = null;
                        if (reportFailures === 0) {
                          matchFailed("\"(\"");
                        }
                      }
                      if (result2 !== null) {
                        result3 = [];
                        result4 = parse_WS();
                        while (result4 !== null) {
                          result3.push(result4);
                          result4 = parse_WS();
                        }
                        if (result3 !== null) {
                          result4 = parse_Var();
                          if (result4 !== null) {
                            result5 = [];
                            result6 = parse_WS();
                            while (result6 !== null) {
                              result5.push(result6);
                              result6 = parse_WS();
                            }
                            if (result5 !== null) {
                              if (input.charCodeAt(pos) === 41) {
                                result6 = ")";
                                pos++;
                              } else {
                                result6 = null;
                                if (reportFailures === 0) {
                                  matchFailed("\")\"");
                                }
                              }
                              if (result6 !== null) {
                                result0 = [result0, result1, result2, result3, result4, result5, result6];
                              } else {
                                result0 = null;
                                pos = pos1;
                              }
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                  if (result0 !== null) {
                    result0 = (function(offset, v) {
                        var ex = {};
                        ex.token = 'expression'
                        ex.expressionType = 'builtincall'
                        ex.builtincall = 'bound'
                        ex.args = [v]
                  
                        return ex;
                  })(pos0, result0[4]);
                  }
                  if (result0 === null) {
                    pos = pos0;
                  }
                  if (result0 === null) {
                    pos0 = pos;
                    pos1 = pos;
                    if (input.substr(pos, 3) === "IRI") {
                      result0 = "IRI";
                      pos += 3;
                    } else {
                      result0 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"IRI\"");
                      }
                    }
                    if (result0 === null) {
                      if (input.substr(pos, 3) === "iri") {
                        result0 = "iri";
                        pos += 3;
                      } else {
                        result0 = null;
                        if (reportFailures === 0) {
                          matchFailed("\"iri\"");
                        }
                      }
                    }
                    if (result0 !== null) {
                      result1 = [];
                      result2 = parse_WS();
                      while (result2 !== null) {
                        result1.push(result2);
                        result2 = parse_WS();
                      }
                      if (result1 !== null) {
                        if (input.charCodeAt(pos) === 40) {
                          result2 = "(";
                          pos++;
                        } else {
                          result2 = null;
                          if (reportFailures === 0) {
                            matchFailed("\"(\"");
                          }
                        }
                        if (result2 !== null) {
                          result3 = [];
                          result4 = parse_WS();
                          while (result4 !== null) {
                            result3.push(result4);
                            result4 = parse_WS();
                          }
                          if (result3 !== null) {
                            result4 = parse_ConditionalOrExpression();
                            if (result4 !== null) {
                              result5 = [];
                              result6 = parse_WS();
                              while (result6 !== null) {
                                result5.push(result6);
                                result6 = parse_WS();
                              }
                              if (result5 !== null) {
                                if (input.charCodeAt(pos) === 41) {
                                  result6 = ")";
                                  pos++;
                                } else {
                                  result6 = null;
                                  if (reportFailures === 0) {
                                    matchFailed("\")\"");
                                  }
                                }
                                if (result6 !== null) {
                                  result0 = [result0, result1, result2, result3, result4, result5, result6];
                                } else {
                                  result0 = null;
                                  pos = pos1;
                                }
                              } else {
                                result0 = null;
                                pos = pos1;
                              }
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                    if (result0 !== null) {
                      result0 = (function(offset, e) {
                          var ex = {};
                          ex.token = 'expression';
                          ex.expressionType = 'builtincall';
                          ex.builtincall = 'iri'
                          ex.args = [e];
                    
                          return ex;
                    })(pos0, result0[4]);
                    }
                    if (result0 === null) {
                      pos = pos0;
                    }
                    if (result0 === null) {
                      pos0 = pos;
                      pos1 = pos;
                      if (input.substr(pos, 3) === "URI") {
                        result0 = "URI";
                        pos += 3;
                      } else {
                        result0 = null;
                        if (reportFailures === 0) {
                          matchFailed("\"URI\"");
                        }
                      }
                      if (result0 === null) {
                        if (input.substr(pos, 3) === "uri") {
                          result0 = "uri";
                          pos += 3;
                        } else {
                          result0 = null;
                          if (reportFailures === 0) {
                            matchFailed("\"uri\"");
                          }
                        }
                      }
                      if (result0 !== null) {
                        result1 = [];
                        result2 = parse_WS();
                        while (result2 !== null) {
                          result1.push(result2);
                          result2 = parse_WS();
                        }
                        if (result1 !== null) {
                          if (input.charCodeAt(pos) === 40) {
                            result2 = "(";
                            pos++;
                          } else {
                            result2 = null;
                            if (reportFailures === 0) {
                              matchFailed("\"(\"");
                            }
                          }
                          if (result2 !== null) {
                            result3 = [];
                            result4 = parse_WS();
                            while (result4 !== null) {
                              result3.push(result4);
                              result4 = parse_WS();
                            }
                            if (result3 !== null) {
                              result4 = parse_ConditionalOrExpression();
                              if (result4 !== null) {
                                result5 = [];
                                result6 = parse_WS();
                                while (result6 !== null) {
                                  result5.push(result6);
                                  result6 = parse_WS();
                                }
                                if (result5 !== null) {
                                  if (input.charCodeAt(pos) === 41) {
                                    result6 = ")";
                                    pos++;
                                  } else {
                                    result6 = null;
                                    if (reportFailures === 0) {
                                      matchFailed("\")\"");
                                    }
                                  }
                                  if (result6 !== null) {
                                    result0 = [result0, result1, result2, result3, result4, result5, result6];
                                  } else {
                                    result0 = null;
                                    pos = pos1;
                                  }
                                } else {
                                  result0 = null;
                                  pos = pos1;
                                }
                              } else {
                                result0 = null;
                                pos = pos1;
                              }
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                      if (result0 !== null) {
                        result0 = (function(offset, e) {
                            var ex = {};
                            ex.token = 'expression';
                            ex.expressionType = 'builtincall';
                            ex.builtincall = 'uri'
                            ex.args = [e];
                      
                            return ex;
                      })(pos0, result0[4]);
                      }
                      if (result0 === null) {
                        pos = pos0;
                      }
                      if (result0 === null) {
                        pos0 = pos;
                        pos1 = pos;
                        if (input.substr(pos, 5) === "BNODE") {
                          result0 = "BNODE";
                          pos += 5;
                        } else {
                          result0 = null;
                          if (reportFailures === 0) {
                            matchFailed("\"BNODE\"");
                          }
                        }
                        if (result0 === null) {
                          if (input.substr(pos, 5) === "bnode") {
                            result0 = "bnode";
                            pos += 5;
                          } else {
                            result0 = null;
                            if (reportFailures === 0) {
                              matchFailed("\"bnode\"");
                            }
                          }
                        }
                        if (result0 !== null) {
                          result1 = [];
                          result2 = parse_WS();
                          while (result2 !== null) {
                            result1.push(result2);
                            result2 = parse_WS();
                          }
                          if (result1 !== null) {
                            pos2 = pos;
                            if (input.charCodeAt(pos) === 40) {
                              result2 = "(";
                              pos++;
                            } else {
                              result2 = null;
                              if (reportFailures === 0) {
                                matchFailed("\"(\"");
                              }
                            }
                            if (result2 !== null) {
                              result3 = [];
                              result4 = parse_WS();
                              while (result4 !== null) {
                                result3.push(result4);
                                result4 = parse_WS();
                              }
                              if (result3 !== null) {
                                result4 = parse_ConditionalOrExpression();
                                if (result4 !== null) {
                                  result5 = [];
                                  result6 = parse_WS();
                                  while (result6 !== null) {
                                    result5.push(result6);
                                    result6 = parse_WS();
                                  }
                                  if (result5 !== null) {
                                    if (input.charCodeAt(pos) === 41) {
                                      result6 = ")";
                                      pos++;
                                    } else {
                                      result6 = null;
                                      if (reportFailures === 0) {
                                        matchFailed("\")\"");
                                      }
                                    }
                                    if (result6 !== null) {
                                      result2 = [result2, result3, result4, result5, result6];
                                    } else {
                                      result2 = null;
                                      pos = pos2;
                                    }
                                  } else {
                                    result2 = null;
                                    pos = pos2;
                                  }
                                } else {
                                  result2 = null;
                                  pos = pos2;
                                }
                              } else {
                                result2 = null;
                                pos = pos2;
                              }
                            } else {
                              result2 = null;
                              pos = pos2;
                            }
                            if (result2 === null) {
                              result2 = parse_NIL();
                            }
                            if (result2 !== null) {
                              result0 = [result0, result1, result2];
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                        if (result0 !== null) {
                          result0 = (function(offset, arg) {
                              var ex = {};
                              ex.token = 'expression';
                              ex.expressionType = 'builtincall';
                              ex.builtincall = 'bnode';
                              if(arg.length === 5) {
                                  ex.args = [arg[2]];
                              } else {
                                  ex.args = null;
                              }
                        
                              return ex;
                        })(pos0, result0[2]);
                        }
                        if (result0 === null) {
                          pos = pos0;
                        }
                        if (result0 === null) {
                          pos0 = pos;
                          pos1 = pos;
                          if (input.substr(pos, 8) === "COALESCE") {
                            result0 = "COALESCE";
                            pos += 8;
                          } else {
                            result0 = null;
                            if (reportFailures === 0) {
                              matchFailed("\"COALESCE\"");
                            }
                          }
                          if (result0 === null) {
                            if (input.substr(pos, 8) === "coalesce") {
                              result0 = "coalesce";
                              pos += 8;
                            } else {
                              result0 = null;
                              if (reportFailures === 0) {
                                matchFailed("\"coalesce\"");
                              }
                            }
                          }
                          if (result0 !== null) {
                            result1 = [];
                            result2 = parse_WS();
                            while (result2 !== null) {
                              result1.push(result2);
                              result2 = parse_WS();
                            }
                            if (result1 !== null) {
                              result2 = parse_ExpressionList();
                              if (result2 !== null) {
                                result0 = [result0, result1, result2];
                              } else {
                                result0 = null;
                                pos = pos1;
                              }
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                          if (result0 !== null) {
                            result0 = (function(offset, args) {
                                var ex = {};
                                ex.token = 'expression';
                                ex.expressionType = 'builtincall';
                                ex.builtincall = 'coalesce';
                                ex.args = args;
                          
                                return ex;    
                          })(pos0, result0[2]);
                          }
                          if (result0 === null) {
                            pos = pos0;
                          }
                          if (result0 === null) {
                            pos0 = pos;
                            pos1 = pos;
                            if (input.substr(pos, 2) === "IF") {
                              result0 = "IF";
                              pos += 2;
                            } else {
                              result0 = null;
                              if (reportFailures === 0) {
                                matchFailed("\"IF\"");
                              }
                            }
                            if (result0 === null) {
                              if (input.substr(pos, 2) === "if") {
                                result0 = "if";
                                pos += 2;
                              } else {
                                result0 = null;
                                if (reportFailures === 0) {
                                  matchFailed("\"if\"");
                                }
                              }
                            }
                            if (result0 !== null) {
                              result1 = [];
                              result2 = parse_WS();
                              while (result2 !== null) {
                                result1.push(result2);
                                result2 = parse_WS();
                              }
                              if (result1 !== null) {
                                if (input.charCodeAt(pos) === 40) {
                                  result2 = "(";
                                  pos++;
                                } else {
                                  result2 = null;
                                  if (reportFailures === 0) {
                                    matchFailed("\"(\"");
                                  }
                                }
                                if (result2 !== null) {
                                  result3 = [];
                                  result4 = parse_WS();
                                  while (result4 !== null) {
                                    result3.push(result4);
                                    result4 = parse_WS();
                                  }
                                  if (result3 !== null) {
                                    result4 = parse_ConditionalOrExpression();
                                    if (result4 !== null) {
                                      result5 = [];
                                      result6 = parse_WS();
                                      while (result6 !== null) {
                                        result5.push(result6);
                                        result6 = parse_WS();
                                      }
                                      if (result5 !== null) {
                                        if (input.charCodeAt(pos) === 44) {
                                          result6 = ",";
                                          pos++;
                                        } else {
                                          result6 = null;
                                          if (reportFailures === 0) {
                                            matchFailed("\",\"");
                                          }
                                        }
                                        if (result6 !== null) {
                                          result7 = [];
                                          result8 = parse_WS();
                                          while (result8 !== null) {
                                            result7.push(result8);
                                            result8 = parse_WS();
                                          }
                                          if (result7 !== null) {
                                            result8 = parse_ConditionalOrExpression();
                                            if (result8 !== null) {
                                              result9 = [];
                                              result10 = parse_WS();
                                              while (result10 !== null) {
                                                result9.push(result10);
                                                result10 = parse_WS();
                                              }
                                              if (result9 !== null) {
                                                if (input.charCodeAt(pos) === 44) {
                                                  result10 = ",";
                                                  pos++;
                                                } else {
                                                  result10 = null;
                                                  if (reportFailures === 0) {
                                                    matchFailed("\",\"");
                                                  }
                                                }
                                                if (result10 !== null) {
                                                  result11 = [];
                                                  result12 = parse_WS();
                                                  while (result12 !== null) {
                                                    result11.push(result12);
                                                    result12 = parse_WS();
                                                  }
                                                  if (result11 !== null) {
                                                    result12 = parse_ConditionalOrExpression();
                                                    if (result12 !== null) {
                                                      result13 = [];
                                                      result14 = parse_WS();
                                                      while (result14 !== null) {
                                                        result13.push(result14);
                                                        result14 = parse_WS();
                                                      }
                                                      if (result13 !== null) {
                                                        if (input.charCodeAt(pos) === 41) {
                                                          result14 = ")";
                                                          pos++;
                                                        } else {
                                                          result14 = null;
                                                          if (reportFailures === 0) {
                                                            matchFailed("\")\"");
                                                          }
                                                        }
                                                        if (result14 !== null) {
                                                          result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14];
                                                        } else {
                                                          result0 = null;
                                                          pos = pos1;
                                                        }
                                                      } else {
                                                        result0 = null;
                                                        pos = pos1;
                                                      }
                                                    } else {
                                                      result0 = null;
                                                      pos = pos1;
                                                    }
                                                  } else {
                                                    result0 = null;
                                                    pos = pos1;
                                                  }
                                                } else {
                                                  result0 = null;
                                                  pos = pos1;
                                                }
                                              } else {
                                                result0 = null;
                                                pos = pos1;
                                              }
                                            } else {
                                              result0 = null;
                                              pos = pos1;
                                            }
                                          } else {
                                            result0 = null;
                                            pos = pos1;
                                          }
                                        } else {
                                          result0 = null;
                                          pos = pos1;
                                        }
                                      } else {
                                        result0 = null;
                                        pos = pos1;
                                      }
                                    } else {
                                      result0 = null;
                                      pos = pos1;
                                    }
                                  } else {
                                    result0 = null;
                                    pos = pos1;
                                  }
                                } else {
                                  result0 = null;
                                  pos = pos1;
                                }
                              } else {
                                result0 = null;
                                pos = pos1;
                              }
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                            if (result0 !== null) {
                              result0 = (function(offset, test, trueCond, falseCond) {
                                var ex = {};
                                ex.token = 'expression';
                                ex.expressionType = 'builtincall';
                                ex.builtincall = 'if';
                                ex.args = [test,trueCond,falseCond];
                            
                                return ex;
                            })(pos0, result0[4], result0[8], result0[12]);
                            }
                            if (result0 === null) {
                              pos = pos0;
                            }
                            if (result0 === null) {
                              pos0 = pos;
                              pos1 = pos;
                              if (input.substr(pos, 9) === "ISLITERAL") {
                                result0 = "ISLITERAL";
                                pos += 9;
                              } else {
                                result0 = null;
                                if (reportFailures === 0) {
                                  matchFailed("\"ISLITERAL\"");
                                }
                              }
                              if (result0 === null) {
                                if (input.substr(pos, 9) === "isliteral") {
                                  result0 = "isliteral";
                                  pos += 9;
                                } else {
                                  result0 = null;
                                  if (reportFailures === 0) {
                                    matchFailed("\"isliteral\"");
                                  }
                                }
                              }
                              if (result0 !== null) {
                                result1 = [];
                                result2 = parse_WS();
                                while (result2 !== null) {
                                  result1.push(result2);
                                  result2 = parse_WS();
                                }
                                if (result1 !== null) {
                                  if (input.charCodeAt(pos) === 40) {
                                    result2 = "(";
                                    pos++;
                                  } else {
                                    result2 = null;
                                    if (reportFailures === 0) {
                                      matchFailed("\"(\"");
                                    }
                                  }
                                  if (result2 !== null) {
                                    result3 = [];
                                    result4 = parse_WS();
                                    while (result4 !== null) {
                                      result3.push(result4);
                                      result4 = parse_WS();
                                    }
                                    if (result3 !== null) {
                                      result4 = parse_ConditionalOrExpression();
                                      if (result4 !== null) {
                                        result5 = [];
                                        result6 = parse_WS();
                                        while (result6 !== null) {
                                          result5.push(result6);
                                          result6 = parse_WS();
                                        }
                                        if (result5 !== null) {
                                          if (input.charCodeAt(pos) === 41) {
                                            result6 = ")";
                                            pos++;
                                          } else {
                                            result6 = null;
                                            if (reportFailures === 0) {
                                              matchFailed("\")\"");
                                            }
                                          }
                                          if (result6 !== null) {
                                            result0 = [result0, result1, result2, result3, result4, result5, result6];
                                          } else {
                                            result0 = null;
                                            pos = pos1;
                                          }
                                        } else {
                                          result0 = null;
                                          pos = pos1;
                                        }
                                      } else {
                                        result0 = null;
                                        pos = pos1;
                                      }
                                    } else {
                                      result0 = null;
                                      pos = pos1;
                                    }
                                  } else {
                                    result0 = null;
                                    pos = pos1;
                                  }
                                } else {
                                  result0 = null;
                                  pos = pos1;
                                }
                              } else {
                                result0 = null;
                                pos = pos1;
                              }
                              if (result0 !== null) {
                                result0 = (function(offset, arg) {
                                  var ex = {};
                                  ex.token = 'expression';
                                  ex.expressionType = 'builtincall';
                                  ex.builtincall = 'isliteral';
                                  ex.args = [arg];
                              
                                  return ex;
                              })(pos0, result0[4]);
                              }
                              if (result0 === null) {
                                pos = pos0;
                              }
                              if (result0 === null) {
                                pos0 = pos;
                                pos1 = pos;
                                if (input.substr(pos, 7) === "ISBLANK") {
                                  result0 = "ISBLANK";
                                  pos += 7;
                                } else {
                                  result0 = null;
                                  if (reportFailures === 0) {
                                    matchFailed("\"ISBLANK\"");
                                  }
                                }
                                if (result0 === null) {
                                  if (input.substr(pos, 7) === "isblank") {
                                    result0 = "isblank";
                                    pos += 7;
                                  } else {
                                    result0 = null;
                                    if (reportFailures === 0) {
                                      matchFailed("\"isblank\"");
                                    }
                                  }
                                }
                                if (result0 !== null) {
                                  result1 = [];
                                  result2 = parse_WS();
                                  while (result2 !== null) {
                                    result1.push(result2);
                                    result2 = parse_WS();
                                  }
                                  if (result1 !== null) {
                                    if (input.charCodeAt(pos) === 40) {
                                      result2 = "(";
                                      pos++;
                                    } else {
                                      result2 = null;
                                      if (reportFailures === 0) {
                                        matchFailed("\"(\"");
                                      }
                                    }
                                    if (result2 !== null) {
                                      result3 = [];
                                      result4 = parse_WS();
                                      while (result4 !== null) {
                                        result3.push(result4);
                                        result4 = parse_WS();
                                      }
                                      if (result3 !== null) {
                                        result4 = parse_ConditionalOrExpression();
                                        if (result4 !== null) {
                                          result5 = [];
                                          result6 = parse_WS();
                                          while (result6 !== null) {
                                            result5.push(result6);
                                            result6 = parse_WS();
                                          }
                                          if (result5 !== null) {
                                            if (input.charCodeAt(pos) === 41) {
                                              result6 = ")";
                                              pos++;
                                            } else {
                                              result6 = null;
                                              if (reportFailures === 0) {
                                                matchFailed("\")\"");
                                              }
                                            }
                                            if (result6 !== null) {
                                              result0 = [result0, result1, result2, result3, result4, result5, result6];
                                            } else {
                                              result0 = null;
                                              pos = pos1;
                                            }
                                          } else {
                                            result0 = null;
                                            pos = pos1;
                                          }
                                        } else {
                                          result0 = null;
                                          pos = pos1;
                                        }
                                      } else {
                                        result0 = null;
                                        pos = pos1;
                                      }
                                    } else {
                                      result0 = null;
                                      pos = pos1;
                                    }
                                  } else {
                                    result0 = null;
                                    pos = pos1;
                                  }
                                } else {
                                  result0 = null;
                                  pos = pos1;
                                }
                                if (result0 !== null) {
                                  result0 = (function(offset, arg) {
                                    var ex = {};
                                    ex.token = 'expression';
                                    ex.expressionType = 'builtincall';
                                    ex.builtincall = 'isblank';
                                    ex.args = [arg];
                                
                                    return ex;
                                })(pos0, result0[4]);
                                }
                                if (result0 === null) {
                                  pos = pos0;
                                }
                                if (result0 === null) {
                                  pos0 = pos;
                                  pos1 = pos;
                                  if (input.substr(pos, 8) === "SAMETERM") {
                                    result0 = "SAMETERM";
                                    pos += 8;
                                  } else {
                                    result0 = null;
                                    if (reportFailures === 0) {
                                      matchFailed("\"SAMETERM\"");
                                    }
                                  }
                                  if (result0 === null) {
                                    if (input.substr(pos, 8) === "sameterm") {
                                      result0 = "sameterm";
                                      pos += 8;
                                    } else {
                                      result0 = null;
                                      if (reportFailures === 0) {
                                        matchFailed("\"sameterm\"");
                                      }
                                    }
                                  }
                                  if (result0 !== null) {
                                    result1 = [];
                                    result2 = parse_WS();
                                    while (result2 !== null) {
                                      result1.push(result2);
                                      result2 = parse_WS();
                                    }
                                    if (result1 !== null) {
                                      if (input.charCodeAt(pos) === 40) {
                                        result2 = "(";
                                        pos++;
                                      } else {
                                        result2 = null;
                                        if (reportFailures === 0) {
                                          matchFailed("\"(\"");
                                        }
                                      }
                                      if (result2 !== null) {
                                        result3 = [];
                                        result4 = parse_WS();
                                        while (result4 !== null) {
                                          result3.push(result4);
                                          result4 = parse_WS();
                                        }
                                        if (result3 !== null) {
                                          result4 = parse_ConditionalOrExpression();
                                          if (result4 !== null) {
                                            result5 = [];
                                            result6 = parse_WS();
                                            while (result6 !== null) {
                                              result5.push(result6);
                                              result6 = parse_WS();
                                            }
                                            if (result5 !== null) {
                                              if (input.charCodeAt(pos) === 44) {
                                                result6 = ",";
                                                pos++;
                                              } else {
                                                result6 = null;
                                                if (reportFailures === 0) {
                                                  matchFailed("\",\"");
                                                }
                                              }
                                              if (result6 !== null) {
                                                result7 = [];
                                                result8 = parse_WS();
                                                while (result8 !== null) {
                                                  result7.push(result8);
                                                  result8 = parse_WS();
                                                }
                                                if (result7 !== null) {
                                                  result8 = parse_ConditionalOrExpression();
                                                  if (result8 !== null) {
                                                    result9 = [];
                                                    result10 = parse_WS();
                                                    while (result10 !== null) {
                                                      result9.push(result10);
                                                      result10 = parse_WS();
                                                    }
                                                    if (result9 !== null) {
                                                      if (input.charCodeAt(pos) === 41) {
                                                        result10 = ")";
                                                        pos++;
                                                      } else {
                                                        result10 = null;
                                                        if (reportFailures === 0) {
                                                          matchFailed("\")\"");
                                                        }
                                                      }
                                                      if (result10 !== null) {
                                                        result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10];
                                                      } else {
                                                        result0 = null;
                                                        pos = pos1;
                                                      }
                                                    } else {
                                                      result0 = null;
                                                      pos = pos1;
                                                    }
                                                  } else {
                                                    result0 = null;
                                                    pos = pos1;
                                                  }
                                                } else {
                                                  result0 = null;
                                                  pos = pos1;
                                                }
                                              } else {
                                                result0 = null;
                                                pos = pos1;
                                              }
                                            } else {
                                              result0 = null;
                                              pos = pos1;
                                            }
                                          } else {
                                            result0 = null;
                                            pos = pos1;
                                          }
                                        } else {
                                          result0 = null;
                                          pos = pos1;
                                        }
                                      } else {
                                        result0 = null;
                                        pos = pos1;
                                      }
                                    } else {
                                      result0 = null;
                                      pos = pos1;
                                    }
                                  } else {
                                    result0 = null;
                                    pos = pos1;
                                  }
                                  if (result0 !== null) {
                                    result0 = (function(offset, e1, e2) {
                                      var ex = {};
                                      ex.token = 'expression';
                                      ex.expressionType = 'builtincall';
                                      ex.builtincall = 'sameterm';
                                      ex.args = [e1, e2];
                                      return ex;
                                  })(pos0, result0[4], result0[8]);
                                  }
                                  if (result0 === null) {
                                    pos = pos0;
                                  }
                                  if (result0 === null) {
                                    pos0 = pos;
                                    pos1 = pos;
                                    if (input.substr(pos, 5) === "ISURI") {
                                      result0 = "ISURI";
                                      pos += 5;
                                    } else {
                                      result0 = null;
                                      if (reportFailures === 0) {
                                        matchFailed("\"ISURI\"");
                                      }
                                    }
                                    if (result0 === null) {
                                      if (input.substr(pos, 5) === "isuri") {
                                        result0 = "isuri";
                                        pos += 5;
                                      } else {
                                        result0 = null;
                                        if (reportFailures === 0) {
                                          matchFailed("\"isuri\"");
                                        }
                                      }
                                      if (result0 === null) {
                                        if (input.substr(pos, 5) === "ISIRI") {
                                          result0 = "ISIRI";
                                          pos += 5;
                                        } else {
                                          result0 = null;
                                          if (reportFailures === 0) {
                                            matchFailed("\"ISIRI\"");
                                          }
                                        }
                                        if (result0 === null) {
                                          if (input.substr(pos, 5) === "isiri") {
                                            result0 = "isiri";
                                            pos += 5;
                                          } else {
                                            result0 = null;
                                            if (reportFailures === 0) {
                                              matchFailed("\"isiri\"");
                                            }
                                          }
                                        }
                                      }
                                    }
                                    if (result0 !== null) {
                                      result1 = [];
                                      result2 = parse_WS();
                                      while (result2 !== null) {
                                        result1.push(result2);
                                        result2 = parse_WS();
                                      }
                                      if (result1 !== null) {
                                        if (input.charCodeAt(pos) === 40) {
                                          result2 = "(";
                                          pos++;
                                        } else {
                                          result2 = null;
                                          if (reportFailures === 0) {
                                            matchFailed("\"(\"");
                                          }
                                        }
                                        if (result2 !== null) {
                                          result3 = [];
                                          result4 = parse_WS();
                                          while (result4 !== null) {
                                            result3.push(result4);
                                            result4 = parse_WS();
                                          }
                                          if (result3 !== null) {
                                            result4 = parse_ConditionalOrExpression();
                                            if (result4 !== null) {
                                              result5 = [];
                                              result6 = parse_WS();
                                              while (result6 !== null) {
                                                result5.push(result6);
                                                result6 = parse_WS();
                                              }
                                              if (result5 !== null) {
                                                if (input.charCodeAt(pos) === 41) {
                                                  result6 = ")";
                                                  pos++;
                                                } else {
                                                  result6 = null;
                                                  if (reportFailures === 0) {
                                                    matchFailed("\")\"");
                                                  }
                                                }
                                                if (result6 !== null) {
                                                  result0 = [result0, result1, result2, result3, result4, result5, result6];
                                                } else {
                                                  result0 = null;
                                                  pos = pos1;
                                                }
                                              } else {
                                                result0 = null;
                                                pos = pos1;
                                              }
                                            } else {
                                              result0 = null;
                                              pos = pos1;
                                            }
                                          } else {
                                            result0 = null;
                                            pos = pos1;
                                          }
                                        } else {
                                          result0 = null;
                                          pos = pos1;
                                        }
                                      } else {
                                        result0 = null;
                                        pos = pos1;
                                      }
                                    } else {
                                      result0 = null;
                                      pos = pos1;
                                    }
                                    if (result0 !== null) {
                                      result0 = (function(offset, arg) {
                                        var ex = {};
                                        ex.token = 'expression';
                                        ex.expressionType = 'builtincall';
                                        ex.builtincall = 'isuri';
                                        ex.args = [arg];
                                    
                                        return ex;
                                    })(pos0, result0[4]);
                                    }
                                    if (result0 === null) {
                                      pos = pos0;
                                    }
                                    if (result0 === null) {
                                      pos0 = pos;
                                      pos1 = pos;
                                      if (input.substr(pos, 7) === "custom:") {
                                        result0 = "custom:";
                                        pos += 7;
                                      } else {
                                        result0 = null;
                                        if (reportFailures === 0) {
                                          matchFailed("\"custom:\"");
                                        }
                                      }
                                      if (result0 === null) {
                                        if (input.substr(pos, 7) === "CUSTOM:") {
                                          result0 = "CUSTOM:";
                                          pos += 7;
                                        } else {
                                          result0 = null;
                                          if (reportFailures === 0) {
                                            matchFailed("\"CUSTOM:\"");
                                          }
                                        }
                                      }
                                      if (result0 !== null) {
                                        if (/^[a-zA-Z0-9_]/.test(input.charAt(pos))) {
                                          result2 = input.charAt(pos);
                                          pos++;
                                        } else {
                                          result2 = null;
                                          if (reportFailures === 0) {
                                            matchFailed("[a-zA-Z0-9_]");
                                          }
                                        }
                                        if (result2 !== null) {
                                          result1 = [];
                                          while (result2 !== null) {
                                            result1.push(result2);
                                            if (/^[a-zA-Z0-9_]/.test(input.charAt(pos))) {
                                              result2 = input.charAt(pos);
                                              pos++;
                                            } else {
                                              result2 = null;
                                              if (reportFailures === 0) {
                                                matchFailed("[a-zA-Z0-9_]");
                                              }
                                            }
                                          }
                                        } else {
                                          result1 = null;
                                        }
                                        if (result1 !== null) {
                                          result2 = [];
                                          result3 = parse_WS();
                                          while (result3 !== null) {
                                            result2.push(result3);
                                            result3 = parse_WS();
                                          }
                                          if (result2 !== null) {
                                            if (input.charCodeAt(pos) === 40) {
                                              result3 = "(";
                                              pos++;
                                            } else {
                                              result3 = null;
                                              if (reportFailures === 0) {
                                                matchFailed("\"(\"");
                                              }
                                            }
                                            if (result3 !== null) {
                                              result4 = [];
                                              pos2 = pos;
                                              result5 = [];
                                              result6 = parse_WS();
                                              while (result6 !== null) {
                                                result5.push(result6);
                                                result6 = parse_WS();
                                              }
                                              if (result5 !== null) {
                                                result6 = parse_ConditionalOrExpression();
                                                if (result6 !== null) {
                                                  if (input.charCodeAt(pos) === 44) {
                                                    result7 = ",";
                                                    pos++;
                                                  } else {
                                                    result7 = null;
                                                    if (reportFailures === 0) {
                                                      matchFailed("\",\"");
                                                    }
                                                  }
                                                  if (result7 !== null) {
                                                    result5 = [result5, result6, result7];
                                                  } else {
                                                    result5 = null;
                                                    pos = pos2;
                                                  }
                                                } else {
                                                  result5 = null;
                                                  pos = pos2;
                                                }
                                              } else {
                                                result5 = null;
                                                pos = pos2;
                                              }
                                              while (result5 !== null) {
                                                result4.push(result5);
                                                pos2 = pos;
                                                result5 = [];
                                                result6 = parse_WS();
                                                while (result6 !== null) {
                                                  result5.push(result6);
                                                  result6 = parse_WS();
                                                }
                                                if (result5 !== null) {
                                                  result6 = parse_ConditionalOrExpression();
                                                  if (result6 !== null) {
                                                    if (input.charCodeAt(pos) === 44) {
                                                      result7 = ",";
                                                      pos++;
                                                    } else {
                                                      result7 = null;
                                                      if (reportFailures === 0) {
                                                        matchFailed("\",\"");
                                                      }
                                                    }
                                                    if (result7 !== null) {
                                                      result5 = [result5, result6, result7];
                                                    } else {
                                                      result5 = null;
                                                      pos = pos2;
                                                    }
                                                  } else {
                                                    result5 = null;
                                                    pos = pos2;
                                                  }
                                                } else {
                                                  result5 = null;
                                                  pos = pos2;
                                                }
                                              }
                                              if (result4 !== null) {
                                                result5 = [];
                                                result6 = parse_WS();
                                                while (result6 !== null) {
                                                  result5.push(result6);
                                                  result6 = parse_WS();
                                                }
                                                if (result5 !== null) {
                                                  result6 = parse_ConditionalOrExpression();
                                                  if (result6 !== null) {
                                                    result7 = [];
                                                    result8 = parse_WS();
                                                    while (result8 !== null) {
                                                      result7.push(result8);
                                                      result8 = parse_WS();
                                                    }
                                                    if (result7 !== null) {
                                                      if (input.charCodeAt(pos) === 41) {
                                                        result8 = ")";
                                                        pos++;
                                                      } else {
                                                        result8 = null;
                                                        if (reportFailures === 0) {
                                                          matchFailed("\")\"");
                                                        }
                                                      }
                                                      if (result8 !== null) {
                                                        result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8];
                                                      } else {
                                                        result0 = null;
                                                        pos = pos1;
                                                      }
                                                    } else {
                                                      result0 = null;
                                                      pos = pos1;
                                                    }
                                                  } else {
                                                    result0 = null;
                                                    pos = pos1;
                                                  }
                                                } else {
                                                  result0 = null;
                                                  pos = pos1;
                                                }
                                              } else {
                                                result0 = null;
                                                pos = pos1;
                                              }
                                            } else {
                                              result0 = null;
                                              pos = pos1;
                                            }
                                          } else {
                                            result0 = null;
                                            pos = pos1;
                                          }
                                        } else {
                                          result0 = null;
                                          pos = pos1;
                                        }
                                      } else {
                                        result0 = null;
                                        pos = pos1;
                                      }
                                      if (result0 !== null) {
                                        result0 = (function(offset, fnname, alter, finalarg) {
                                        var ex = {};
                                        ex.token = 'expression';
                                        ex.expressionType = 'custom';
                                        ex.name = fnname.join('');
                                        var acum = [];
                                        for(var i=0; i<alter.length; i++)
                                          acum.push(alter[i][1]);
                                        acum.push(finalarg);
                                        ex.args = acum;
                                      
                                        return ex;
                                      })(pos0, result0[1], result0[4], result0[6]);
                                      }
                                      if (result0 === null) {
                                        pos = pos0;
                                      }
                                      if (result0 === null) {
                                        result0 = parse_RegexExpression();
                                        if (result0 === null) {
                                          result0 = parse_ExistsFunc();
                                          if (result0 === null) {
                                            result0 = parse_NotExistsFunc();
                                          }
                                        }
                                      }
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[106] BuiltInCall");
          }
          return result0;
        }
        
        function parse_RegexExpression() {
          var result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 5) === "REGEX") {
            result0 = "REGEX";
            pos += 5;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"REGEX\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 5) === "regex") {
              result0 = "regex";
              pos += 5;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"regex\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              if (input.charCodeAt(pos) === 40) {
                result2 = "(";
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"(\"");
                }
              }
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result4 = parse_ConditionalOrExpression();
                  if (result4 !== null) {
                    result5 = [];
                    result6 = parse_WS();
                    while (result6 !== null) {
                      result5.push(result6);
                      result6 = parse_WS();
                    }
                    if (result5 !== null) {
                      if (input.charCodeAt(pos) === 44) {
                        result6 = ",";
                        pos++;
                      } else {
                        result6 = null;
                        if (reportFailures === 0) {
                          matchFailed("\",\"");
                        }
                      }
                      if (result6 !== null) {
                        result7 = [];
                        result8 = parse_WS();
                        while (result8 !== null) {
                          result7.push(result8);
                          result8 = parse_WS();
                        }
                        if (result7 !== null) {
                          result8 = parse_ConditionalOrExpression();
                          if (result8 !== null) {
                            result9 = [];
                            result10 = parse_WS();
                            while (result10 !== null) {
                              result9.push(result10);
                              result10 = parse_WS();
                            }
                            if (result9 !== null) {
                              pos2 = pos;
                              if (input.charCodeAt(pos) === 44) {
                                result10 = ",";
                                pos++;
                              } else {
                                result10 = null;
                                if (reportFailures === 0) {
                                  matchFailed("\",\"");
                                }
                              }
                              if (result10 !== null) {
                                result11 = [];
                                result12 = parse_WS();
                                while (result12 !== null) {
                                  result11.push(result12);
                                  result12 = parse_WS();
                                }
                                if (result11 !== null) {
                                  result12 = parse_ConditionalOrExpression();
                                  if (result12 !== null) {
                                    result10 = [result10, result11, result12];
                                  } else {
                                    result10 = null;
                                    pos = pos2;
                                  }
                                } else {
                                  result10 = null;
                                  pos = pos2;
                                }
                              } else {
                                result10 = null;
                                pos = pos2;
                              }
                              result10 = result10 !== null ? result10 : "";
                              if (result10 !== null) {
                                result11 = [];
                                result12 = parse_WS();
                                while (result12 !== null) {
                                  result11.push(result12);
                                  result12 = parse_WS();
                                }
                                if (result11 !== null) {
                                  if (input.charCodeAt(pos) === 41) {
                                    result12 = ")";
                                    pos++;
                                  } else {
                                    result12 = null;
                                    if (reportFailures === 0) {
                                      matchFailed("\")\"");
                                    }
                                  }
                                  if (result12 !== null) {
                                    result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12];
                                  } else {
                                    result0 = null;
                                    pos = pos1;
                                  }
                                } else {
                                  result0 = null;
                                  pos = pos1;
                                }
                              } else {
                                result0 = null;
                                pos = pos1;
                              }
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, e1, e2, eo) {
                var regex = {};
                regex.token = 'expression';
                regex.expressionType = 'regex';
                regex.text = e1;
                regex.pattern = e2;
                regex.flags = eo[2];
          
                return regex;
          })(pos0, result0[4], result0[8], result0[10]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[107] RegexExpression");
          }
          return result0;
        }
        
        function parse_ExistsFunc() {
          var result0, result1, result2;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 6) === "EXISTS") {
            result0 = "EXISTS";
            pos += 6;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"EXISTS\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 6) === "exists") {
              result0 = "exists";
              pos += 6;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"exists\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              result2 = parse_GroupGraphPattern();
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, ggp) {
              var ex = {};
              ex.token = 'expression';
              ex.expressionType = 'builtincall';
              ex.builtincall = 'exists';
              ex.args = [ggp];
          
              return ex;
          })(pos0, result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[108] ExistsFunc");
          }
          return result0;
        }
        
        function parse_NotExistsFunc() {
          var result0, result1, result2, result3, result4;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 3) === "NOT") {
            result0 = "NOT";
            pos += 3;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"NOT\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 3) === "not") {
              result0 = "not";
              pos += 3;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"not\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              if (input.substr(pos, 6) === "EXISTS") {
                result2 = "EXISTS";
                pos += 6;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"EXISTS\"");
                }
              }
              if (result2 === null) {
                if (input.substr(pos, 6) === "exists") {
                  result2 = "exists";
                  pos += 6;
                } else {
                  result2 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"exists\"");
                  }
                }
              }
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  result4 = parse_GroupGraphPattern();
                  if (result4 !== null) {
                    result0 = [result0, result1, result2, result3, result4];
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, ggp) {
              var ex = {};
              ex.token = 'expression';
              ex.expressionType = 'builtincall';
              ex.builtincall = 'notexists';
              ex.args = [ggp];
          
              return ex;
          })(pos0, result0[4]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[109] NotExistsFunc");
          }
          return result0;
        }
        
        function parse_Aggregate() {
          var result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 5) === "COUNT") {
            result0 = "COUNT";
            pos += 5;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"COUNT\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 5) === "count") {
              result0 = "count";
              pos += 5;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"count\"");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              if (input.charCodeAt(pos) === 40) {
                result2 = "(";
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"(\"");
                }
              }
              if (result2 !== null) {
                result3 = [];
                result4 = parse_WS();
                while (result4 !== null) {
                  result3.push(result4);
                  result4 = parse_WS();
                }
                if (result3 !== null) {
                  if (input.substr(pos, 8) === "DISTINCT") {
                    result4 = "DISTINCT";
                    pos += 8;
                  } else {
                    result4 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"DISTINCT\"");
                    }
                  }
                  if (result4 === null) {
                    if (input.substr(pos, 8) === "distinct") {
                      result4 = "distinct";
                      pos += 8;
                    } else {
                      result4 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"distinct\"");
                      }
                    }
                  }
                  result4 = result4 !== null ? result4 : "";
                  if (result4 !== null) {
                    result5 = [];
                    result6 = parse_WS();
                    while (result6 !== null) {
                      result5.push(result6);
                      result6 = parse_WS();
                    }
                    if (result5 !== null) {
                      if (input.charCodeAt(pos) === 42) {
                        result6 = "*";
                        pos++;
                      } else {
                        result6 = null;
                        if (reportFailures === 0) {
                          matchFailed("\"*\"");
                        }
                      }
                      if (result6 === null) {
                        result6 = parse_ConditionalOrExpression();
                      }
                      if (result6 !== null) {
                        result7 = [];
                        result8 = parse_WS();
                        while (result8 !== null) {
                          result7.push(result8);
                          result8 = parse_WS();
                        }
                        if (result7 !== null) {
                          if (input.charCodeAt(pos) === 41) {
                            result8 = ")";
                            pos++;
                          } else {
                            result8 = null;
                            if (reportFailures === 0) {
                              matchFailed("\")\"");
                            }
                          }
                          if (result8 !== null) {
                            result9 = [];
                            result10 = parse_WS();
                            while (result10 !== null) {
                              result9.push(result10);
                              result10 = parse_WS();
                            }
                            if (result9 !== null) {
                              result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9];
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, d, e) {
                var exp = {};
                exp.token = 'expression';
                exp.expressionType = 'aggregate';
                exp.aggregateType = 'count';
                exp.distinct = (d != "" ? 'DISTINCT' : d);
                exp.expression = e;
          
                return exp;
          
            })(pos0, result0[4], result0[6]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            pos1 = pos;
            if (input.substr(pos, 3) === "SUM") {
              result0 = "SUM";
              pos += 3;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"SUM\"");
              }
            }
            if (result0 === null) {
              if (input.substr(pos, 3) === "sum") {
                result0 = "sum";
                pos += 3;
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("\"sum\"");
                }
              }
            }
            if (result0 !== null) {
              result1 = [];
              result2 = parse_WS();
              while (result2 !== null) {
                result1.push(result2);
                result2 = parse_WS();
              }
              if (result1 !== null) {
                if (input.charCodeAt(pos) === 40) {
                  result2 = "(";
                  pos++;
                } else {
                  result2 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"(\"");
                  }
                }
                if (result2 !== null) {
                  result3 = [];
                  result4 = parse_WS();
                  while (result4 !== null) {
                    result3.push(result4);
                    result4 = parse_WS();
                  }
                  if (result3 !== null) {
                    if (input.substr(pos, 8) === "DISTINCT") {
                      result4 = "DISTINCT";
                      pos += 8;
                    } else {
                      result4 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"DISTINCT\"");
                      }
                    }
                    if (result4 === null) {
                      if (input.substr(pos, 8) === "distinct") {
                        result4 = "distinct";
                        pos += 8;
                      } else {
                        result4 = null;
                        if (reportFailures === 0) {
                          matchFailed("\"distinct\"");
                        }
                      }
                    }
                    result4 = result4 !== null ? result4 : "";
                    if (result4 !== null) {
                      result5 = [];
                      result6 = parse_WS();
                      while (result6 !== null) {
                        result5.push(result6);
                        result6 = parse_WS();
                      }
                      if (result5 !== null) {
                        result6 = parse_ConditionalOrExpression();
                        if (result6 !== null) {
                          result7 = [];
                          result8 = parse_WS();
                          while (result8 !== null) {
                            result7.push(result8);
                            result8 = parse_WS();
                          }
                          if (result7 !== null) {
                            if (input.charCodeAt(pos) === 41) {
                              result8 = ")";
                              pos++;
                            } else {
                              result8 = null;
                              if (reportFailures === 0) {
                                matchFailed("\")\"");
                              }
                            }
                            if (result8 !== null) {
                              result9 = [];
                              result10 = parse_WS();
                              while (result10 !== null) {
                                result9.push(result10);
                                result10 = parse_WS();
                              }
                              if (result9 !== null) {
                                result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9];
                              } else {
                                result0 = null;
                                pos = pos1;
                              }
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
            if (result0 !== null) {
              result0 = (function(offset, d, e) {
                  var exp = {};
                  exp.token = 'expression';
                  exp.expressionType = 'aggregate';
                  exp.aggregateType = 'sum';
                  exp.distinct = (d != "" ? 'DISTINCT' : d);
                  exp.expression = e;
            
                  return exp;
            
              })(pos0, result0[4], result0[6]);
            }
            if (result0 === null) {
              pos = pos0;
            }
            if (result0 === null) {
              pos0 = pos;
              pos1 = pos;
              if (input.substr(pos, 3) === "MIN") {
                result0 = "MIN";
                pos += 3;
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("\"MIN\"");
                }
              }
              if (result0 === null) {
                if (input.substr(pos, 3) === "min") {
                  result0 = "min";
                  pos += 3;
                } else {
                  result0 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"min\"");
                  }
                }
              }
              if (result0 !== null) {
                result1 = [];
                result2 = parse_WS();
                while (result2 !== null) {
                  result1.push(result2);
                  result2 = parse_WS();
                }
                if (result1 !== null) {
                  if (input.charCodeAt(pos) === 40) {
                    result2 = "(";
                    pos++;
                  } else {
                    result2 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"(\"");
                    }
                  }
                  if (result2 !== null) {
                    result3 = [];
                    result4 = parse_WS();
                    while (result4 !== null) {
                      result3.push(result4);
                      result4 = parse_WS();
                    }
                    if (result3 !== null) {
                      if (input.substr(pos, 8) === "DISTINCT") {
                        result4 = "DISTINCT";
                        pos += 8;
                      } else {
                        result4 = null;
                        if (reportFailures === 0) {
                          matchFailed("\"DISTINCT\"");
                        }
                      }
                      if (result4 === null) {
                        if (input.substr(pos, 8) === "distinct") {
                          result4 = "distinct";
                          pos += 8;
                        } else {
                          result4 = null;
                          if (reportFailures === 0) {
                            matchFailed("\"distinct\"");
                          }
                        }
                      }
                      result4 = result4 !== null ? result4 : "";
                      if (result4 !== null) {
                        result5 = [];
                        result6 = parse_WS();
                        while (result6 !== null) {
                          result5.push(result6);
                          result6 = parse_WS();
                        }
                        if (result5 !== null) {
                          result6 = parse_ConditionalOrExpression();
                          if (result6 !== null) {
                            result7 = [];
                            result8 = parse_WS();
                            while (result8 !== null) {
                              result7.push(result8);
                              result8 = parse_WS();
                            }
                            if (result7 !== null) {
                              if (input.charCodeAt(pos) === 41) {
                                result8 = ")";
                                pos++;
                              } else {
                                result8 = null;
                                if (reportFailures === 0) {
                                  matchFailed("\")\"");
                                }
                              }
                              if (result8 !== null) {
                                result9 = [];
                                result10 = parse_WS();
                                while (result10 !== null) {
                                  result9.push(result10);
                                  result10 = parse_WS();
                                }
                                if (result9 !== null) {
                                  result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9];
                                } else {
                                  result0 = null;
                                  pos = pos1;
                                }
                              } else {
                                result0 = null;
                                pos = pos1;
                              }
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
              if (result0 !== null) {
                result0 = (function(offset, d, e) {
                    var exp = {};
                    exp.token = 'expression';
                    exp.expressionType = 'aggregate';
                    exp.aggregateType = 'min';
                    exp.distinct = (d != "" ? 'DISTINCT' : d);
                    exp.expression = e;
              
                    return exp;
              
                })(pos0, result0[4], result0[6]);
              }
              if (result0 === null) {
                pos = pos0;
              }
              if (result0 === null) {
                pos0 = pos;
                pos1 = pos;
                if (input.substr(pos, 3) === "MAX") {
                  result0 = "MAX";
                  pos += 3;
                } else {
                  result0 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"MAX\"");
                  }
                }
                if (result0 === null) {
                  if (input.substr(pos, 3) === "max") {
                    result0 = "max";
                    pos += 3;
                  } else {
                    result0 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"max\"");
                    }
                  }
                }
                if (result0 !== null) {
                  result1 = [];
                  result2 = parse_WS();
                  while (result2 !== null) {
                    result1.push(result2);
                    result2 = parse_WS();
                  }
                  if (result1 !== null) {
                    if (input.charCodeAt(pos) === 40) {
                      result2 = "(";
                      pos++;
                    } else {
                      result2 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"(\"");
                      }
                    }
                    if (result2 !== null) {
                      result3 = [];
                      result4 = parse_WS();
                      while (result4 !== null) {
                        result3.push(result4);
                        result4 = parse_WS();
                      }
                      if (result3 !== null) {
                        if (input.substr(pos, 8) === "DISTINCT") {
                          result4 = "DISTINCT";
                          pos += 8;
                        } else {
                          result4 = null;
                          if (reportFailures === 0) {
                            matchFailed("\"DISTINCT\"");
                          }
                        }
                        if (result4 === null) {
                          if (input.substr(pos, 8) === "distinct") {
                            result4 = "distinct";
                            pos += 8;
                          } else {
                            result4 = null;
                            if (reportFailures === 0) {
                              matchFailed("\"distinct\"");
                            }
                          }
                        }
                        result4 = result4 !== null ? result4 : "";
                        if (result4 !== null) {
                          result5 = [];
                          result6 = parse_WS();
                          while (result6 !== null) {
                            result5.push(result6);
                            result6 = parse_WS();
                          }
                          if (result5 !== null) {
                            result6 = parse_ConditionalOrExpression();
                            if (result6 !== null) {
                              result7 = [];
                              result8 = parse_WS();
                              while (result8 !== null) {
                                result7.push(result8);
                                result8 = parse_WS();
                              }
                              if (result7 !== null) {
                                if (input.charCodeAt(pos) === 41) {
                                  result8 = ")";
                                  pos++;
                                } else {
                                  result8 = null;
                                  if (reportFailures === 0) {
                                    matchFailed("\")\"");
                                  }
                                }
                                if (result8 !== null) {
                                  result9 = [];
                                  result10 = parse_WS();
                                  while (result10 !== null) {
                                    result9.push(result10);
                                    result10 = parse_WS();
                                  }
                                  if (result9 !== null) {
                                    result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9];
                                  } else {
                                    result0 = null;
                                    pos = pos1;
                                  }
                                } else {
                                  result0 = null;
                                  pos = pos1;
                                }
                              } else {
                                result0 = null;
                                pos = pos1;
                              }
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
                if (result0 !== null) {
                  result0 = (function(offset, d, e) {
                      var exp = {};
                      exp.token = 'expression'
                      exp.expressionType = 'aggregate'
                      exp.aggregateType = 'max'
                      exp.distinct = (d != "" ? 'DISTINCT' : d);
                      exp.expression = e
                
                      return exp
                
                  })(pos0, result0[4], result0[6]);
                }
                if (result0 === null) {
                  pos = pos0;
                }
                if (result0 === null) {
                  pos0 = pos;
                  pos1 = pos;
                  if (input.substr(pos, 3) === "AVG") {
                    result0 = "AVG";
                    pos += 3;
                  } else {
                    result0 = null;
                    if (reportFailures === 0) {
                      matchFailed("\"AVG\"");
                    }
                  }
                  if (result0 === null) {
                    if (input.substr(pos, 3) === "avg") {
                      result0 = "avg";
                      pos += 3;
                    } else {
                      result0 = null;
                      if (reportFailures === 0) {
                        matchFailed("\"avg\"");
                      }
                    }
                  }
                  if (result0 !== null) {
                    result1 = [];
                    result2 = parse_WS();
                    while (result2 !== null) {
                      result1.push(result2);
                      result2 = parse_WS();
                    }
                    if (result1 !== null) {
                      if (input.charCodeAt(pos) === 40) {
                        result2 = "(";
                        pos++;
                      } else {
                        result2 = null;
                        if (reportFailures === 0) {
                          matchFailed("\"(\"");
                        }
                      }
                      if (result2 !== null) {
                        result3 = [];
                        result4 = parse_WS();
                        while (result4 !== null) {
                          result3.push(result4);
                          result4 = parse_WS();
                        }
                        if (result3 !== null) {
                          if (input.substr(pos, 8) === "DISTINCT") {
                            result4 = "DISTINCT";
                            pos += 8;
                          } else {
                            result4 = null;
                            if (reportFailures === 0) {
                              matchFailed("\"DISTINCT\"");
                            }
                          }
                          if (result4 === null) {
                            if (input.substr(pos, 8) === "distinct") {
                              result4 = "distinct";
                              pos += 8;
                            } else {
                              result4 = null;
                              if (reportFailures === 0) {
                                matchFailed("\"distinct\"");
                              }
                            }
                          }
                          result4 = result4 !== null ? result4 : "";
                          if (result4 !== null) {
                            result5 = [];
                            result6 = parse_WS();
                            while (result6 !== null) {
                              result5.push(result6);
                              result6 = parse_WS();
                            }
                            if (result5 !== null) {
                              result6 = parse_ConditionalOrExpression();
                              if (result6 !== null) {
                                result7 = [];
                                result8 = parse_WS();
                                while (result8 !== null) {
                                  result7.push(result8);
                                  result8 = parse_WS();
                                }
                                if (result7 !== null) {
                                  if (input.charCodeAt(pos) === 41) {
                                    result8 = ")";
                                    pos++;
                                  } else {
                                    result8 = null;
                                    if (reportFailures === 0) {
                                      matchFailed("\")\"");
                                    }
                                  }
                                  if (result8 !== null) {
                                    result9 = [];
                                    result10 = parse_WS();
                                    while (result10 !== null) {
                                      result9.push(result10);
                                      result10 = parse_WS();
                                    }
                                    if (result9 !== null) {
                                      result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9];
                                    } else {
                                      result0 = null;
                                      pos = pos1;
                                    }
                                  } else {
                                    result0 = null;
                                    pos = pos1;
                                  }
                                } else {
                                  result0 = null;
                                  pos = pos1;
                                }
                              } else {
                                result0 = null;
                                pos = pos1;
                              }
                            } else {
                              result0 = null;
                              pos = pos1;
                            }
                          } else {
                            result0 = null;
                            pos = pos1;
                          }
                        } else {
                          result0 = null;
                          pos = pos1;
                        }
                      } else {
                        result0 = null;
                        pos = pos1;
                      }
                    } else {
                      result0 = null;
                      pos = pos1;
                    }
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                  if (result0 !== null) {
                    result0 = (function(offset, d, e) {
                        var exp = {};
                        exp.token = 'expression'
                        exp.expressionType = 'aggregate'
                        exp.aggregateType = 'avg'
                        exp.distinct = (d != "" ? 'DISTINCT' : d);
                        exp.expression = e
                  
                        return exp
                  
                    })(pos0, result0[4], result0[6]);
                  }
                  if (result0 === null) {
                    pos = pos0;
                  }
                }
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[110] Aggregate");
          }
          return result0;
        }
        
        function parse_IRIrefOrFunction() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_IRIref();
          if (result0 !== null) {
            result1 = parse_ArgList();
            result1 = result1 !== null ? result1 : "";
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, i, args) {
                var fcall = {};
                fcall.token = "expression";
                fcall.expressionType = 'irireforfunction';
                fcall.iriref = i;
                fcall.args = args.value;
          
                return fcall;
          })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[117] IRIrefOrFunction");
          }
          return result0;
        }
        
        function parse_RDFLiteral() {
          var result0, result1, result2;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_String();
          if (result0 !== null) {
            result1 = parse_LANGTAG();
            if (result1 === null) {
              pos2 = pos;
              if (input.substr(pos, 2) === "^^") {
                result1 = "^^";
                pos += 2;
              } else {
                result1 = null;
                if (reportFailures === 0) {
                  matchFailed("\"^^\"");
                }
              }
              if (result1 !== null) {
                result2 = parse_IRIref();
                if (result2 !== null) {
                  result1 = [result1, result2];
                } else {
                  result1 = null;
                  pos = pos2;
                }
              } else {
                result1 = null;
                pos = pos2;
              }
            }
            result1 = result1 !== null ? result1 : "";
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, s, e) {
                if(typeof(e) === "string" && e.length > 0) {
                    return {token:'literal', value:s.value, lang:e.slice(1), type:null}
                } else {
                    if(typeof(e) === "object") {
                        e.shift(); // remove the '^^' char
                        return {token:'literal', value:s.value, lang:null, type:e[0] }
                    } else {
                        return { token:'literal', value:s.value, lang:null, type:null }
                    }
                }
          })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[112] RDFLiteral");
          }
          return result0;
        }
        
        function parse_NumericLiteral() {
          var result0;
          
          reportFailures++;
          result0 = parse_NumericLiteralUnsigned();
          if (result0 === null) {
            result0 = parse_NumericLiteralPositive();
            if (result0 === null) {
              result0 = parse_NumericLiteralNegative();
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[113] NumericLiteral");
          }
          return result0;
        }
        
        function parse_NumericLiteralUnsigned() {
          var result0;
          
          reportFailures++;
          result0 = parse_DOUBLE();
          if (result0 === null) {
            result0 = parse_DECIMAL();
            if (result0 === null) {
              result0 = parse_INTEGER();
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[114] NumericLiteralUnsigned");
          }
          return result0;
        }
        
        function parse_NumericLiteralPositive() {
          var result0;
          
          reportFailures++;
          result0 = parse_DOUBLE_POSITIVE();
          if (result0 === null) {
            result0 = parse_DECIMAL_POSITIVE();
            if (result0 === null) {
              result0 = parse_INTEGER_POSITIVE();
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[115] NumericLiteralPositive");
          }
          return result0;
        }
        
        function parse_NumericLiteralNegative() {
          var result0;
          
          reportFailures++;
          result0 = parse_DOUBLE_NEGATIVE();
          if (result0 === null) {
            result0 = parse_DECIMAL_NEGATIVE();
            if (result0 === null) {
              result0 = parse_INTEGER_NEGATIVE();
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[116] NumericLiteralNegative");
          }
          return result0;
        }
        
        function parse_BooleanLiteral() {
          var result0;
          var pos0;
          
          reportFailures++;
          pos0 = pos;
          if (input.substr(pos, 4) === "TRUE") {
            result0 = "TRUE";
            pos += 4;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"TRUE\"");
            }
          }
          if (result0 === null) {
            if (input.substr(pos, 4) === "true") {
              result0 = "true";
              pos += 4;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"true\"");
              }
            }
          }
          if (result0 !== null) {
            result0 = (function(offset) {
                var lit = {};
                lit.token = "literal";
                lit.lang = null;
                lit.type = "http://www.w3.org/2001/XMLSchema#boolean";
                lit.value = true;
                return lit;
           })(pos0);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            if (input.substr(pos, 5) === "FALSE") {
              result0 = "FALSE";
              pos += 5;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"FALSE\"");
              }
            }
            if (result0 === null) {
              if (input.substr(pos, 5) === "false") {
                result0 = "false";
                pos += 5;
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("\"false\"");
                }
              }
            }
            if (result0 !== null) {
              result0 = (function(offset) {
                  var lit = {};
                  lit.token = "literal";
                  lit.lang = null;
                  lit.type = "http://www.w3.org/2001/XMLSchema#boolean";
                  lit.value = false;
                  return lit;
            })(pos0);
            }
            if (result0 === null) {
              pos = pos0;
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[117] BooleanLiteral");
          }
          return result0;
        }
        
        function parse_String() {
          var result0;
          var pos0;
          
          reportFailures++;
          pos0 = pos;
          result0 = parse_STRING_LITERAL_LONG1();
          if (result0 !== null) {
            result0 = (function(offset, s) { return {token:'string', value:s} })(pos0, result0);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            result0 = parse_STRING_LITERAL_LONG2();
            if (result0 !== null) {
              result0 = (function(offset, s) { return {token:'string', value:s} })(pos0, result0);
            }
            if (result0 === null) {
              pos = pos0;
            }
            if (result0 === null) {
              pos0 = pos;
              result0 = parse_STRING_LITERAL1();
              if (result0 !== null) {
                result0 = (function(offset, s) { return {token:'string', value:s} })(pos0, result0);
              }
              if (result0 === null) {
                pos = pos0;
              }
              if (result0 === null) {
                pos0 = pos;
                result0 = parse_STRING_LITERAL2();
                if (result0 !== null) {
                  result0 = (function(offset, s) { return {token:'string', value:s} })(pos0, result0);
                }
                if (result0 === null) {
                  pos = pos0;
                }
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[118] String");
          }
          return result0;
        }
        
        function parse_IRIref() {
          var result0;
          var pos0;
          
          reportFailures++;
          pos0 = pos;
          result0 = parse_IRI_REF();
          if (result0 !== null) {
            result0 = (function(offset, iri) { return {token: 'uri', prefix:null, suffix:null, value:iri} })(pos0, result0);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            result0 = parse_PrefixedName();
            if (result0 !== null) {
              result0 = (function(offset, p) { return p })(pos0, result0);
            }
            if (result0 === null) {
              pos = pos0;
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[119] IRIref");
          }
          return result0;
        }
        
        function parse_PrefixedName() {
          var result0;
          var pos0;
          
          reportFailures++;
          pos0 = pos;
          result0 = parse_PNAME_LN();
          if (result0 !== null) {
            result0 = (function(offset, p) { return {token: 'uri', prefix:p[0], suffix:p[1], value:null } })(pos0, result0);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            result0 = parse_PNAME_NS();
            if (result0 !== null) {
              result0 = (function(offset, p) { return {token: 'uri', prefix:p, suffix:'', value:null } })(pos0, result0);
            }
            if (result0 === null) {
              pos = pos0;
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[120] PrefixedName");
          }
          return result0;
        }
        
        function parse_BlankNode() {
          var result0;
          var pos0;
          
          reportFailures++;
          pos0 = pos;
          result0 = parse_BLANK_NODE_LABEL();
          if (result0 !== null) {
            result0 = (function(offset, l) { return {token:'blank', value:l}})(pos0, result0);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            result0 = parse_ANON();
            if (result0 !== null) {
              result0 = (function(offset) { GlobalBlankNodeCounter++; return {token:'blank', value:'_:'+GlobalBlankNodeCounter} })(pos0);
            }
            if (result0 === null) {
              pos = pos0;
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[121] BlankNode");
          }
          return result0;
        }
        
        function parse_IRI_REF() {
          var result0, result1, result2;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.charCodeAt(pos) === 60) {
            result0 = "<";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"<\"");
            }
          }
          if (result0 !== null) {
            result1 = [];
            if (/^[^<>"{}|^`\\]/.test(input.charAt(pos))) {
              result2 = input.charAt(pos);
              pos++;
            } else {
              result2 = null;
              if (reportFailures === 0) {
                matchFailed("[^<>\"{}|^`\\\\]");
              }
            }
            while (result2 !== null) {
              result1.push(result2);
              if (/^[^<>"{}|^`\\]/.test(input.charAt(pos))) {
                result2 = input.charAt(pos);
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("[^<>\"{}|^`\\\\]");
                }
              }
            }
            if (result1 !== null) {
              if (input.charCodeAt(pos) === 62) {
                result2 = ">";
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\">\"");
                }
              }
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, iri_ref) { return iri_ref.join('') })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[122] IRI_REF");
          }
          return result0;
        }
        
        function parse_PNAME_NS() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_PN_PREFIX();
          result0 = result0 !== null ? result0 : "";
          if (result0 !== null) {
            if (input.charCodeAt(pos) === 58) {
              result1 = ":";
              pos++;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("\":\"");
              }
            }
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, p) { return p })(pos0, result0[0]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[123] PNAME_NS");
          }
          return result0;
        }
        
        function parse_PNAME_LN() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_PNAME_NS();
          if (result0 !== null) {
            result1 = parse_PN_LOCAL();
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, p, s) { return [p, s] })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[124] PNAME_LN");
          }
          return result0;
        }
        
        function parse_BLANK_NODE_LABEL() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 2) === "_:") {
            result0 = "_:";
            pos += 2;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"_:\"");
            }
          }
          if (result0 !== null) {
            result1 = parse_PN_LOCAL();
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, l) { return l })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[125] BLANK_NODE_LABEL");
          }
          return result0;
        }
        
        function parse_VAR1() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.charCodeAt(pos) === 63) {
            result0 = "?";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"?\"");
            }
          }
          if (result0 !== null) {
            result1 = parse_VARNAME();
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, v) { return v })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[126] VAR1");
          }
          return result0;
        }
        
        function parse_VAR2() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.charCodeAt(pos) === 36) {
            result0 = "$";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"$\"");
            }
          }
          if (result0 !== null) {
            result1 = parse_VARNAME();
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, v) { return v })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[127] VAR2");
          }
          return result0;
        }
        
        function parse_LANGTAG() {
          var result0, result1, result2, result3, result4, result5;
          var pos0, pos1, pos2;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.charCodeAt(pos) === 64) {
            result0 = "@";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"@\"");
            }
          }
          if (result0 !== null) {
            if (/^[a-zA-Z]/.test(input.charAt(pos))) {
              result2 = input.charAt(pos);
              pos++;
            } else {
              result2 = null;
              if (reportFailures === 0) {
                matchFailed("[a-zA-Z]");
              }
            }
            if (result2 !== null) {
              result1 = [];
              while (result2 !== null) {
                result1.push(result2);
                if (/^[a-zA-Z]/.test(input.charAt(pos))) {
                  result2 = input.charAt(pos);
                  pos++;
                } else {
                  result2 = null;
                  if (reportFailures === 0) {
                    matchFailed("[a-zA-Z]");
                  }
                }
              }
            } else {
              result1 = null;
            }
            if (result1 !== null) {
              result2 = [];
              pos2 = pos;
              if (input.charCodeAt(pos) === 45) {
                result3 = "-";
                pos++;
              } else {
                result3 = null;
                if (reportFailures === 0) {
                  matchFailed("\"-\"");
                }
              }
              if (result3 !== null) {
                if (/^[a-zA-Z0-9]/.test(input.charAt(pos))) {
                  result5 = input.charAt(pos);
                  pos++;
                } else {
                  result5 = null;
                  if (reportFailures === 0) {
                    matchFailed("[a-zA-Z0-9]");
                  }
                }
                if (result5 !== null) {
                  result4 = [];
                  while (result5 !== null) {
                    result4.push(result5);
                    if (/^[a-zA-Z0-9]/.test(input.charAt(pos))) {
                      result5 = input.charAt(pos);
                      pos++;
                    } else {
                      result5 = null;
                      if (reportFailures === 0) {
                        matchFailed("[a-zA-Z0-9]");
                      }
                    }
                  }
                } else {
                  result4 = null;
                }
                if (result4 !== null) {
                  result3 = [result3, result4];
                } else {
                  result3 = null;
                  pos = pos2;
                }
              } else {
                result3 = null;
                pos = pos2;
              }
              while (result3 !== null) {
                result2.push(result3);
                pos2 = pos;
                if (input.charCodeAt(pos) === 45) {
                  result3 = "-";
                  pos++;
                } else {
                  result3 = null;
                  if (reportFailures === 0) {
                    matchFailed("\"-\"");
                  }
                }
                if (result3 !== null) {
                  if (/^[a-zA-Z0-9]/.test(input.charAt(pos))) {
                    result5 = input.charAt(pos);
                    pos++;
                  } else {
                    result5 = null;
                    if (reportFailures === 0) {
                      matchFailed("[a-zA-Z0-9]");
                    }
                  }
                  if (result5 !== null) {
                    result4 = [];
                    while (result5 !== null) {
                      result4.push(result5);
                      if (/^[a-zA-Z0-9]/.test(input.charAt(pos))) {
                        result5 = input.charAt(pos);
                        pos++;
                      } else {
                        result5 = null;
                        if (reportFailures === 0) {
                          matchFailed("[a-zA-Z0-9]");
                        }
                      }
                    }
                  } else {
                    result4 = null;
                  }
                  if (result4 !== null) {
                    result3 = [result3, result4];
                  } else {
                    result3 = null;
                    pos = pos2;
                  }
                } else {
                  result3 = null;
                  pos = pos2;
                }
              }
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, a, b) {
          
                if(b.length===0) {
                    return ("@"+a.join('')).toLowerCase();
                } else {
                    return ("@"+a.join('')+"-"+b[0][1].join('')).toLowerCase();
                }
          })(pos0, result0[1], result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[128] LANGTAG");
          }
          return result0;
        }
        
        function parse_INTEGER() {
          var result0, result1;
          var pos0;
          
          reportFailures++;
          pos0 = pos;
          if (/^[0-9]/.test(input.charAt(pos))) {
            result1 = input.charAt(pos);
            pos++;
          } else {
            result1 = null;
            if (reportFailures === 0) {
              matchFailed("[0-9]");
            }
          }
          if (result1 !== null) {
            result0 = [];
            while (result1 !== null) {
              result0.push(result1);
              if (/^[0-9]/.test(input.charAt(pos))) {
                result1 = input.charAt(pos);
                pos++;
              } else {
                result1 = null;
                if (reportFailures === 0) {
                  matchFailed("[0-9]");
                }
              }
            }
          } else {
            result0 = null;
          }
          if (result0 !== null) {
            result0 = (function(offset, d) {
                var lit = {};
                lit.token = "literal";
                lit.lang = null;
                lit.type = "http://www.w3.org/2001/XMLSchema#integer";
                lit.value = flattenString(d);
                return lit;
          })(pos0, result0);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[129] INTEGER");
          }
          return result0;
        }
        
        function parse_DECIMAL() {
          var result0, result1, result2, result3;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (/^[0-9]/.test(input.charAt(pos))) {
            result1 = input.charAt(pos);
            pos++;
          } else {
            result1 = null;
            if (reportFailures === 0) {
              matchFailed("[0-9]");
            }
          }
          if (result1 !== null) {
            result0 = [];
            while (result1 !== null) {
              result0.push(result1);
              if (/^[0-9]/.test(input.charAt(pos))) {
                result1 = input.charAt(pos);
                pos++;
              } else {
                result1 = null;
                if (reportFailures === 0) {
                  matchFailed("[0-9]");
                }
              }
            }
          } else {
            result0 = null;
          }
          if (result0 !== null) {
            if (input.charCodeAt(pos) === 46) {
              result1 = ".";
              pos++;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("\".\"");
              }
            }
            if (result1 !== null) {
              result2 = [];
              if (/^[0-9]/.test(input.charAt(pos))) {
                result3 = input.charAt(pos);
                pos++;
              } else {
                result3 = null;
                if (reportFailures === 0) {
                  matchFailed("[0-9]");
                }
              }
              while (result3 !== null) {
                result2.push(result3);
                if (/^[0-9]/.test(input.charAt(pos))) {
                  result3 = input.charAt(pos);
                  pos++;
                } else {
                  result3 = null;
                  if (reportFailures === 0) {
                    matchFailed("[0-9]");
                  }
                }
              }
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, a, b, c) {
          
                var lit = {};
                lit.token = "literal";
                lit.lang = null;
                lit.type = "http://www.w3.org/2001/XMLSchema#decimal";
                lit.value = flattenString([a,b,c]);
                return lit;
          })(pos0, result0[0], result0[1], result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            pos1 = pos;
            if (input.charCodeAt(pos) === 46) {
              result0 = ".";
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\".\"");
              }
            }
            if (result0 !== null) {
              if (/^[0-9]/.test(input.charAt(pos))) {
                result2 = input.charAt(pos);
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("[0-9]");
                }
              }
              if (result2 !== null) {
                result1 = [];
                while (result2 !== null) {
                  result1.push(result2);
                  if (/^[0-9]/.test(input.charAt(pos))) {
                    result2 = input.charAt(pos);
                    pos++;
                  } else {
                    result2 = null;
                    if (reportFailures === 0) {
                      matchFailed("[0-9]");
                    }
                  }
                }
              } else {
                result1 = null;
              }
              if (result1 !== null) {
                result0 = [result0, result1];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
            if (result0 !== null) {
              result0 = (function(offset, a, b) {
                  var lit = {};
                  lit.token = "literal";
                  lit.lang = null;
                  lit.type = "http://www.w3.org/2001/XMLSchema#decimal";
                  lit.value = flattenString([a,b]);
                  return lit;
             })(pos0, result0[0], result0[1]);
            }
            if (result0 === null) {
              pos = pos0;
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[130] DECIMAL");
          }
          return result0;
        }
        
        function parse_DOUBLE() {
          var result0, result1, result2, result3;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (/^[0-9]/.test(input.charAt(pos))) {
            result1 = input.charAt(pos);
            pos++;
          } else {
            result1 = null;
            if (reportFailures === 0) {
              matchFailed("[0-9]");
            }
          }
          if (result1 !== null) {
            result0 = [];
            while (result1 !== null) {
              result0.push(result1);
              if (/^[0-9]/.test(input.charAt(pos))) {
                result1 = input.charAt(pos);
                pos++;
              } else {
                result1 = null;
                if (reportFailures === 0) {
                  matchFailed("[0-9]");
                }
              }
            }
          } else {
            result0 = null;
          }
          if (result0 !== null) {
            if (input.charCodeAt(pos) === 46) {
              result1 = ".";
              pos++;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("\".\"");
              }
            }
            if (result1 !== null) {
              result2 = [];
              if (/^[0-9]/.test(input.charAt(pos))) {
                result3 = input.charAt(pos);
                pos++;
              } else {
                result3 = null;
                if (reportFailures === 0) {
                  matchFailed("[0-9]");
                }
              }
              while (result3 !== null) {
                result2.push(result3);
                if (/^[0-9]/.test(input.charAt(pos))) {
                  result3 = input.charAt(pos);
                  pos++;
                } else {
                  result3 = null;
                  if (reportFailures === 0) {
                    matchFailed("[0-9]");
                  }
                }
              }
              if (result2 !== null) {
                result3 = parse_EXPONENT();
                if (result3 !== null) {
                  result0 = [result0, result1, result2, result3];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, a, b, c, e) {
                var lit = {};
                lit.token = "literal";
                lit.lang = null;
                lit.type = "http://www.w3.org/2001/XMLSchema#double";
                lit.value = flattenString([a,b,c,e]);
                return lit;
          })(pos0, result0[0], result0[1], result0[2], result0[3]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          if (result0 === null) {
            pos0 = pos;
            pos1 = pos;
            if (input.charCodeAt(pos) === 46) {
              result0 = ".";
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\".\"");
              }
            }
            if (result0 !== null) {
              if (/^[0-9]/.test(input.charAt(pos))) {
                result2 = input.charAt(pos);
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("[0-9]");
                }
              }
              if (result2 !== null) {
                result1 = [];
                while (result2 !== null) {
                  result1.push(result2);
                  if (/^[0-9]/.test(input.charAt(pos))) {
                    result2 = input.charAt(pos);
                    pos++;
                  } else {
                    result2 = null;
                    if (reportFailures === 0) {
                      matchFailed("[0-9]");
                    }
                  }
                }
              } else {
                result1 = null;
              }
              if (result1 !== null) {
                result2 = parse_EXPONENT();
                if (result2 !== null) {
                  result0 = [result0, result1, result2];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
            if (result0 !== null) {
              result0 = (function(offset, a, b, c) {
                  var lit = {};
                  lit.token = "literal";
                  lit.lang = null;
                  lit.type = "http://www.w3.org/2001/XMLSchema#double";
                  lit.value = flattenString([a,b,c]);
                  return lit;
            })(pos0, result0[0], result0[1], result0[2]);
            }
            if (result0 === null) {
              pos = pos0;
            }
            if (result0 === null) {
              pos0 = pos;
              pos1 = pos;
              if (/^[0-9]/.test(input.charAt(pos))) {
                result1 = input.charAt(pos);
                pos++;
              } else {
                result1 = null;
                if (reportFailures === 0) {
                  matchFailed("[0-9]");
                }
              }
              if (result1 !== null) {
                result0 = [];
                while (result1 !== null) {
                  result0.push(result1);
                  if (/^[0-9]/.test(input.charAt(pos))) {
                    result1 = input.charAt(pos);
                    pos++;
                  } else {
                    result1 = null;
                    if (reportFailures === 0) {
                      matchFailed("[0-9]");
                    }
                  }
                }
              } else {
                result0 = null;
              }
              if (result0 !== null) {
                result1 = parse_EXPONENT();
                if (result1 !== null) {
                  result0 = [result0, result1];
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
              if (result0 !== null) {
                result0 = (function(offset, a, b) {
                    var lit = {};
                    lit.token = "literal";
                    lit.lang = null;
                    lit.type = "http://www.w3.org/2001/XMLSchema#double";
                    lit.value = flattenString([a,b]);
                    return lit;
              })(pos0, result0[0], result0[1]);
              }
              if (result0 === null) {
                pos = pos0;
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[131] DOUBLE");
          }
          return result0;
        }
        
        function parse_INTEGER_POSITIVE() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.charCodeAt(pos) === 43) {
            result0 = "+";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"+\"");
            }
          }
          if (result0 !== null) {
            result1 = parse_INTEGER();
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, d) { d.value = "+"+d.value; return d; })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[132] INTEGER_POSITIVE");
          }
          return result0;
        }
        
        function parse_DECIMAL_POSITIVE() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.charCodeAt(pos) === 43) {
            result0 = "+";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"+\"");
            }
          }
          if (result0 !== null) {
            result1 = parse_DECIMAL();
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, d) { d.value = "+"+d.value; return d })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[133] DECIMAL_POSITIVE");
          }
          return result0;
        }
        
        function parse_DOUBLE_POSITIVE() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.charCodeAt(pos) === 43) {
            result0 = "+";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"+\"");
            }
          }
          if (result0 !== null) {
            result1 = parse_DOUBLE();
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, d) { d.value = "+"+d.value; return d })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[134] DOUBLE_POSITIVE");
          }
          return result0;
        }
        
        function parse_INTEGER_NEGATIVE() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.charCodeAt(pos) === 45) {
            result0 = "-";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"-\"");
            }
          }
          if (result0 !== null) {
            result1 = parse_INTEGER();
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, d) { d.value = "-"+d.value; return d; })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[135] INTEGER_NEGATIVE");
          }
          return result0;
        }
        
        function parse_DECIMAL_NEGATIVE() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.charCodeAt(pos) === 45) {
            result0 = "-";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"-\"");
            }
          }
          if (result0 !== null) {
            result1 = parse_DECIMAL();
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, d) { d.value = "-"+d.value; return d; })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[136] DECIMAL_NEGATIVE");
          }
          return result0;
        }
        
        function parse_DOUBLE_NEGATIVE() {
          var result0, result1;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.charCodeAt(pos) === 45) {
            result0 = "-";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"-\"");
            }
          }
          if (result0 !== null) {
            result1 = parse_DOUBLE();
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, d) { d.value = "-"+d.value; return d; })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[137] DOUBLE_NEGATIVE");
          }
          return result0;
        }
        
        function parse_EXPONENT() {
          var result0, result1, result2, result3;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (/^[eE]/.test(input.charAt(pos))) {
            result0 = input.charAt(pos);
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("[eE]");
            }
          }
          if (result0 !== null) {
            if (/^[+\-]/.test(input.charAt(pos))) {
              result1 = input.charAt(pos);
              pos++;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("[+\\-]");
              }
            }
            result1 = result1 !== null ? result1 : "";
            if (result1 !== null) {
              if (/^[0-9]/.test(input.charAt(pos))) {
                result3 = input.charAt(pos);
                pos++;
              } else {
                result3 = null;
                if (reportFailures === 0) {
                  matchFailed("[0-9]");
                }
              }
              if (result3 !== null) {
                result2 = [];
                while (result3 !== null) {
                  result2.push(result3);
                  if (/^[0-9]/.test(input.charAt(pos))) {
                    result3 = input.charAt(pos);
                    pos++;
                  } else {
                    result3 = null;
                    if (reportFailures === 0) {
                      matchFailed("[0-9]");
                    }
                  }
                }
              } else {
                result2 = null;
              }
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, a, b, c) { return flattenString([a,b,c]) })(pos0, result0[0], result0[1], result0[2]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[138] EXPONENT");
          }
          return result0;
        }
        
        function parse_STRING_LITERAL1() {
          var result0, result1, result2;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.charCodeAt(pos) === 39) {
            result0 = "'";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"'\"");
            }
          }
          if (result0 !== null) {
            result1 = [];
            if (/^[^'\\\n\r]/.test(input.charAt(pos))) {
              result2 = input.charAt(pos);
              pos++;
            } else {
              result2 = null;
              if (reportFailures === 0) {
                matchFailed("[^'\\\\\\n\\r]");
              }
            }
            if (result2 === null) {
              result2 = parse_ECHAR();
            }
            while (result2 !== null) {
              result1.push(result2);
              if (/^[^'\\\n\r]/.test(input.charAt(pos))) {
                result2 = input.charAt(pos);
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("[^'\\\\\\n\\r]");
                }
              }
              if (result2 === null) {
                result2 = parse_ECHAR();
              }
            }
            if (result1 !== null) {
              if (input.charCodeAt(pos) === 39) {
                result2 = "'";
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"'\"");
                }
              }
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, content) { return flattenString(content) })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[139] STRING_LITERAL1");
          }
          return result0;
        }
        
        function parse_STRING_LITERAL2() {
          var result0, result1, result2;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.charCodeAt(pos) === 34) {
            result0 = "\"";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"\\\"\"");
            }
          }
          if (result0 !== null) {
            result1 = [];
            if (/^[^"\\\n\r]/.test(input.charAt(pos))) {
              result2 = input.charAt(pos);
              pos++;
            } else {
              result2 = null;
              if (reportFailures === 0) {
                matchFailed("[^\"\\\\\\n\\r]");
              }
            }
            if (result2 === null) {
              result2 = parse_ECHAR();
            }
            while (result2 !== null) {
              result1.push(result2);
              if (/^[^"\\\n\r]/.test(input.charAt(pos))) {
                result2 = input.charAt(pos);
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("[^\"\\\\\\n\\r]");
                }
              }
              if (result2 === null) {
                result2 = parse_ECHAR();
              }
            }
            if (result1 !== null) {
              if (input.charCodeAt(pos) === 34) {
                result2 = "\"";
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"\\\"\"");
                }
              }
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, content) { return flattenString(content) })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[140] STRING_LITERAL2");
          }
          return result0;
        }
        
        function parse_STRING_LITERAL_LONG1() {
          var result0, result1, result2;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 3) === "'''") {
            result0 = "'''";
            pos += 3;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"'''\"");
            }
          }
          if (result0 !== null) {
            result1 = [];
            if (/^[^'\\]/.test(input.charAt(pos))) {
              result2 = input.charAt(pos);
              pos++;
            } else {
              result2 = null;
              if (reportFailures === 0) {
                matchFailed("[^'\\\\]");
              }
            }
            if (result2 === null) {
              result2 = parse_ECHAR();
            }
            while (result2 !== null) {
              result1.push(result2);
              if (/^[^'\\]/.test(input.charAt(pos))) {
                result2 = input.charAt(pos);
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("[^'\\\\]");
                }
              }
              if (result2 === null) {
                result2 = parse_ECHAR();
              }
            }
            if (result1 !== null) {
              if (input.substr(pos, 3) === "'''") {
                result2 = "'''";
                pos += 3;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"'''\"");
                }
              }
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, content) { return flattenString(content) })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[141] STRING_LITERAL_LONG1");
          }
          return result0;
        }
        
        function parse_STRING_LITERAL_LONG2() {
          var result0, result1, result2;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.substr(pos, 3) === "\"\"\"") {
            result0 = "\"\"\"";
            pos += 3;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"\\\"\\\"\\\"\"");
            }
          }
          if (result0 !== null) {
            result1 = [];
            if (/^[^"\\]/.test(input.charAt(pos))) {
              result2 = input.charAt(pos);
              pos++;
            } else {
              result2 = null;
              if (reportFailures === 0) {
                matchFailed("[^\"\\\\]");
              }
            }
            if (result2 === null) {
              result2 = parse_ECHAR();
            }
            while (result2 !== null) {
              result1.push(result2);
              if (/^[^"\\]/.test(input.charAt(pos))) {
                result2 = input.charAt(pos);
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("[^\"\\\\]");
                }
              }
              if (result2 === null) {
                result2 = parse_ECHAR();
              }
            }
            if (result1 !== null) {
              if (input.substr(pos, 3) === "\"\"\"") {
                result2 = "\"\"\"";
                pos += 3;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"\\\"\\\"\\\"\"");
                }
              }
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, content) { return flattenString(content) })(pos0, result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[142] STRING_LITERAL_LONG2");
          }
          return result0;
        }
        
        function parse_ECHAR() {
          var result0, result1;
          var pos0;
          
          reportFailures++;
          pos0 = pos;
          if (input.charCodeAt(pos) === 92) {
            result0 = "\\";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"\\\\\"");
            }
          }
          if (result0 !== null) {
            if (/^[tbnrf"']/.test(input.charAt(pos))) {
              result1 = input.charAt(pos);
              pos++;
            } else {
              result1 = null;
              if (reportFailures === 0) {
                matchFailed("[tbnrf\"']");
              }
            }
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos0;
            }
          } else {
            result0 = null;
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[143] ECHAR");
          }
          return result0;
        }
        
        function parse_NIL() {
          var result0, result1, result2;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          if (input.charCodeAt(pos) === 40) {
            result0 = "(";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"(\"");
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              if (input.charCodeAt(pos) === 41) {
                result2 = ")";
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\")\"");
                }
              }
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset) {
          
                return  {token: "triplesnodecollection", 
                         triplesContext:[], 
                         chainSubject:[{token:'uri', value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"}]};
          })(pos0);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[144] NIL");
          }
          return result0;
        }
        
        function parse_WS() {
          var result0;
          
          reportFailures++;
          if (/^[ ]/.test(input.charAt(pos))) {
            result0 = input.charAt(pos);
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("[ ]");
            }
          }
          if (result0 === null) {
            if (/^[\t]/.test(input.charAt(pos))) {
              result0 = input.charAt(pos);
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("[\\t]");
              }
            }
            if (result0 === null) {
              if (/^[\r]/.test(input.charAt(pos))) {
                result0 = input.charAt(pos);
                pos++;
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("[\\r]");
                }
              }
              if (result0 === null) {
                if (/^[\n]/.test(input.charAt(pos))) {
                  result0 = input.charAt(pos);
                  pos++;
                } else {
                  result0 = null;
                  if (reportFailures === 0) {
                    matchFailed("[\\n]");
                  }
                }
                if (result0 === null) {
                  result0 = parse_COMMENT();
                }
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[145] WS");
          }
          return result0;
        }
        
        function parse_COMMENT() {
          var result0, result1, result2;
          var pos0;
          
          reportFailures++;
          pos0 = pos;
          if (input.charCodeAt(pos) === 35) {
            result0 = "#";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"#\"");
            }
          }
          if (result0 !== null) {
            result1 = [];
            if (/^[^\n\r]/.test(input.charAt(pos))) {
              result2 = input.charAt(pos);
              pos++;
            } else {
              result2 = null;
              if (reportFailures === 0) {
                matchFailed("[^\\n\\r]");
              }
            }
            while (result2 !== null) {
              result1.push(result2);
              if (/^[^\n\r]/.test(input.charAt(pos))) {
                result2 = input.charAt(pos);
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("[^\\n\\r]");
                }
              }
            }
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos0;
            }
          } else {
            result0 = null;
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed(" COMMENT");
          }
          return result0;
        }
        
        function parse_ANON() {
          var result0, result1, result2;
          var pos0;
          
          reportFailures++;
          pos0 = pos;
          if (input.charCodeAt(pos) === 91) {
            result0 = "[";
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("\"[\"");
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_WS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_WS();
            }
            if (result1 !== null) {
              if (input.charCodeAt(pos) === 93) {
                result2 = "]";
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\"]\"");
                }
              }
              if (result2 !== null) {
                result0 = [result0, result1, result2];
              } else {
                result0 = null;
                pos = pos0;
              }
            } else {
              result0 = null;
              pos = pos0;
            }
          } else {
            result0 = null;
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[146] ANON");
          }
          return result0;
        }
        
        function parse_PN_CHARS_BASE() {
          var result0;
          
          reportFailures++;
          if (/^[A-Z]/.test(input.charAt(pos))) {
            result0 = input.charAt(pos);
            pos++;
          } else {
            result0 = null;
            if (reportFailures === 0) {
              matchFailed("[A-Z]");
            }
          }
          if (result0 === null) {
            if (/^[a-z]/.test(input.charAt(pos))) {
              result0 = input.charAt(pos);
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("[a-z]");
              }
            }
            if (result0 === null) {
              if (/^[\xC0-\xD6]/.test(input.charAt(pos))) {
                result0 = input.charAt(pos);
                pos++;
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("[\\xC0-\\xD6]");
                }
              }
              if (result0 === null) {
                if (/^[\xD8-\xF6]/.test(input.charAt(pos))) {
                  result0 = input.charAt(pos);
                  pos++;
                } else {
                  result0 = null;
                  if (reportFailures === 0) {
                    matchFailed("[\\xD8-\\xF6]");
                  }
                }
                if (result0 === null) {
                  if (/^[\xF8-\u02FF]/.test(input.charAt(pos))) {
                    result0 = input.charAt(pos);
                    pos++;
                  } else {
                    result0 = null;
                    if (reportFailures === 0) {
                      matchFailed("[\\xF8-\\u02FF]");
                    }
                  }
                  if (result0 === null) {
                    if (/^[\u0370-\u037D]/.test(input.charAt(pos))) {
                      result0 = input.charAt(pos);
                      pos++;
                    } else {
                      result0 = null;
                      if (reportFailures === 0) {
                        matchFailed("[\\u0370-\\u037D]");
                      }
                    }
                    if (result0 === null) {
                      if (/^[\u037F-\u1FFF]/.test(input.charAt(pos))) {
                        result0 = input.charAt(pos);
                        pos++;
                      } else {
                        result0 = null;
                        if (reportFailures === 0) {
                          matchFailed("[\\u037F-\\u1FFF]");
                        }
                      }
                      if (result0 === null) {
                        if (/^[\u200C-\u200D]/.test(input.charAt(pos))) {
                          result0 = input.charAt(pos);
                          pos++;
                        } else {
                          result0 = null;
                          if (reportFailures === 0) {
                            matchFailed("[\\u200C-\\u200D]");
                          }
                        }
                        if (result0 === null) {
                          if (/^[\u2070-\u218F]/.test(input.charAt(pos))) {
                            result0 = input.charAt(pos);
                            pos++;
                          } else {
                            result0 = null;
                            if (reportFailures === 0) {
                              matchFailed("[\\u2070-\\u218F]");
                            }
                          }
                          if (result0 === null) {
                            if (/^[\u2C00-\u2FEF]/.test(input.charAt(pos))) {
                              result0 = input.charAt(pos);
                              pos++;
                            } else {
                              result0 = null;
                              if (reportFailures === 0) {
                                matchFailed("[\\u2C00-\\u2FEF]");
                              }
                            }
                            if (result0 === null) {
                              if (/^[\u3001-\uD7FF]/.test(input.charAt(pos))) {
                                result0 = input.charAt(pos);
                                pos++;
                              } else {
                                result0 = null;
                                if (reportFailures === 0) {
                                  matchFailed("[\\u3001-\\uD7FF]");
                                }
                              }
                              if (result0 === null) {
                                if (/^[\uF900-\uFDCF]/.test(input.charAt(pos))) {
                                  result0 = input.charAt(pos);
                                  pos++;
                                } else {
                                  result0 = null;
                                  if (reportFailures === 0) {
                                    matchFailed("[\\uF900-\\uFDCF]");
                                  }
                                }
                                if (result0 === null) {
                                  if (/^[\uFDF0-\uFFFD]/.test(input.charAt(pos))) {
                                    result0 = input.charAt(pos);
                                    pos++;
                                  } else {
                                    result0 = null;
                                    if (reportFailures === 0) {
                                      matchFailed("[\\uFDF0-\\uFFFD]");
                                    }
                                  }
                                  if (result0 === null) {
                                    if (/^[\u1000-\uEFFF]/.test(input.charAt(pos))) {
                                      result0 = input.charAt(pos);
                                      pos++;
                                    } else {
                                      result0 = null;
                                      if (reportFailures === 0) {
                                        matchFailed("[\\u1000-\\uEFFF]");
                                      }
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[147] PN_CHARS_BASE");
          }
          return result0;
        }
        
        function parse_PN_CHARS_U() {
          var result0;
          
          reportFailures++;
          result0 = parse_PN_CHARS_BASE();
          if (result0 === null) {
            if (input.charCodeAt(pos) === 95) {
              result0 = "_";
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"_\"");
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[148] PN_CHARS_U");
          }
          return result0;
        }
        
        function parse_VARNAME() {
          var result0, result1, result2;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_PN_CHARS_U();
          if (result0 === null) {
            if (/^[0-9]/.test(input.charAt(pos))) {
              result0 = input.charAt(pos);
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("[0-9]");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_PN_CHARS_U();
            if (result2 === null) {
              if (/^[0-9]/.test(input.charAt(pos))) {
                result2 = input.charAt(pos);
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("[0-9]");
                }
              }
              if (result2 === null) {
                if (/^[\xB7]/.test(input.charAt(pos))) {
                  result2 = input.charAt(pos);
                  pos++;
                } else {
                  result2 = null;
                  if (reportFailures === 0) {
                    matchFailed("[\\xB7]");
                  }
                }
                if (result2 === null) {
                  if (/^[\u0300-\u036F]/.test(input.charAt(pos))) {
                    result2 = input.charAt(pos);
                    pos++;
                  } else {
                    result2 = null;
                    if (reportFailures === 0) {
                      matchFailed("[\\u0300-\\u036F]");
                    }
                  }
                  if (result2 === null) {
                    if (/^[\u203F-\u2040]/.test(input.charAt(pos))) {
                      result2 = input.charAt(pos);
                      pos++;
                    } else {
                      result2 = null;
                      if (reportFailures === 0) {
                        matchFailed("[\\u203F-\\u2040]");
                      }
                    }
                  }
                }
              }
            }
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_PN_CHARS_U();
              if (result2 === null) {
                if (/^[0-9]/.test(input.charAt(pos))) {
                  result2 = input.charAt(pos);
                  pos++;
                } else {
                  result2 = null;
                  if (reportFailures === 0) {
                    matchFailed("[0-9]");
                  }
                }
                if (result2 === null) {
                  if (/^[\xB7]/.test(input.charAt(pos))) {
                    result2 = input.charAt(pos);
                    pos++;
                  } else {
                    result2 = null;
                    if (reportFailures === 0) {
                      matchFailed("[\\xB7]");
                    }
                  }
                  if (result2 === null) {
                    if (/^[\u0300-\u036F]/.test(input.charAt(pos))) {
                      result2 = input.charAt(pos);
                      pos++;
                    } else {
                      result2 = null;
                      if (reportFailures === 0) {
                        matchFailed("[\\u0300-\\u036F]");
                      }
                    }
                    if (result2 === null) {
                      if (/^[\u203F-\u2040]/.test(input.charAt(pos))) {
                        result2 = input.charAt(pos);
                        pos++;
                      } else {
                        result2 = null;
                        if (reportFailures === 0) {
                          matchFailed("[\\u203F-\\u2040]");
                        }
                      }
                    }
                  }
                }
              }
            }
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, init, rpart) { return init+rpart.join('') })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[149] VARNAME");
          }
          return result0;
        }
        
        function parse_PN_CHARS() {
          var result0;
          
          reportFailures++;
          result0 = parse_PN_CHARS_U();
          if (result0 === null) {
            if (input.charCodeAt(pos) === 45) {
              result0 = "-";
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("\"-\"");
              }
            }
            if (result0 === null) {
              if (/^[0-9]/.test(input.charAt(pos))) {
                result0 = input.charAt(pos);
                pos++;
              } else {
                result0 = null;
                if (reportFailures === 0) {
                  matchFailed("[0-9]");
                }
              }
              if (result0 === null) {
                if (/^[\xB7]/.test(input.charAt(pos))) {
                  result0 = input.charAt(pos);
                  pos++;
                } else {
                  result0 = null;
                  if (reportFailures === 0) {
                    matchFailed("[\\xB7]");
                  }
                }
                if (result0 === null) {
                  if (/^[\u0300-\u036F]/.test(input.charAt(pos))) {
                    result0 = input.charAt(pos);
                    pos++;
                  } else {
                    result0 = null;
                    if (reportFailures === 0) {
                      matchFailed("[\\u0300-\\u036F]");
                    }
                  }
                  if (result0 === null) {
                    if (/^[\u203F-\u2040]/.test(input.charAt(pos))) {
                      result0 = input.charAt(pos);
                      pos++;
                    } else {
                      result0 = null;
                      if (reportFailures === 0) {
                        matchFailed("[\\u203F-\\u2040]");
                      }
                    }
                  }
                }
              }
            }
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[150] PN_CHARS");
          }
          return result0;
        }
        
        function parse_PN_PREFIX() {
          var result0, result1, result2;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_PN_CHARS_BASE();
          if (result0 !== null) {
            result1 = [];
            result2 = parse_PN_CHARS();
            if (result2 === null) {
              if (input.charCodeAt(pos) === 46) {
                result2 = ".";
                pos++;
              } else {
                result2 = null;
                if (reportFailures === 0) {
                  matchFailed("\".\"");
                }
              }
            }
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_PN_CHARS();
              if (result2 === null) {
                if (input.charCodeAt(pos) === 46) {
                  result2 = ".";
                  pos++;
                } else {
                  result2 = null;
                  if (reportFailures === 0) {
                    matchFailed("\".\"");
                  }
                }
              }
            }
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, base, rest) { if(rest[rest.length-1] == '.'){
                                                        	throw new Error("Wrong PN_PREFIX, cannot finish with '.'")
          					      } else {
          						  return base + rest.join('');
          					      }})(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[151] PN_PREFIX");
          }
          return result0;
        }
        
        function parse_PN_LOCAL() {
          var result0, result1, result2;
          var pos0, pos1;
          
          reportFailures++;
          pos0 = pos;
          pos1 = pos;
          result0 = parse_PN_CHARS_U();
          if (result0 === null) {
            if (/^[0-9]/.test(input.charAt(pos))) {
              result0 = input.charAt(pos);
              pos++;
            } else {
              result0 = null;
              if (reportFailures === 0) {
                matchFailed("[0-9]");
              }
            }
          }
          if (result0 !== null) {
            result1 = [];
            result2 = parse_PN_CHARS();
            while (result2 !== null) {
              result1.push(result2);
              result2 = parse_PN_CHARS();
            }
            if (result1 !== null) {
              result0 = [result0, result1];
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
          if (result0 !== null) {
            result0 = (function(offset, base, rest) { 
                                                                 return base + rest.join('');
                                                               })(pos0, result0[0], result0[1]);
          }
          if (result0 === null) {
            pos = pos0;
          }
          reportFailures--;
          if (reportFailures === 0 && result0 === null) {
            matchFailed("[152] PN_LOCAL");
          }
          return result0;
        }
        
        
        function cleanupExpected(expected) {
          expected.sort();
          
          var lastExpected = null;
          var cleanExpected = [];
          for (var i = 0; i < expected.length; i++) {
            if (expected[i] !== lastExpected) {
              cleanExpected.push(expected[i]);
              lastExpected = expected[i];
            }
          }
          return cleanExpected;
        }
        
        function computeErrorPosition() {
          /*
           * The first idea was to use |String.split| to break the input up to the
           * error position along newlines and derive the line and column from
           * there. However IE's |split| implementation is so broken that it was
           * enough to prevent it.
           */
          
          var line = 1;
          var column = 1;
          var seenCR = false;
          
          for (var i = 0; i < Math.max(pos, rightmostFailuresPos); i++) {
            var ch = input.charAt(i);
            if (ch === "\n") {
              if (!seenCR) { line++; }
              column = 1;
              seenCR = false;
            } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
              line++;
              column = 1;
              seenCR = true;
            } else {
              column++;
              seenCR = false;
            }
          }
          
          return { line: line, column: column };
        }
        
        
            var flattenString = function(arrs) {
                var acum ="";
                for(var i=0; i< arrs.length; i++) {
                  if(typeof(arrs[i])==='string') {
                    acum = acum + arrs[i];
                  } else {
                    acum = acum + arrs[i].join('');
                  }
                }
        
                return acum;
            }
        
        
            var GlobalBlankNodeCounter = 0;
        
            var prefixes = {};
        
            var registerPrefix = function(prefix, uri) {
                prefixes[prefix] = uri;
            }
        
            var registerDefaultPrefix = function(uri) {
                prefixes[null] = uri;
            }
        
            var arrayToString = function(array) {
                var tmp = "";
                for(var i=0; i<array.length; i++) {
                    tmp = tmp + array[i];            
                }
        
                return tmp.toUpperCase();
            }
        
        
        var result = parseFunctions[startRule]();
        
        /*
         * The parser is now in one of the following three states:
         *
         * 1. The parser successfully parsed the whole input.
         *
         *    - |result !== null|
         *    - |pos === input.length|
         *    - |rightmostFailuresExpected| may or may not contain something
         *
         * 2. The parser successfully parsed only a part of the input.
         *
         *    - |result !== null|
         *    - |pos < input.length|
         *    - |rightmostFailuresExpected| may or may not contain something
         *
         * 3. The parser did not successfully parse any part of the input.
         *
         *   - |result === null|
         *   - |pos === 0|
         *   - |rightmostFailuresExpected| contains at least one failure
         *
         * All code following this comment (including called functions) must
         * handle these states.
         */
        if (result === null || pos !== input.length) {
          var offset = Math.max(pos, rightmostFailuresPos);
          var found = offset < input.length ? input.charAt(offset) : null;
          var errorPosition = computeErrorPosition();
          
          throw new this.SyntaxError(
            cleanupExpected(rightmostFailuresExpected),
            found,
            offset,
            errorPosition.line,
            errorPosition.column
          );
        }
        
        return result;
      },
      
      /* Returns the parser source code. */
      toSource: function() { return this._source; }
    };
    
    /* Thrown when a parser encounters a syntax error. */
    
    result.SyntaxError = function(expected, found, offset, line, column) {
      function buildMessage(expected, found) {
        var expectedHumanized, foundHumanized;
        
        switch (expected.length) {
          case 0:
            expectedHumanized = "end of input";
            break;
          case 1:
            expectedHumanized = expected[0];
            break;
          default:
            expectedHumanized = expected.slice(0, expected.length - 1).join(", ")
              + " or "
              + expected[expected.length - 1];
        }
        
        foundHumanized = found ? quote(found) : "end of input";
        
        return "Expected " + expectedHumanized + " but " + foundHumanized + " found.";
      }
      
      this.name = "SyntaxError";
      this.expected = expected;
      this.found = found;
      this.message = buildMessage(expected, found);
      this.offset = offset;
      this.line = line;
      this.column = column;
    };
    
    result.SyntaxError.prototype = Error.prototype;
    
    return result;
  })();