Package lupos.endpoint.client.formatreader.tsv

Source Code of lupos.endpoint.client.formatreader.tsv.TSVParser$LookaheadSuccess

/**
* Copyright (c) 2013, Institute of Information Systems (Sven Groppe and contributors of LUPOSDATE), University of Luebeck
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
*   - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
*     disclaimer.
*   - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
*     following disclaimer in the documentation and/or other materials provided with the distribution.
*   - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote
*     products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Generated By:JJTree&JavaCC: Do not edit this line. TSVParser.java */
package lupos.endpoint.client.formatreader.tsv;

import java.io.*;
import java.net.URISyntaxException;

import lupos.datastructures.items.literal.Literal;
import lupos.datastructures.items.literal.LiteralFactory;
import lupos.datastructures.items.literal.TypedLiteralOriginalContent;
import lupos.datastructures.items.literal.URILiteral;
import lupos.datastructures.items.literal.LanguageTaggedLiteralOriginalLanguage;

public class TSVParser/*@bgen(jjtree)*/implements TSVParserTreeConstants, TSVParserConstants {/*@bgen(jjtree)*/
  protected JJTTSVParserState jjtree = new JJTTSVParserState();public static void main(String args [])
  {
    System.out.println("enter query...");
    TSVParser parser = new TSVParser(System.in);

    try
    {
        parser.expr();
        System.out.println("Result:");
                        ((SimpleNode) parser.jjtree.rootNode()).dump("|");
        } catch(Exception e) {
                System.out.println(e);
                e.printStackTrace();
        }
  }

        public static Literal getLiteral(Node n) {
          return getLiteral(n, false);
        }

        public static Literal getLiteral(Node n, final boolean allowLazyLiteral) {
                Literal literal = null;

                if (n instanceof ASTNIL) {
                        try {
                                literal = (allowLazyLiteral) ? LiteralFactory
                                                .createURILiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>")
                                                : LiteralFactory
                                                                .createURILiteralWithoutLazyLiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>");
                        } catch (final URISyntaxException e1) {
                                e1.printStackTrace();
                        }
                } else if (n instanceof ASTBlankNode) {
                        final ASTBlankNode blankNode = (ASTBlankNode) n;
                        final String name = blankNode.getIdentifier();
                        literal = (allowLazyLiteral) ? LiteralFactory
                                        .createAnonymousLiteral(name) : LiteralFactory
                                        .createAnonymousLiteralWithoutLazyLiteral(name);
                } else if (n instanceof ASTQuotedURIRef) {
                        final ASTQuotedURIRef uri = (ASTQuotedURIRef) n;
                        final String name = uri.getQRef();

                        if (URILiteral.isURI("<" + name + ">")) {
                                try {
                                        literal = (allowLazyLiteral) ? LiteralFactory
                                                        .createURILiteral("<" + name + ">")
                                                        : LiteralFactory
                                                                        .createURILiteralWithoutLazyLiteral("<"
                                                                                        + name + ">");
                                } catch (final Exception e) {
                                        literal = (allowLazyLiteral) ? LiteralFactory
                                                        .createLiteral("<" + name + ">") : LiteralFactory
                                                        .createLiteralWithoutLazyLiteral("<" + name + ">");
                                }
                        } else
                                literal = (allowLazyLiteral) ? LiteralFactory.createLiteral("<"
                                                + name + ">") : LiteralFactory
                                                .createLiteralWithoutLazyLiteral("<" + name + ">");
                } else if (n instanceof ASTRDFLiteral)
                        n = n.jjtGetChild(0);

                if (literal != null)
                        return literal;

                if (n instanceof ASTStringLiteral) {
                        final ASTStringLiteral lit = (ASTStringLiteral) n;
                        final String quotedContent = lit.getStringLiteral();

                        try {
                                literal = (allowLazyLiteral) ? LiteralFactory
                                                .createTypedLiteral(quotedContent,
                                                                "<http://www.w3.org/2001/XMLSchema#string>")
                                                : TypedLiteralOriginalContent.createTypedLiteral(
                                                                quotedContent,
                                                                "<http://www.w3.org/2001/XMLSchema#string>");
                        } catch (final URISyntaxException e) {
                                literal = (allowLazyLiteral) ? LiteralFactory
                                                .createLiteral(quotedContent) : LiteralFactory
                                                .createLiteralWithoutLazyLiteral(quotedContent);
                        }
                } else if (n instanceof ASTInteger) {
                        final ASTInteger lit = (ASTInteger) n;
                        final String content = String.valueOf(lit.getValue());

                        try {
                                literal = (allowLazyLiteral) ? LiteralFactory
                                                .createTypedLiteral("\u005c"" + content + "\u005c"",
                                                                "<http://www.w3.org/2001/XMLSchema#integer>")
                                                : TypedLiteralOriginalContent.createTypedLiteral("\u005c""
                                                                + content + "\u005c"",
                                                                "<http://www.w3.org/2001/XMLSchema#integer>");
                        } catch (final URISyntaxException e) {
                                literal = (allowLazyLiteral) ? LiteralFactory
                                                .createLiteral(content) : LiteralFactory
                                                .createLiteralWithoutLazyLiteral(content);
                        }
                } else if (n instanceof ASTFloatingPoint) {
                        final ASTFloatingPoint lit = (ASTFloatingPoint) n;
                        final String content = lit.getValue();

                        try {
                                if (content.contains("e") || content.contains("E"))
                                        literal = (allowLazyLiteral) ? LiteralFactory
                                                        .createTypedLiteral("\u005c"" + content + "\u005c"",
                                                                        "<http://www.w3.org/2001/XMLSchema#double>")
                                                        : TypedLiteralOriginalContent
                                                                        .createTypedLiteral("\u005c"" + content + "\u005c"",
                                                                                        "<http://www.w3.org/2001/XMLSchema#double>");
                                else
                                        literal = (allowLazyLiteral) ? LiteralFactory
                                                        .createTypedLiteral("\u005c"" + content + "\u005c"",
                                                                        "<http://www.w3.org/2001/XMLSchema#decimal>")
                                                        : TypedLiteralOriginalContent
                                                                        .createTypedLiteral("\u005c"" + content + "\u005c"",
                                                                                        "<http://www.w3.org/2001/XMLSchema#decimal>");
                        } catch (final URISyntaxException e) {
                                literal = (allowLazyLiteral) ? LiteralFactory
                                                .createLiteral(content) : LiteralFactory
                                                .createLiteralWithoutLazyLiteral(content);
                        }
                } else if (n instanceof ASTBooleanLiteral) {
                        final String content = ((ASTBooleanLiteral) n).getState() + "";

                        try {
                                literal = (allowLazyLiteral) ? LiteralFactory
                                                .createTypedLiteral("\u005c"" + content + "\u005c"",
                                                                "<http://www.w3.org/2001/XMLSchema#boolean>")
                                                : TypedLiteralOriginalContent.createTypedLiteral("\u005c""
                                                                + content + "\u005c"",
                                                                "<http://www.w3.org/2001/XMLSchema#boolean>");
                        } catch (final URISyntaxException e) {
                                literal = (allowLazyLiteral) ? LiteralFactory
                                                .createLiteral(content) : LiteralFactory
                                                .createLiteralWithoutLazyLiteral(content);
                        }
                } else if (n instanceof ASTDoubleCircumflex) {
                        if (n.jjtGetNumChildren() != 2)
                                System.err.println(n + " is expected to have 2 children!");
                        else {
                                final String content = getLiteral(n.jjtGetChild(0), allowLazyLiteral).toString();
                                final String type = getLiteral(n.jjtGetChild(1), allowLazyLiteral).toString();

                                try {
                                        literal = (allowLazyLiteral) ? LiteralFactory
                                                        .createTypedLiteral(content, type)
                                                        : TypedLiteralOriginalContent.createTypedLiteral(
                                                                        content, type);
                                } catch (final Exception e) {
                                        literal = (allowLazyLiteral) ? LiteralFactory
                                                        .createLiteral(content + "^^" + type)
                                                        : LiteralFactory
                                                                        .createLiteralWithoutLazyLiteral(content
                                                                                        + "^^" + type);
                                }
                        }
                } else if (n instanceof ASTLangTag) {
                        final String content = getLiteral(n.jjtGetChild(0), allowLazyLiteral).toString();
                        final String lang = ((ASTLangTag) n).getLangTag();
                        literal = (allowLazyLiteral) ? LiteralFactory
                                        .createLanguageTaggedLiteral(content, lang)
                                        : LanguageTaggedLiteralOriginalLanguage
                                                        .createLanguageTaggedLiteral(content, lang);
                } else
                        System.err.println("Unexpected type! "
                                        + n.getClass().getSimpleName());

                return literal;
        }

  public static SimpleNode parse(String query) throws ParseException
  {
    TSVParser parser = new TSVParser(new StringReader(query));
    switch (parser.expr())
    {
      default :
                try {
                        return ((SimpleNode) parser.jjtree.rootNode());
                } catch(Exception e) {
                        return null;
                }
      case 0 : return null;
      case - 1 : return null;
    }
  }

  public static SimpleNode parse(final InputStream inputStream) throws ParseException
  {
    TSVParser parser = new TSVParser(inputStream);
    switch (parser.expr())
    {
      default :
                try {
                        return ((SimpleNode) parser.jjtree.rootNode());
                } catch(Exception e) {
                        return null;
                }
      case 0 : return null;
      case - 1 : return null;
    }
  }

  final public int expr() throws ParseException {
/*@bgen(jjtree) Result */
  ASTResult jjtn000 = new ASTResult(JJTRESULT);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      firstLine();
      jj_consume_token(33);
      label_1:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case IRI_REF:
        case BLANK_NODE_LABEL:
        case INTEGER:
        case DECIMAL:
        case DOUBLE:
        case STRING_LITERAL1:
        case STRING_LITERAL2:
        case STRING_LITERAL_LONG1:
        case STRING_LITERAL_LONG2:
        case NIL:
        case ANON:
        case 33:
        case 34:
        case 36:
        case 37:
        case 38:
        case 39:
          ;
          break;
        default:
          jj_la1[0] = jj_gen;
          break label_1;
        }
        resultLine();
      }
      jj_consume_token(0);
      jjtree.closeNodeScope(jjtn000, true);
      jjtc000 = false;
      {if (true) return 1;}
    } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      {if (true) throw (RuntimeException)jjte000;}
    }
    if (jjte000 instanceof ParseException) {
      {if (true) throw (ParseException)jjte000;}
    }
    {if (true) throw (Error)jjte000;}
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
    throw new Error("Missing return statement in function");
  }

  final public void firstLine() throws ParseException {
/*@bgen(jjtree) Vars */
  ASTVars jjtn000 = new ASTVars(JJTVARS);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case VAR:
        Var();
        label_2:
        while (true) {
          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
          case 34:
            ;
            break;
          default:
            jj_la1[1] = jj_gen;
            break label_2;
          }
          jj_consume_token(34);
          Var();
        }
        break;
      default:
        jj_la1[2] = jj_gen;
        ;
      }
    } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      {if (true) throw (RuntimeException)jjte000;}
    }
    if (jjte000 instanceof ParseException) {
      {if (true) throw (ParseException)jjte000;}
    }
    {if (true) throw (Error)jjte000;}
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
  }

//1
  final public void resultLine() throws ParseException {
/*@bgen(jjtree) OneResult */
  ASTOneResult jjtn000 = new ASTOneResult(JJTONERESULT);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      GraphTerm();
      label_3:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case 34:
          ;
          break;
        default:
          jj_la1[3] = jj_gen;
          break label_3;
        }
        jj_consume_token(34);
        GraphTerm();
      }
      jj_consume_token(33);
    } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      {if (true) throw (RuntimeException)jjte000;}
    }
    if (jjte000 instanceof ParseException) {
      {if (true) throw (ParseException)jjte000;}
    }
    {if (true) throw (Error)jjte000;}
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
  }

//98
  final public void Var() throws ParseException {
/*@bgen(jjtree) Var */
  ASTVar jjtn000 = new ASTVar(JJTVAR);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);Token varName;
    try {
      varName = jj_consume_token(VAR);
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
    jjtn000.setName(varName.image.substring(1));
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
  }

//99
  final public void GraphTerm() throws ParseException {
/*@bgen(jjtree) Value */
  ASTValue jjtn000 = new ASTValue(JJTVALUE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case IRI_REF:
      case BLANK_NODE_LABEL:
      case INTEGER:
      case DECIMAL:
      case DOUBLE:
      case STRING_LITERAL1:
      case STRING_LITERAL2:
      case STRING_LITERAL_LONG1:
      case STRING_LITERAL_LONG2:
      case NIL:
      case ANON:
      case 36:
      case 37:
      case 38:
      case 39:
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case IRI_REF:
          IRIref();
          break;
        case STRING_LITERAL1:
        case STRING_LITERAL2:
        case STRING_LITERAL_LONG1:
        case STRING_LITERAL_LONG2:
          RDFLiteral();
          break;
        case INTEGER:
        case DECIMAL:
        case DOUBLE:
        case 36:
        case 37:
          NumericLiteral();
          break;
        case 38:
        case 39:
          BooleanLiteral();
          break;
        case BLANK_NODE_LABEL:
        case ANON:
          BlankNode();
          break;
        case NIL:
                                                                                     ASTNIL jjtn001 = new ASTNIL(JJTNIL);
                                                                                     boolean jjtc001 = true;
                                                                                     jjtree.openNodeScope(jjtn001);
          try {
            jj_consume_token(NIL);
          } finally {
                                                                                     if (jjtc001) {
                                                                                       jjtree.closeNodeScope(jjtn001, true);
                                                                                     }
          }
          break;
        default:
          jj_la1[4] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
        break;
      default:
        jj_la1[5] = jj_gen;
        ;
      }
    } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      {if (true) throw (RuntimeException)jjte000;}
    }
    if (jjte000 instanceof ParseException) {
      {if (true) throw (ParseException)jjte000;}
    }
    {if (true) throw (Error)jjte000;}
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
  }

  final public void RDFLiteral() throws ParseException {
/*@bgen(jjtree) RDFLiteral */
  ASTRDFLiteral jjtn000 = new ASTRDFLiteral(JJTRDFLITERAL);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      if (jj_2_1(2147483647)) {
        TypedLiteral();
      } else if (jj_2_2(2147483647)) {
        LiteralWithLangTag();
      } else {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case STRING_LITERAL1:
        case STRING_LITERAL2:
        case STRING_LITERAL_LONG1:
        case STRING_LITERAL_LONG2:
          String();
          break;
        default:
          jj_la1[6] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
      }
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  final public void TypedLiteral() throws ParseException {
/*@bgen(jjtree) DoubleCircumflex */
  ASTDoubleCircumflex jjtn000 = new ASTDoubleCircumflex(JJTDOUBLECIRCUMFLEX);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      String();
      jj_consume_token(35);
      IRIref();
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  final public void LiteralWithLangTag() throws ParseException {
/*@bgen(jjtree) LangTag */
  ASTLangTag jjtn000 = new ASTLangTag(JJTLANGTAG);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      String();
      jj_consume_token(LANGTAG);
                               jjtree.closeNodeScope(jjtn000, true);
                               jjtc000 = false;
                               jjtn000.setLangTag(token.image);
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

//120
  final public void NumericLiteral() throws ParseException {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case INTEGER:
    case DECIMAL:
    case DOUBLE:
      NumericLiteralUnsigned();
      break;
    case 36:
      NumericLiteralPositive();
      break;
    case 37:
      NumericLiteralNegative();
      break;
    default:
      jj_la1[7] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

//121
  final public void NumericLiteralUnsigned() throws ParseException {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case INTEGER:
      NumericLiteralUnsignedInteger();
      break;
    case DECIMAL:
    case DOUBLE:
      NumericLiteralUnsignedFloatingPoint();
      break;
    default:
      jj_la1[8] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final public void NumericLiteralUnsignedInteger() throws ParseException {
/*@bgen(jjtree) Integer */
  ASTInteger jjtn000 = new ASTInteger(JJTINTEGER);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      jj_consume_token(INTEGER);
                      jjtree.closeNodeScope(jjtn000, true);
                      jjtc000 = false;
                      jjtn000.setStringInt((token.image));
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  final public void NumericLiteralUnsignedFloatingPoint() throws ParseException {
/*@bgen(jjtree) FloatingPoint */
  ASTFloatingPoint jjtn000 = new ASTFloatingPoint(JJTFLOATINGPOINT);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case DECIMAL:
        jj_consume_token(DECIMAL);
                      jjtree.closeNodeScope(jjtn000, true);
                      jjtc000 = false;
                      jjtn000.setValue((token.image));
        break;
      case DOUBLE:
        jj_consume_token(DOUBLE);
                     jjtree.closeNodeScope(jjtn000, true);
                     jjtc000 = false;
                     jjtn000.setValue((token.image));
        break;
      default:
        jj_la1[9] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

//122
  final public void NumericLiteralPositive() throws ParseException {
    jj_consume_token(36);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case INTEGER:
      NumericLiteralPositiveInteger();
      break;
    case DECIMAL:
    case DOUBLE:
      NumericLiteralPositiveFloatingPoint();
      break;
    default:
      jj_la1[10] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final public void NumericLiteralPositiveInteger() throws ParseException {
/*@bgen(jjtree) Integer */
  ASTInteger jjtn000 = new ASTInteger(JJTINTEGER);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      jj_consume_token(INTEGER);
                      jjtree.closeNodeScope(jjtn000, true);
                      jjtc000 = false;
                      jjtn000.setStringInt((token.image));
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  final public void NumericLiteralPositiveFloatingPoint() throws ParseException {
/*@bgen(jjtree) FloatingPoint */
  ASTFloatingPoint jjtn000 = new ASTFloatingPoint(JJTFLOATINGPOINT);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case DECIMAL:
        jj_consume_token(DECIMAL);
                       jjtree.closeNodeScope(jjtn000, true);
                       jjtc000 = false;
                       jjtn000.setValue((token.image));
        break;
      case DOUBLE:
        jj_consume_token(DOUBLE);
                      jjtree.closeNodeScope(jjtn000, true);
                      jjtc000 = false;
                      jjtn000.setValue((token.image));
        break;
      default:
        jj_la1[11] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

//123
  final public void NumericLiteralNegative() throws ParseException {
    jj_consume_token(37);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case INTEGER:
      NumericLiteralNegativeInteger();
      break;
    case DECIMAL:
    case DOUBLE:
      NumericLiteralNegativeFloatingPoint();
      break;
    default:
      jj_la1[12] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final public void NumericLiteralNegativeInteger() throws ParseException {
/*@bgen(jjtree) Integer */
  ASTInteger jjtn000 = new ASTInteger(JJTINTEGER);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      jj_consume_token(INTEGER);
                      jjtree.closeNodeScope(jjtn000, true);
                      jjtc000 = false;
                      jjtn000.setStringInt("-"+(token.image));
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  final public void NumericLiteralNegativeFloatingPoint() throws ParseException {
/*@bgen(jjtree) FloatingPoint */
  ASTFloatingPoint jjtn000 = new ASTFloatingPoint(JJTFLOATINGPOINT);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case DECIMAL:
        jj_consume_token(DECIMAL);
                       jjtree.closeNodeScope(jjtn000, true);
                       jjtc000 = false;
                       jjtn000.setValue("-"+(token.image));
        break;
      case DOUBLE:
        jj_consume_token(DOUBLE);
                      jjtree.closeNodeScope(jjtn000, true);
                      jjtc000 = false;
                      jjtn000.setValue("-"+(token.image));
        break;
      default:
        jj_la1[13] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

//124
  final public void BooleanLiteral() throws ParseException {
/*@bgen(jjtree) BooleanLiteral */
  ASTBooleanLiteral jjtn000 = new ASTBooleanLiteral(JJTBOOLEANLITERAL);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case 38:
        jj_consume_token(38);
             jjtree.closeNodeScope(jjtn000, true);
             jjtc000 = false;
             jjtn000.setState(true);
        break;
      case 39:
        jj_consume_token(39);
              jjtree.closeNodeScope(jjtn000, true);
              jjtc000 = false;
              jjtn000.setState(false);
        break;
      default:
        jj_la1[14] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
  }

//125
  final public void String() throws ParseException {
/*@bgen(jjtree) StringLiteral */
  ASTStringLiteral jjtn000 = new ASTStringLiteral(JJTSTRINGLITERAL);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);Token t;
    try {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case STRING_LITERAL1:
        t = jj_consume_token(STRING_LITERAL1);
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
    jjtn000.setStringLiteral(t.image);
        break;
      case STRING_LITERAL2:
        t = jj_consume_token(STRING_LITERAL2);
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
    jjtn000.setStringLiteral(t.image);
        break;
      case STRING_LITERAL_LONG1:
        t = jj_consume_token(STRING_LITERAL_LONG1);
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
    jjtn000.setStringLiteral(t.image);
        break;
      case STRING_LITERAL_LONG2:
        t = jj_consume_token(STRING_LITERAL_LONG2);
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
    jjtn000.setStringLiteral(t.image);
        break;
      default:
        jj_la1[15] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
  }

//126
  final public void IRIref() throws ParseException {
    QuotedIriRef();
  }

  final public void QuotedIriRef() throws ParseException {
/*@bgen(jjtree) QuotedURIRef */
  ASTQuotedURIRef jjtn000 = new ASTQuotedURIRef(JJTQUOTEDURIREF);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);Token qRef;
    try {
      qRef = jj_consume_token(IRI_REF);
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
    jjtn000.setQRef(qRef.image.substring(1, qRef.image.length() - 1));
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
  }

//128
  final public void BlankNode() throws ParseException {
  Token t;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case BLANK_NODE_LABEL:
      t = jj_consume_token(BLANK_NODE_LABEL);
                             ASTBlankNode jjtn001 = new ASTBlankNode(JJTBLANKNODE);
                             boolean jjtc001 = true;
                             jjtree.openNodeScope(jjtn001);
      try {
                             jjtree.closeNodeScope(jjtn001, true);
                             jjtc001 = false;
                             jjtn001.setIdentifier((t.image));
      } finally {
                             if (jjtc001) {
                               jjtree.closeNodeScope(jjtn001, true);
                             }
      }
      break;
    case ANON:
     ASTEmptyNode jjtn002 = new ASTEmptyNode(JJTEMPTYNODE);
     boolean jjtc002 = true;
     jjtree.openNodeScope(jjtn002);
      try {
        jj_consume_token(ANON);
      } finally {
     if (jjtc002) {
       jjtree.closeNodeScope(jjtn002, true);
     }
      }
      break;
    default:
      jj_la1[16] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  private boolean jj_2_1(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_1(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(0, xla); }
  }

  private boolean jj_2_2(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_2(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(1, xla); }
  }

  private boolean jj_3_2() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(17)) {
    jj_scanpos = xsp;
    if (jj_scan_token(18)) {
    jj_scanpos = xsp;
    if (jj_scan_token(19)) {
    jj_scanpos = xsp;
    if (jj_scan_token(20)) return true;
    }
    }
    }
    if (jj_scan_token(LANGTAG)) return true;
    return false;
  }

  private boolean jj_3_1() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(17)) {
    jj_scanpos = xsp;
    if (jj_scan_token(18)) {
    jj_scanpos = xsp;
    if (jj_scan_token(19)) {
    jj_scanpos = xsp;
    if (jj_scan_token(20)) return true;
    }
    }
    }
    if (jj_scan_token(35)) return true;
    return false;
  }

  /** Generated Token Manager. */
  public TSVParserTokenManager token_source;
  JavaCharStream jj_input_stream;
  /** Current token. */
  public Token token;
  /** Next token. */
  public Token jj_nt;
  private int jj_ntk;
  private Token jj_scanpos, jj_lastpos;
  private int jj_la;
  private int jj_gen;
  final private int[] jj_la1 = new int[17];
  static private int[] jj_la1_0;
  static private int[] jj_la1_1;
  static {
      jj_la1_init_0();
      jj_la1_init_1();
   }
   private static void jj_la1_init_0() {
      jj_la1_0 = new int[] {0xbee110,0x0,0x200,0x0,0xbee110,0xbee110,0x1e0000,0xe000,0xe000,0xc000,0xe000,0xc000,0xe000,0xc000,0x0,0x1e0000,0x800100,};
   }
   private static void jj_la1_init_1() {
      jj_la1_1 = new int[] {0xf6,0x4,0x0,0x4,0xf0,0xf0,0x0,0x30,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0x0,0x0,};
   }
  final private JJCalls[] jj_2_rtns = new JJCalls[2];
  private boolean jj_rescan = false;
  private int jj_gc = 0;

  /** Constructor with InputStream. */
  public TSVParser(java.io.InputStream stream) {
     this(stream, null);
  }
  /** Constructor with InputStream and supplied encoding */
  public TSVParser(java.io.InputStream stream, String encoding) {
    try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
    token_source = new TSVParserTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 17; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  /** Reinitialise. */
  public void ReInit(java.io.InputStream stream) {
     ReInit(stream, null);
  }
  /** Reinitialise. */
  public void ReInit(java.io.InputStream stream, String encoding) {
    try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
    token_source.ReInit(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jjtree.reset();
    jj_gen = 0;
    for (int i = 0; i < 17; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  /** Constructor. */
  public TSVParser(java.io.Reader stream) {
    jj_input_stream = new JavaCharStream(stream, 1, 1);
    token_source = new TSVParserTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 17; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  /** Reinitialise. */
  public void ReInit(java.io.Reader stream) {
    jj_input_stream.ReInit(stream, 1, 1);
    token_source.ReInit(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jjtree.reset();
    jj_gen = 0;
    for (int i = 0; i < 17; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  /** Constructor with generated Token Manager. */
  public TSVParser(TSVParserTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 17; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  /** Reinitialise. */
  public void ReInit(TSVParserTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jjtree.reset();
    jj_gen = 0;
    for (int i = 0; i < 17; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  private Token jj_consume_token(int kind) throws ParseException {
    Token oldToken;
    if ((oldToken = token).next != null) token = token.next;
    else token = token.next = token_source.getNextToken();
    jj_ntk = -1;
    if (token.kind == kind) {
      jj_gen++;
      if (++jj_gc > 100) {
        jj_gc = 0;
        for (int i = 0; i < jj_2_rtns.length; i++) {
          JJCalls c = jj_2_rtns[i];
          while (c != null) {
            if (c.gen < jj_gen) c.first = null;
            c = c.next;
          }
        }
      }
      return token;
    }
    token = oldToken;
    jj_kind = kind;
    throw generateParseException();
  }

  static private final class LookaheadSuccess extends java.lang.Error { }
  final private LookaheadSuccess jj_ls = new LookaheadSuccess();
  private boolean jj_scan_token(int kind) {
    if (jj_scanpos == jj_lastpos) {
      jj_la--;
      if (jj_scanpos.next == null) {
        jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
      } else {
        jj_lastpos = jj_scanpos = jj_scanpos.next;
      }
    } else {
      jj_scanpos = jj_scanpos.next;
    }
    if (jj_rescan) {
      int i = 0; Token tok = token;
      while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
      if (tok != null) jj_add_error_token(kind, i);
    }
    if (jj_scanpos.kind != kind) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
    return false;
  }


/** Get the next Token. */
  final public Token getNextToken() {
    if (token.next != null) token = token.next;
    else token = token.next = token_source.getNextToken();
    jj_ntk = -1;
    jj_gen++;
    return token;
  }

/** Get the specific Token. */
  final public Token getToken(int index) {
    Token t = token;
    for (int i = 0; i < index; i++) {
      if (t.next != null) t = t.next;
      else t = t.next = token_source.getNextToken();
    }
    return t;
  }

  private int jj_ntk() {
    if ((jj_nt=token.next) == null)
      return (jj_ntk = (token.next=token_source.getNextToken()).kind);
    else
      return (jj_ntk = jj_nt.kind);
  }

  private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();
  private int[] jj_expentry;
  private int jj_kind = -1;
  private int[] jj_lasttokens = new int[100];
  private int jj_endpos;

  private void jj_add_error_token(int kind, int pos) {
    if (pos >= 100) return;
    if (pos == jj_endpos + 1) {
      jj_lasttokens[jj_endpos++] = kind;
    } else if (jj_endpos != 0) {
      jj_expentry = new int[jj_endpos];
      for (int i = 0; i < jj_endpos; i++) {
        jj_expentry[i] = jj_lasttokens[i];
      }
      jj_entries_loop: for (java.util.Iterator<?> it = jj_expentries.iterator(); it.hasNext();) {
        int[] oldentry = (int[])(it.next());
        if (oldentry.length == jj_expentry.length) {
          for (int i = 0; i < jj_expentry.length; i++) {
            if (oldentry[i] != jj_expentry[i]) {
              continue jj_entries_loop;
            }
          }
          jj_expentries.add(jj_expentry);
          break jj_entries_loop;
        }
      }
      if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
    }
  }

  /** Generate ParseException. */
  public ParseException generateParseException() {
    jj_expentries.clear();
    boolean[] la1tokens = new boolean[40];
    if (jj_kind >= 0) {
      la1tokens[jj_kind] = true;
      jj_kind = -1;
    }
    for (int i = 0; i < 17; i++) {
      if (jj_la1[i] == jj_gen) {
        for (int j = 0; j < 32; j++) {
          if ((jj_la1_0[i] & (1<<j)) != 0) {
            la1tokens[j] = true;
          }
          if ((jj_la1_1[i] & (1<<j)) != 0) {
            la1tokens[32+j] = true;
          }
        }
      }
    }
    for (int i = 0; i < 40; i++) {
      if (la1tokens[i]) {
        jj_expentry = new int[1];
        jj_expentry[0] = i;
        jj_expentries.add(jj_expentry);
      }
    }
    jj_endpos = 0;
    jj_rescan_token();
    jj_add_error_token(0, 0);
    int[][] exptokseq = new int[jj_expentries.size()][];
    for (int i = 0; i < jj_expentries.size(); i++) {
      exptokseq[i] = jj_expentries.get(i);
    }
    return new ParseException(token, exptokseq, tokenImage);
  }

  /** Enable tracing. */
  final public void enable_tracing() {
  }

  /** Disable tracing. */
  final public void disable_tracing() {
  }

  private void jj_rescan_token() {
    jj_rescan = true;
    for (int i = 0; i < 2; i++) {
    try {
      JJCalls p = jj_2_rtns[i];
      do {
        if (p.gen > jj_gen) {
          jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
          switch (i) {
            case 0: jj_3_1(); break;
            case 1: jj_3_2(); break;
          }
        }
        p = p.next;
      } while (p != null);
      } catch(LookaheadSuccess ls) { }
    }
    jj_rescan = false;
  }

  private void jj_save(int index, int xla) {
    JJCalls p = jj_2_rtns[index];
    while (p.gen > jj_gen) {
      if (p.next == null) { p = p.next = new JJCalls(); break; }
      p = p.next;
    }
    p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
  }

  static final class JJCalls {
    int gen;
    Token first;
    int arg;
    JJCalls next;
  }

}
TOP

Related Classes of lupos.endpoint.client.formatreader.tsv.TSVParser$LookaheadSuccess

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.