From 773b16ba3918a998f476f84e9f1071a91ba221e8 Mon Sep 17 00:00:00 2001 From: L0n3Sn1p3r Date: Wed, 2 Aug 2017 13:19:17 +0200 Subject: [PATCH 1/2] fixed a bug in the timestamp function. the ts function would return `false` if applied to any triple that would contain a literal as object which was not a string. this is now fixed. --- .../csparql/sparql/jena/ext/timestamp.java | 87 +++++++++---------- 1 file changed, 43 insertions(+), 44 deletions(-) diff --git a/csparql-sparql-jena/src/main/java/eu/larkc/csparql/sparql/jena/ext/timestamp.java b/csparql-sparql-jena/src/main/java/eu/larkc/csparql/sparql/jena/ext/timestamp.java index 8dd5e75..6515ff9 100644 --- a/csparql-sparql-jena/src/main/java/eu/larkc/csparql/sparql/jena/ext/timestamp.java +++ b/csparql-sparql-jena/src/main/java/eu/larkc/csparql/sparql/jena/ext/timestamp.java @@ -36,9 +36,9 @@ import java.util.Map; + import com.hp.hpl.jena.datatypes.RDFDatatype; import com.hp.hpl.jena.datatypes.TypeMapper; -import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; @@ -49,58 +49,57 @@ import com.hp.hpl.jena.sparql.expr.NodeValue; import com.hp.hpl.jena.sparql.function.FunctionBase3; - public class timestamp extends FunctionBase3 { - static int i = 0; - public static Map timestamps; - - // @Override - // public NodeValue exec(NodeValue v) { - // String key = v.asString(); - // if (timestamps.containsKey(key)) { - // NodeValue ts=NodeValue.makeInteger(timestamps.get(key)); - // - // return ts; - // } else { - // return NodeValue.makeBoolean(false); - // } - // } + static int i = 0; + public static Map timestamps; - @Override - public NodeValue exec(NodeValue arg0, NodeValue arg1, NodeValue arg2) { + // @Override + // public NodeValue exec(NodeValue v) { + // String key = v.asString(); + // if (timestamps.containsKey(key)) { + // NodeValue ts=NodeValue.makeInteger(timestamps.get(key)); + // + // return ts; + // } else { + // return NodeValue.makeBoolean(false); + // } + // } - Statement key; + @Override + public NodeValue exec(NodeValue arg0, NodeValue arg1, NodeValue arg2) { - if(arg2.isLiteral()){ - String[] objectParts = arg2.asString().split("\\^\\^"); - TypeMapper tm = TypeMapper.getInstance(); - // RDFDatatype d = tm.getTypeByName(objectParts[1]); - RDFDatatype d = null; - if (objectParts.length > 1) { - d = tm.getTypeByName(objectParts[1]); - } else { - d = XSDDatatype.XSDstring; - } - Model model = ModelFactory.createDefaultModel(); - Literal lObject = model.createTypedLiteral(objectParts[0].replaceAll("\"", ""),d); - key = new StatementImpl(new ResourceImpl(arg0.asString()), new PropertyImpl(arg1.asString()), lObject); + Statement key; + if (arg2.isLiteral()) { + String[] objectParts = arg2.asString().split("\\^\\^"); + TypeMapper tm = TypeMapper.getInstance(); + // RDFDatatype d = tm.getTypeByName(objectParts[1]); + RDFDatatype d = null; + // if (objectParts.length > 1) { + d = tm.getTypeByName(arg2.getDatatypeURI()); + // } else { + // d = XSDDatatype.XSDstring; + // } + Model model = ModelFactory.createDefaultModel(); + Literal lObject = model.createTypedLiteral(objectParts[0].replaceAll("\"", ""), d); + key = new StatementImpl(new ResourceImpl(arg0.asString()), new PropertyImpl(arg1.asString()), lObject); - lObject = null; - model = null; + lObject = null; + model = null; - } else { - key = new StatementImpl(new ResourceImpl(arg0.asString()), new PropertyImpl(arg1.asString()), new ResourceImpl(arg2.asString())); + } else { + key = new StatementImpl(new ResourceImpl(arg0.asString()), new PropertyImpl(arg1.asString()), + new ResourceImpl(arg2.asString())); - } + } - if (timestamps.containsKey(key)) { - NodeValue ts=NodeValue.makeInteger(timestamps.get(key)); + if (timestamps.containsKey(key)) { + NodeValue ts = NodeValue.makeInteger(timestamps.get(key)); - return ts; - } else { - return NodeValue.makeBoolean(false); - } - } + return ts; + } else { + return NodeValue.makeBoolean(false); + } + } } From 971f1b929e86f9e45cc85e9a844b4f2dbb2bd6ff Mon Sep 17 00:00:00 2001 From: L0n3Sn1p3r Date: Tue, 8 Aug 2017 10:14:38 +0200 Subject: [PATCH 2/2] Changed the grammar to accept multi-character time units (such as ms). change affects the javaCC file as well as the generated files. due to a newer version of javacc (?) the variable curChar has a different type (was char, is now int). accordingly changed the TokenMgrError constructor. --- csparql-core/Grammar/master.jj | 2 +- .../core/new_parser/CsparqlParser.java | 1352 +++++++++-------- .../new_parser/CsparqlParserConstants.java | 34 - .../new_parser/CsparqlParserTokenManager.java | 277 ++-- .../core/new_parser/TokenMgrError.java | 4 +- 5 files changed, 882 insertions(+), 787 deletions(-) diff --git a/csparql-core/Grammar/master.jj b/csparql-core/Grammar/master.jj index fa8993a..000bd6b 100644 --- a/csparql-core/Grammar/master.jj +++ b/csparql-core/Grammar/master.jj @@ -173,7 +173,7 @@ Window Window():{} TimeUnit TimeUnit():{Token t; String timeunit = "";} { (t = < SPACE > { timeunit = timeunit + t.image ; })* - t = + t = ()* {timeunit = timeunit + t.image ; if(!timeunit.equals("ms") && !timeunit.equals("s") && !timeunit.equals("m") && !timeunit.equals("h") && !timeunit.equals("d")) throw new ParseException(); diff --git a/csparql-core/src/main/java/eu/larkc/csparql/core/new_parser/CsparqlParser.java b/csparql-core/src/main/java/eu/larkc/csparql/core/new_parser/CsparqlParser.java index a09fb90..2690b2d 100644 --- a/csparql-core/src/main/java/eu/larkc/csparql/core/new_parser/CsparqlParser.java +++ b/csparql-core/src/main/java/eu/larkc/csparql/core/new_parser/CsparqlParser.java @@ -1,49 +1,15 @@ -/** - * Copyright 2011-2015 DEIB - Politecnico di Milano - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Acknowledgements: - * We would like to thank Davide Barbieri, Emanuele Della Valle, - * Marco Balduini, Soheila Dehghanzadeh, Shen Gao, and - * Daniele Dell'Aglio for the effort in the development of the software. - * - * This work is partially supported by - * - the European LarKC project (FP7-215535) of DEIB, Politecnico di - * Milano - * - the ERC grant “Search Computing” awarded to prof. Stefano Ceri - * - the European ModaClouds project (FP7-ICT-2011-8-318484) of DEIB, - * Politecnico di Milano - * - the IBM Faculty Award 2013 grated to prof. Emanuele Della Valle; - * - the City Data Fusion for Event Management 2013 project funded - * by EIT Digital of DEIB, Politecnico di Milano - * - the Dynamic and Distributed Information Systems Group of the - * University of Zurich; - * - INSIGHT NUIG and Science Foundation Ireland (SFI) under grant - * No. SFI/12/RC/2289 - */ +/* CsparqlParser.java */ /* Generated By:JavaCC: Do not edit this line. CsparqlParser.java */ package eu.larkc.csparql.core.new_parser ; import java.io.StringReader; - import eu.larkc.csparql.core.new_parser.utility_files.*; public class CsparqlParser extends CsparqlParserBase implements CsparqlParserConstants { public static CsparqlParser createAndParse(String queryString) throws ParseException{ CsparqlParser parser = new CsparqlParser(new StringReader(TextUtilities.queryTextEnhancer(queryString))); -// System.out.println(TextUtilities.queryTextEnhancer(queryString)); + System.out.println(TextUtilities.queryTextEnhancer(queryString)); parser.Query(); return parser; } @@ -52,11 +18,12 @@ final public void Query() throws ParseException { RegisterClause(); label_1: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case PREFIX: - case BASE: + case BASE:{ ; break; + } default: jj_la1[0] = jj_gen; break label_1; @@ -66,16 +33,19 @@ final public void Query() throws ParseException { if (jj_2_1(5)) { SelectClause(); } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CONSTRUCT: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CONSTRUCT:{ ConstructClause(); break; - case DESCRIBE: + } + case DESCRIBE:{ DescribeClause(); break; - case ASK: + } + case ASK:{ AskClause(); break; + } default: jj_la1[1] = jj_gen; jj_consume_token(-1); @@ -84,10 +54,11 @@ final public void Query() throws ParseException { } label_2: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case FROM: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case FROM:{ ; break; + } default: jj_la1[2] = jj_gen; break label_2; @@ -95,10 +66,11 @@ final public void Query() throws ParseException { if (jj_2_2(5)) { FromClause(); } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case FROM: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case FROM:{ FromStreamClause(); break; + } default: jj_la1[3] = jj_gen; jj_consume_token(-1); @@ -106,50 +78,53 @@ final public void Query() throws ParseException { } } } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case WHERE: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case WHERE:{ WhereClause(); break; + } default: jj_la1[4] = jj_gen; ; } - setSparqlQuery(sparqlQuery) ; +setSparqlQuery(sparqlQuery) ; jj_consume_token(0); - } +} - final public void Prologue() throws ParseException { - Token t; + final public void Prologue() throws ParseException {Token t; if (jj_2_4(2)) { t = jj_consume_token(PREFIX); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; label_3: while (true) { if (jj_2_3(2)) { t = jj_consume_token(SINGLELETTERTEXT); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case NUMBERS: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case NUMBERS:{ t = jj_consume_token(NUMBERS); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case SYMBOL: + } + case SYMBOL:{ t = jj_consume_token(SYMBOL); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; + } default: jj_la1[5] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case SINGLELETTERTEXT: case NUMBERS: - case SYMBOL: + case SYMBOL:{ ; break; + } default: jj_la1[6] = jj_gen; break label_3; @@ -157,27 +132,29 @@ final public void Prologue() throws ParseException { } label_4: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SPACE: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SPACE:{ ; break; + } default: jj_la1[7] = jj_gen; break label_4; } t = jj_consume_token(SPACE); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; } t = jj_consume_token(IRIref); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case BASE: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case BASE:{ t = jj_consume_token(BASE); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; t = jj_consume_token(IRIref); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; + } default: jj_la1[8] = jj_gen; jj_consume_token(-1); @@ -186,31 +163,32 @@ final public void Prologue() throws ParseException { } label_5: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SPACE: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SPACE:{ ; break; + } default: jj_la1[9] = jj_gen; break label_5; } t = jj_consume_token(SPACE); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; } - sparqlQuery = sparqlQuery + "\u005cn"; - } +sparqlQuery = sparqlQuery + "\n"; +} - final public void RegisterClause() throws ParseException { - Token t ; String queryName =""; + final public void RegisterClause() throws ParseException {Token t ; String queryName =""; if (jj_2_5(3)) { jj_consume_token(REGISTERSTREAM); - setOutputIsStream(true); +setOutputIsStream(true); } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case REGISTERQUERY: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case REGISTERQUERY:{ jj_consume_token(REGISTERQUERY); - setOutputIsStream(false); +setOutputIsStream(false); break; + } default: jj_la1[10] = jj_gen; jj_consume_token(-1); @@ -219,25 +197,28 @@ final public void RegisterClause() throws ParseException { } label_6: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SINGLELETTERTEXT: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SINGLELETTERTEXT:{ t = jj_consume_token(SINGLELETTERTEXT); - queryName = queryName + t.image ; +queryName = queryName + t.image ; break; - case NUMBERS: + } + case NUMBERS:{ t = jj_consume_token(NUMBERS); - queryName = queryName + t.image ; +queryName = queryName + t.image ; break; + } default: jj_la1[11] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case SINGLELETTERTEXT: - case NUMBERS: + case NUMBERS:{ ; break; + } default: jj_la1[12] = jj_gen; break label_6; @@ -245,150 +226,163 @@ final public void RegisterClause() throws ParseException { } jj_consume_token(SPACE); jj_consume_token(AS); - setCsparqlQueryName(queryName.trim()); +setCsparqlQueryName(queryName.trim()); label_7: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SPACE: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SPACE:{ ; break; + } default: jj_la1[13] = jj_gen; break label_7; } jj_consume_token(SPACE); } - } +} - final public void AddClause() throws ParseException { - Token t; + final public void AddClause() throws ParseException {Token t; t = jj_consume_token(ADD); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; label_8: while (true) { label_9: while (true) { if (jj_2_6(2)) { t = jj_consume_token(AS); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SINGLELETTERTEXT: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SINGLELETTERTEXT:{ t = jj_consume_token(SINGLELETTERTEXT); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case SYMBOL: + } + case SYMBOL:{ t = jj_consume_token(SYMBOL); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case NUMBERS: + } + case NUMBERS:{ t = jj_consume_token(NUMBERS); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; + } default: jj_la1[14] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case SINGLELETTERTEXT: case NUMBERS: case SYMBOL: - case AS: + case AS:{ ; break; + } default: jj_la1[15] = jj_gen; break label_9; } } t = jj_consume_token(SPACE); - sparqlQuery = sparqlQuery + t.image ; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { +sparqlQuery = sparqlQuery + t.image ; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case SINGLELETTERTEXT: case NUMBERS: case SYMBOL: - case AS: + case AS:{ ; break; + } default: jj_la1[16] = jj_gen; break label_8; } } - sparqlQuery = sparqlQuery + "\u005cn"; - } +sparqlQuery = sparqlQuery + "\n"; +} - final public void DescribeClause() throws ParseException { - Token t; + final public void DescribeClause() throws ParseException {Token t; t = jj_consume_token(DESCRIBE); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; label_10: while (true) { label_11: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ADD: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case ADD:{ t = jj_consume_token(ADD); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case CONSTRUCT: + } + case CONSTRUCT:{ t = jj_consume_token(CONSTRUCT); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case SELECT: + } + case SELECT:{ t = jj_consume_token(SELECT); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case AS: + } + case AS:{ t = jj_consume_token(AS); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case SINGLELETTERTEXT: + } + case SINGLELETTERTEXT:{ t = jj_consume_token(SINGLELETTERTEXT); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case SYMBOL: + } + case SYMBOL:{ t = jj_consume_token(SYMBOL); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case NUMBERS: + } + case NUMBERS:{ t = jj_consume_token(NUMBERS); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; + } default: jj_la1[17] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case SELECT: case ADD: case CONSTRUCT: case SINGLELETTERTEXT: case NUMBERS: case SYMBOL: - case AS: + case AS:{ ; break; + } default: jj_la1[18] = jj_gen; break label_11; } } t = jj_consume_token(SPACE); - sparqlQuery = sparqlQuery + t.image ; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { +sparqlQuery = sparqlQuery + t.image ; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case SELECT: case ADD: case CONSTRUCT: case SINGLELETTERTEXT: case NUMBERS: case SYMBOL: - case AS: + case AS:{ ; break; + } default: jj_la1[19] = jj_gen; break label_10; @@ -396,71 +390,76 @@ final public void DescribeClause() throws ParseException { } label_12: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SPACE: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SPACE:{ ; break; + } default: jj_la1[20] = jj_gen; break label_12; } t = jj_consume_token(SPACE); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; } - sparqlQuery = sparqlQuery + "\u005cn"; - } +sparqlQuery = sparqlQuery + "\n"; +} - final public void AskClause() throws ParseException { - Token t; + final public void AskClause() throws ParseException {Token t; t = jj_consume_token(ASK); - sparqlQuery = sparqlQuery + t.image ; - sparqlQuery = sparqlQuery + "\u005cn"; - } +sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + "\n"; +} - final public void SelectClause() throws ParseException { - Token t; + final public void SelectClause() throws ParseException {Token t; t = jj_consume_token(SELECT); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; label_13: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case SINGLELETTERTEXT: case NUMBERS: case SYMBOL: case IRIref: case SPACE: - case AS: + case AS:{ ; break; + } default: jj_la1[21] = jj_gen; break label_13; } if (jj_2_7(3)) { t = jj_consume_token(SINGLELETTERTEXT); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SYMBOL: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SYMBOL:{ t = jj_consume_token(SYMBOL); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case NUMBERS: + } + case NUMBERS:{ t = jj_consume_token(NUMBERS); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case IRIref: + } + case IRIref:{ t = jj_consume_token(IRIref); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case SPACE: + } + case SPACE:{ t = jj_consume_token(SPACE); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case AS: + } + case AS:{ t = jj_consume_token(AS); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; + } default: jj_la1[22] = jj_gen; jj_consume_token(-1); @@ -468,48 +467,52 @@ final public void SelectClause() throws ParseException { } } } - sparqlQuery = sparqlQuery + "\u005cn"; - } +sparqlQuery = sparqlQuery + "\n"; +} - final public void ConstructClause() throws ParseException { - Token t; + final public void ConstructClause() throws ParseException {Token t; t = jj_consume_token(CONSTRUCT); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; label_14: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case SINGLELETTERTEXT: case NUMBERS: case SYMBOL: case IRIref: - case SPACE: + case SPACE:{ ; break; + } default: jj_la1[23] = jj_gen; break label_14; } if (jj_2_8(3)) { t = jj_consume_token(SINGLELETTERTEXT); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SYMBOL: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SYMBOL:{ t = jj_consume_token(SYMBOL); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case NUMBERS: + } + case NUMBERS:{ t = jj_consume_token(NUMBERS); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case IRIref: + } + case IRIref:{ t = jj_consume_token(IRIref); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case SPACE: + } + case SPACE:{ t = jj_consume_token(SPACE); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; + } default: jj_la1[24] = jj_gen; jj_consume_token(-1); @@ -517,43 +520,43 @@ final public void ConstructClause() throws ParseException { } } } - sparqlQuery = sparqlQuery + "\u005cn"; - } +sparqlQuery = sparqlQuery + "\n"; +} - final public void FromClause() throws ParseException { - Token t; + final public void FromClause() throws ParseException {Token t; t = jj_consume_token(FROM); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; //t = " " { s = s + t.image ; } //((t = { s = s + t.image ; } | t = { s = s + t.image ; })+ t = " " { s = s + t.image ; })+ t = jj_consume_token(IRIref); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; label_15: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SPACE: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SPACE:{ ; break; + } default: jj_la1[25] = jj_gen; break label_15; } t = jj_consume_token(SPACE); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; } - sparqlQuery = sparqlQuery + "\u005cn"; - } +sparqlQuery = sparqlQuery + "\n"; +} - final public void FromStreamClause() throws ParseException { - Token t ; String streamName =""; String s1 =""; - Window window; + final public void FromStreamClause() throws ParseException {Token t ; String streamName =""; String s1 =""; +Window window; jj_consume_token(FROM); label_16: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case NAMED: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case NAMED:{ ; break; + } default: jj_la1[26] = jj_gen; break label_16; @@ -562,14 +565,15 @@ final public void FromStreamClause() throws ParseException { } jj_consume_token(STREAM); t = jj_consume_token(IRIref); - streamName = t.image ; +streamName = t.image ; jj_consume_token(SPACE); label_17: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SPACE: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SPACE:{ ; break; + } default: jj_la1[27] = jj_gen; break label_17; @@ -581,32 +585,34 @@ final public void FromStreamClause() throws ParseException { jj_consume_token(SYMBOL); label_18: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SPACE: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SPACE:{ ; break; + } default: jj_la1[28] = jj_gen; break label_18; } jj_consume_token(SPACE); } - StreamInfo si = new StreamInfo(streamName,window) ; +StreamInfo si = new StreamInfo(streamName,window) ; addStreams(si); - } +} final public Window Window() throws ParseException { - Window window; +Window window; if (jj_2_9(2)) { window = LogicalWindow(); - {if (true) return window;} +{if ("" != null) return window;} } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case SPACE: - case TRIPLES: + case TRIPLES:{ window = PhysicalWindow(); - {if (true) return window;} +{if ("" != null) return window;} break; + } default: jj_la1[29] = jj_gen; jj_consume_token(-1); @@ -614,245 +620,271 @@ final public Window Window() throws ParseException { } } throw new Error("Missing return statement in function"); - } +} - final public TimeUnit TimeUnit() throws ParseException { - Token t; String timeunit = ""; + final public TimeUnit TimeUnit() throws ParseException {Token t; String timeunit = ""; label_19: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SPACE: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SPACE:{ ; break; + } default: jj_la1[30] = jj_gen; break label_19; } t = jj_consume_token(SPACE); - timeunit = timeunit + t.image ; +timeunit = timeunit + t.image ; } t = jj_consume_token(SINGLELETTERTEXT); - timeunit = timeunit + t.image ; + label_20: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SINGLELETTERTEXT:{ + ; + break; + } + default: + jj_la1[31] = jj_gen; + break label_20; + } + jj_consume_token(SINGLELETTERTEXT); + } +timeunit = timeunit + t.image ; if(!timeunit.equals("ms") && !timeunit.equals("s") && !timeunit.equals("m") && !timeunit.equals("h") && !timeunit.equals("d")) {if (true) throw new ParseException();} - {if (true) return TimeUnit.getUnitOfMeasure(timeunit);} +{if ("" != null) return TimeUnit.getUnitOfMeasure(timeunit);} throw new Error("Missing return statement in function"); - } +} - final public TimeIntervalDescription WindowOverlap() throws ParseException { - Token t; String tempStepValue = ""; - TimeIntervalDescription stepDescription = new TimeIntervalDescription(); + final public TimeIntervalDescription WindowOverlap() throws ParseException {Token t; String tempStepValue = ""; +TimeIntervalDescription stepDescription = new TimeIntervalDescription(); TimeUnit tm; - label_20: + label_21: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SPACE: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SPACE:{ ; break; + } default: - jj_la1[31] = jj_gen; - break label_20; + jj_la1[32] = jj_gen; + break label_21; } t = jj_consume_token(SPACE); } if (jj_2_10(2)) { t = jj_consume_token(STEP); - label_21: + label_22: while (true) { t = jj_consume_token(NUMBERS); - tempStepValue = tempStepValue + t.image ; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case NUMBERS: +tempStepValue = tempStepValue + t.image ; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case NUMBERS:{ ; break; + } default: - jj_la1[32] = jj_gen; - break label_21; + jj_la1[33] = jj_gen; + break label_22; } } tm = TimeUnit(); - stepDescription.setTimeUnit(tm) ; stepDescription.setValue(Integer.parseInt(tempStepValue)); {if (true) return stepDescription;} +stepDescription.setTimeUnit(tm) ; stepDescription.setValue(Integer.parseInt(tempStepValue)); {if ("" != null) return stepDescription;} } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case TUMBLING: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case TUMBLING:{ t = jj_consume_token(TUMBLING); - {if (true) return null;} +{if ("" != null) return null;} break; + } default: - jj_la1[33] = jj_gen; + jj_la1[34] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } throw new Error("Missing return statement in function"); - } +} - final public LogicalWindow LogicalWindow() throws ParseException { - Token t; String tempRangeValue = ""; - label_22: + final public LogicalWindow LogicalWindow() throws ParseException {Token t; String tempRangeValue = ""; + label_23: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SPACE: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SPACE:{ ; break; + } default: - jj_la1[34] = jj_gen; - break label_22; + jj_la1[35] = jj_gen; + break label_23; } jj_consume_token(SPACE); } - TimeIntervalDescription rangeDescription = new TimeIntervalDescription(); +TimeIntervalDescription rangeDescription = new TimeIntervalDescription(); TimeIntervalDescription stepDescription = new TimeIntervalDescription(); TimeUnit tm; boolean isTumbling; - label_23: + label_24: while (true) { t = jj_consume_token(NUMBERS); - tempRangeValue = tempRangeValue + t.image ; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case NUMBERS: +tempRangeValue = tempRangeValue + t.image ; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case NUMBERS:{ ; break; + } default: - jj_la1[35] = jj_gen; - break label_23; + jj_la1[36] = jj_gen; + break label_24; } } tm = TimeUnit(); stepDescription = WindowOverlap(); - rangeDescription.setTimeUnit(tm) ; +rangeDescription.setTimeUnit(tm) ; rangeDescription.setValue(Integer.parseInt(tempRangeValue)); if(stepDescription == null) isTumbling = true; else isTumbling = false; - {if (true) return new LogicalWindow(rangeDescription,stepDescription,isTumbling) ;} + {if ("" != null) return new LogicalWindow(rangeDescription,stepDescription,isTumbling) ;} throw new Error("Missing return statement in function"); - } +} - final public PhysicalWindow PhysicalWindow() throws ParseException { - Token t; String windowRange = ""; - label_24: + final public PhysicalWindow PhysicalWindow() throws ParseException {Token t; String windowRange = ""; + label_25: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SPACE: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SPACE:{ ; break; + } default: - jj_la1[36] = jj_gen; - break label_24; + jj_la1[37] = jj_gen; + break label_25; } t = jj_consume_token(SPACE); } t = jj_consume_token(TRIPLES); - label_25: + label_26: while (true) { t = jj_consume_token(NUMBERS); - windowRange = windowRange + t.image ; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case NUMBERS: +windowRange = windowRange + t.image ; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case NUMBERS:{ ; break; + } default: - jj_la1[37] = jj_gen; - break label_25; + jj_la1[38] = jj_gen; + break label_26; } } - {if (true) return new PhysicalWindow(Integer.parseInt(windowRange)) ;} +{if ("" != null) return new PhysicalWindow(Integer.parseInt(windowRange)) ;} throw new Error("Missing return statement in function"); - } +} - final public void WhereClause() throws ParseException { - Token t; + final public void WhereClause() throws ParseException {Token t; t = jj_consume_token(WHERE); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; if (jj_2_12(5)) { - label_26: + label_27: while (true) { if (jj_2_11(5)) { t = jj_consume_token(SPACE); - sparqlQuery = sparqlQuery + t.image ; - label_27: +sparqlQuery = sparqlQuery + t.image ; + label_28: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SINGLELETTERTEXT: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SINGLELETTERTEXT:{ t = jj_consume_token(SINGLELETTERTEXT); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case SYMBOL: + } + case SYMBOL:{ t = jj_consume_token(SYMBOL); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case NUMBERS: + } + case NUMBERS:{ t = jj_consume_token(NUMBERS); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case IRIref: + } + case IRIref:{ t = jj_consume_token(IRIref); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case SELECT: + } + case SELECT:{ t = jj_consume_token(SELECT); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case AS: + } + case AS:{ t = jj_consume_token(AS); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case WHERE: + } + case WHERE:{ t = jj_consume_token(WHERE); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; + } default: - jj_la1[38] = jj_gen; + jj_la1[39] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case SELECT: case WHERE: case SINGLELETTERTEXT: case NUMBERS: case SYMBOL: case IRIref: - case AS: + case AS:{ ; break; + } default: - jj_la1[39] = jj_gen; - break label_27; + jj_la1[40] = jj_gen; + break label_28; } } } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SPACE: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SPACE:{ t = jj_consume_token(SPACE); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; + } default: - jj_la1[40] = jj_gen; + jj_la1[41] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SPACE: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SPACE:{ ; break; + } default: - jj_la1[41] = jj_gen; - break label_26; + jj_la1[42] = jj_gen; + break label_27; } } } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SYMBOL: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SYMBOL:{ t = jj_consume_token(SYMBOL); - sparqlQuery = sparqlQuery + t.image ; - label_28: +sparqlQuery = sparqlQuery + t.image ; + label_29: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case SELECT: case WHERE: case SINGLELETTERTEXT: @@ -860,260 +892,299 @@ final public void WhereClause() throws ParseException { case SYMBOL: case IRIref: case SPACE: - case AS: + case AS:{ ; break; + } default: - jj_la1[42] = jj_gen; - break label_28; + jj_la1[43] = jj_gen; + break label_29; } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SINGLELETTERTEXT: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SINGLELETTERTEXT:{ t = jj_consume_token(SINGLELETTERTEXT); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case SYMBOL: + } + case SYMBOL:{ t = jj_consume_token(SYMBOL); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case NUMBERS: + } + case NUMBERS:{ t = jj_consume_token(NUMBERS); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case IRIref: + } + case IRIref:{ t = jj_consume_token(IRIref); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case SELECT: + } + case SELECT:{ t = jj_consume_token(SELECT); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case AS: + } + case AS:{ t = jj_consume_token(AS); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case WHERE: + } + case WHERE:{ t = jj_consume_token(WHERE); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; - case SPACE: + } + case SPACE:{ t = jj_consume_token(SPACE); - sparqlQuery = sparqlQuery + t.image ; +sparqlQuery = sparqlQuery + t.image ; break; + } default: - jj_la1[43] = jj_gen; + jj_la1[44] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } break; + } default: - jj_la1[44] = jj_gen; + jj_la1[45] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } - sparqlQuery = sparqlQuery + "\u005cn"; - } +sparqlQuery = sparqlQuery + "\n"; +} - private boolean jj_2_1(int xla) { + private boolean jj_2_1(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_1(); } + try { return (!jj_3_1()); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(0, xla); } } - private boolean jj_2_2(int xla) { + private boolean jj_2_2(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_2(); } + try { return (!jj_3_2()); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(1, xla); } } - private boolean jj_2_3(int xla) { + private boolean jj_2_3(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_3(); } + try { return (!jj_3_3()); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(2, xla); } } - private boolean jj_2_4(int xla) { + private boolean jj_2_4(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_4(); } + try { return (!jj_3_4()); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(3, xla); } } - private boolean jj_2_5(int xla) { + private boolean jj_2_5(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_5(); } + try { return (!jj_3_5()); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(4, xla); } } - private boolean jj_2_6(int xla) { + private boolean jj_2_6(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_6(); } + try { return (!jj_3_6()); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(5, xla); } } - private boolean jj_2_7(int xla) { + private boolean jj_2_7(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_7(); } + try { return (!jj_3_7()); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(6, xla); } } - private boolean jj_2_8(int xla) { + private boolean jj_2_8(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_8(); } + try { return (!jj_3_8()); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(7, xla); } } - private boolean jj_2_9(int xla) { + private boolean jj_2_9(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_9(); } + try { return (!jj_3_9()); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(8, xla); } } - private boolean jj_2_10(int xla) { + private boolean jj_2_10(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_10(); } + try { return (!jj_3_10()); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(9, xla); } } - private boolean jj_2_11(int xla) { + private boolean jj_2_11(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_11(); } + try { return (!jj_3_11()); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(10, xla); } } - private boolean jj_2_12(int xla) { + private boolean jj_2_12(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_12(); } + try { return (!jj_3_12()); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(11, xla); } } - private boolean jj_3R_55() { + private boolean jj_3R_56() + { if (jj_scan_token(SPACE)) return true; return false; } - private boolean jj_3R_41() { + private boolean jj_3R_42() + { Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_55()) { jj_scanpos = xsp; break; } + if (jj_3R_56()) { jj_scanpos = xsp; break; } } if (jj_scan_token(SINGLELETTERTEXT)) return true; return false; } - private boolean jj_3_6() { + private boolean jj_3_6() + { if (jj_scan_token(AS)) return true; return false; } - private boolean jj_3R_38() { + private boolean jj_3R_39() + { if (jj_scan_token(NUMBERS)) return true; return false; } - private boolean jj_3_9() { - if (jj_3R_32()) return true; + private boolean jj_3_9() + { + if (jj_3R_33()) return true; return false; } - private boolean jj_3_5() { + private boolean jj_3_5() + { if (jj_scan_token(REGISTERSTREAM)) return true; return false; } - private boolean jj_3R_31() { + private boolean jj_3R_32() + { Token xsp; xsp = jj_scanpos; if (jj_3_3()) { jj_scanpos = xsp; - if (jj_3R_38()) { + if (jj_3R_39()) { jj_scanpos = xsp; - if (jj_3R_39()) return true; + if (jj_3R_40()) return true; } } return false; } - private boolean jj_3_3() { + private boolean jj_3_3() + { if (jj_scan_token(SINGLELETTERTEXT)) return true; return false; } - private boolean jj_3R_49() { + private boolean jj_3R_50() + { if (jj_scan_token(SPACE)) return true; return false; } - private boolean jj_3R_39() { + private boolean jj_3R_40() + { if (jj_scan_token(SYMBOL)) return true; return false; } - private boolean jj_3R_48() { + private boolean jj_3R_49() + { if (jj_scan_token(WHERE)) return true; return false; } - private boolean jj_3R_47() { + private boolean jj_3R_48() + { if (jj_scan_token(AS)) return true; return false; } - private boolean jj_3R_46() { + private boolean jj_3R_47() + { if (jj_scan_token(SELECT)) return true; return false; } - private boolean jj_3R_45() { + private boolean jj_3R_46() + { if (jj_scan_token(IRIref)) return true; return false; } - private boolean jj_3R_37() { + private boolean jj_3R_38() + { if (jj_scan_token(SPACE)) return true; return false; } - private boolean jj_3R_44() { + private boolean jj_3R_45() + { if (jj_scan_token(NUMBERS)) return true; return false; } - private boolean jj_3R_43() { + private boolean jj_3R_44() + { if (jj_scan_token(SYMBOL)) return true; return false; } - private boolean jj_3_4() { + private boolean jj_3_4() + { if (jj_scan_token(PREFIX)) return true; Token xsp; - if (jj_3R_31()) return true; + if (jj_3R_32()) return true; while (true) { xsp = jj_scanpos; - if (jj_3R_31()) { jj_scanpos = xsp; break; } + if (jj_3R_32()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_34() { + private boolean jj_3R_35() + { Token xsp; xsp = jj_scanpos; - if (jj_3R_42()) { - jj_scanpos = xsp; if (jj_3R_43()) { jj_scanpos = xsp; if (jj_3R_44()) { @@ -1124,7 +1195,9 @@ private boolean jj_3R_34() { jj_scanpos = xsp; if (jj_3R_47()) { jj_scanpos = xsp; - if (jj_3R_48()) return true; + if (jj_3R_48()) { + jj_scanpos = xsp; + if (jj_3R_49()) return true; } } } @@ -1134,112 +1207,127 @@ private boolean jj_3R_34() { return false; } - private boolean jj_3R_42() { + private boolean jj_3R_43() + { if (jj_scan_token(SINGLELETTERTEXT)) return true; return false; } - private boolean jj_3R_30() { + private boolean jj_3R_31() + { if (jj_scan_token(FROM)) return true; if (jj_scan_token(IRIref)) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_37()) { jj_scanpos = xsp; break; } + if (jj_3R_38()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3_8() { + private boolean jj_3_8() + { if (jj_scan_token(SINGLELETTERTEXT)) return true; return false; } - private boolean jj_3_11() { + private boolean jj_3_11() + { if (jj_scan_token(SPACE)) return true; Token xsp; - if (jj_3R_34()) return true; + if (jj_3R_35()) return true; while (true) { xsp = jj_scanpos; - if (jj_3R_34()) { jj_scanpos = xsp; break; } + if (jj_3R_35()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_35() { + private boolean jj_3R_36() + { Token xsp; xsp = jj_scanpos; if (jj_3_11()) { jj_scanpos = xsp; - if (jj_3R_49()) return true; + if (jj_3R_50()) return true; } return false; } - private boolean jj_3R_54() { + private boolean jj_3R_55() + { if (jj_scan_token(AS)) return true; return false; } - private boolean jj_3R_53() { + private boolean jj_3R_54() + { if (jj_scan_token(SPACE)) return true; return false; } - private boolean jj_3_12() { + private boolean jj_3_12() + { Token xsp; - if (jj_3R_35()) return true; + if (jj_3R_36()) return true; while (true) { xsp = jj_scanpos; - if (jj_3R_35()) { jj_scanpos = xsp; break; } + if (jj_3R_36()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_52() { + private boolean jj_3R_53() + { if (jj_scan_token(IRIref)) return true; return false; } - private boolean jj_3_2() { - if (jj_3R_30()) return true; + private boolean jj_3_2() + { + if (jj_3R_31()) return true; return false; } - private boolean jj_3R_51() { + private boolean jj_3R_52() + { if (jj_scan_token(NUMBERS)) return true; return false; } - private boolean jj_3R_50() { + private boolean jj_3R_51() + { if (jj_scan_token(SYMBOL)) return true; return false; } - private boolean jj_3_1() { - if (jj_3R_29()) return true; + private boolean jj_3_1() + { + if (jj_3R_30()) return true; return false; } - private boolean jj_3_7() { + private boolean jj_3_7() + { if (jj_scan_token(SINGLELETTERTEXT)) return true; return false; } - private boolean jj_3R_36() { + private boolean jj_3R_37() + { Token xsp; xsp = jj_scanpos; if (jj_3_7()) { jj_scanpos = xsp; - if (jj_3R_50()) { - jj_scanpos = xsp; if (jj_3R_51()) { jj_scanpos = xsp; if (jj_3R_52()) { jj_scanpos = xsp; if (jj_3R_53()) { jj_scanpos = xsp; - if (jj_3R_54()) return true; + if (jj_3R_54()) { + jj_scanpos = xsp; + if (jj_3R_55()) return true; } } } @@ -1248,48 +1336,53 @@ private boolean jj_3R_36() { return false; } - private boolean jj_3R_29() { + private boolean jj_3R_30() + { if (jj_scan_token(SELECT)) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_36()) { jj_scanpos = xsp; break; } + if (jj_3R_37()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_40() { + private boolean jj_3R_41() + { if (jj_scan_token(NUMBERS)) return true; return false; } - private boolean jj_3R_32() { + private boolean jj_3R_33() + { Token xsp; while (true) { xsp = jj_scanpos; if (jj_scan_token(18)) { jj_scanpos = xsp; break; } } - if (jj_3R_40()) return true; + if (jj_3R_41()) return true; while (true) { xsp = jj_scanpos; - if (jj_3R_40()) { jj_scanpos = xsp; break; } + if (jj_3R_41()) { jj_scanpos = xsp; break; } } - if (jj_3R_41()) return true; + if (jj_3R_42()) return true; return false; } - private boolean jj_3R_33() { + private boolean jj_3R_34() + { if (jj_scan_token(NUMBERS)) return true; return false; } - private boolean jj_3_10() { + private boolean jj_3_10() + { if (jj_scan_token(STEP)) return true; Token xsp; - if (jj_3R_33()) return true; + if (jj_3R_34()) return true; while (true) { xsp = jj_scanpos; - if (jj_3R_33()) { jj_scanpos = xsp; break; } + if (jj_3R_34()) { jj_scanpos = xsp; break; } } return false; } @@ -1305,162 +1398,171 @@ private boolean jj_3_10() { private Token jj_scanpos, jj_lastpos; private int jj_la; private int jj_gen; - final private int[] jj_la1 = new int[45]; + final private int[] jj_la1 = new int[46]; static private int[] jj_la1_0; static { - jj_la1_init_0(); - } - private static void jj_la1_init_0() { - jj_la1_0 = new int[] {0x60,0xd00,0x1000,0x1000,0x2000,0x18000,0x1c000,0x40000,0x40,0x40000,0x100000,0xc000,0xc000,0x40000,0x1c000,0x41c000,0x41c000,0x41ca80,0x41ca80,0x41ca80,0x40000,0x47c000,0x478000,0x7c000,0x78000,0x40000,0x800000,0x40000,0x40000,0x8040000,0x40000,0x40000,0x8000,0x4000000,0x40000,0x8000,0x40000,0x8000,0x43e080,0x43e080,0x40000,0x40000,0x47e080,0x47e080,0x10000,}; - } + jj_la1_init_0(); + } + private static void jj_la1_init_0() { + jj_la1_0 = new int[] {0x60,0xd00,0x1000,0x1000,0x2000,0x18000,0x1c000,0x40000,0x40,0x40000,0x100000,0xc000,0xc000,0x40000,0x1c000,0x41c000,0x41c000,0x41ca80,0x41ca80,0x41ca80,0x40000,0x47c000,0x478000,0x7c000,0x78000,0x40000,0x800000,0x40000,0x40000,0x8040000,0x40000,0x4000,0x40000,0x8000,0x4000000,0x40000,0x8000,0x40000,0x8000,0x43e080,0x43e080,0x40000,0x40000,0x47e080,0x47e080,0x10000,}; + } final private JJCalls[] jj_2_rtns = new JJCalls[12]; private boolean jj_rescan = false; private int jj_gc = 0; /** Constructor with InputStream. */ public CsparqlParser(java.io.InputStream stream) { - this(stream, null); + this(stream, null); } /** Constructor with InputStream and supplied encoding */ public CsparqlParser(java.io.InputStream stream, String encoding) { - try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } - token_source = new CsparqlParserTokenManager(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 45; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } + token_source = new CsparqlParserTokenManager(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 46; 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); + 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; - jj_gen = 0; - for (int i = 0; i < 45; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + 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; + jj_gen = 0; + for (int i = 0; i < 46; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Constructor. */ public CsparqlParser(java.io.Reader stream) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new CsparqlParserTokenManager(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 45; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + jj_input_stream = new SimpleCharStream(stream, 1, 1); + token_source = new CsparqlParserTokenManager(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 46; 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; - jj_gen = 0; - for (int i = 0; i < 45; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + if (jj_input_stream == null) { + jj_input_stream = new SimpleCharStream(stream, 1, 1); + } else { + jj_input_stream.ReInit(stream, 1, 1); + } + if (token_source == null) { + token_source = new CsparqlParserTokenManager(jj_input_stream); + } + + token_source.ReInit(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 46; 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 CsparqlParser(CsparqlParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 45; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 46; 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(CsparqlParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 45; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 46; 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 { } + 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(); + } + + @SuppressWarnings("serial") + 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; + 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; + 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; + 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 int jj_ntk_f() { + 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 jj_expentries = new java.util.ArrayList(); @@ -1470,62 +1572,83 @@ private int jj_ntk() { 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; - } + 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]; + } + + for (int[] oldentry : jj_expentries) { + if (oldentry.length == jj_expentry.length) { + boolean isMatched = true; + + for (int i = 0; i < jj_expentry.length; i++) { + if (oldentry[i] != jj_expentry[i]) { + isMatched = false; + break; + } + + } + if (isMatched) { + jj_expentries.add(jj_expentry); + break; + } + } + } + + if (pos != 0) { + jj_lasttokens[(jj_endpos = pos) - 1] = kind; + } + } } /** Generate ParseException. */ public ParseException generateParseException() { - jj_expentries.clear(); - boolean[] la1tokens = new boolean[28]; - if (jj_kind >= 0) { - la1tokens[jj_kind] = true; - jj_kind = -1; - } - for (int i = 0; i < 45; i++) { - if (jj_la1[i] == jj_gen) { - for (int j = 0; j < 32; j++) { - if ((jj_la1_0[i] & (1<= 0) { + la1tokens[jj_kind] = true; + jj_kind = -1; + } + for (int i = 0; i < 46; i++) { + if (jj_la1[i] == jj_gen) { + for (int j = 0; j < 32; j++) { + if ((jj_la1_0[i] & (1< 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; - case 2: jj_3_3(); break; - case 3: jj_3_4(); break; - case 4: jj_3_5(); break; - case 5: jj_3_6(); break; - case 6: jj_3_7(); break; - case 7: jj_3_8(); break; - case 8: jj_3_9(); break; - case 9: jj_3_10(); break; - case 10: jj_3_11(); break; - case 11: jj_3_12(); break; - } - } - p = p.next; - } while (p != null); - } catch(LookaheadSuccess ls) { } - } - jj_rescan = false; + jj_rescan = true; + for (int i = 0; i < 12; 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; + case 2: jj_3_3(); break; + case 3: jj_3_4(); break; + case 4: jj_3_5(); break; + case 5: jj_3_6(); break; + case 6: jj_3_7(); break; + case 7: jj_3_8(); break; + case 8: jj_3_9(); break; + case 9: jj_3_10(); break; + case 10: jj_3_11(); break; + case 11: jj_3_12(); 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; + 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; + int gen; + Token first; + int arg; + JJCalls next; } } diff --git a/csparql-core/src/main/java/eu/larkc/csparql/core/new_parser/CsparqlParserConstants.java b/csparql-core/src/main/java/eu/larkc/csparql/core/new_parser/CsparqlParserConstants.java index e90b844..c8c84df 100644 --- a/csparql-core/src/main/java/eu/larkc/csparql/core/new_parser/CsparqlParserConstants.java +++ b/csparql-core/src/main/java/eu/larkc/csparql/core/new_parser/CsparqlParserConstants.java @@ -1,37 +1,3 @@ -/** - * Copyright 2011-2015 DEIB - Politecnico di Milano - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Acknowledgements: - * We would like to thank Davide Barbieri, Emanuele Della Valle, - * Marco Balduini, Soheila Dehghanzadeh, Shen Gao, and - * Daniele Dell'Aglio for the effort in the development of the software. - * - * This work is partially supported by - * - the European LarKC project (FP7-215535) of DEIB, Politecnico di - * Milano - * - the ERC grant “Search Computing” awarded to prof. Stefano Ceri - * - the European ModaClouds project (FP7-ICT-2011-8-318484) of DEIB, - * Politecnico di Milano - * - the IBM Faculty Award 2013 grated to prof. Emanuele Della Valle; - * - the City Data Fusion for Event Management 2013 project funded - * by EIT Digital of DEIB, Politecnico di Milano - * - the Dynamic and Distributed Information Systems Group of the - * University of Zurich; - * - INSIGHT NUIG and Science Foundation Ireland (SFI) under grant - * No. SFI/12/RC/2289 - */ /* Generated By:JavaCC: Do not edit this line. CsparqlParserConstants.java */ package eu.larkc.csparql.core.new_parser ; diff --git a/csparql-core/src/main/java/eu/larkc/csparql/core/new_parser/CsparqlParserTokenManager.java b/csparql-core/src/main/java/eu/larkc/csparql/core/new_parser/CsparqlParserTokenManager.java index d303749..dea0a9f 100644 --- a/csparql-core/src/main/java/eu/larkc/csparql/core/new_parser/CsparqlParserTokenManager.java +++ b/csparql-core/src/main/java/eu/larkc/csparql/core/new_parser/CsparqlParserTokenManager.java @@ -1,46 +1,11 @@ -/** - * Copyright 2011-2015 DEIB - Politecnico di Milano - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Acknowledgements: - * We would like to thank Davide Barbieri, Emanuele Della Valle, - * Marco Balduini, Soheila Dehghanzadeh, Shen Gao, and - * Daniele Dell'Aglio for the effort in the development of the software. - * - * This work is partially supported by - * - the European LarKC project (FP7-215535) of DEIB, Politecnico di - * Milano - * - the ERC grant “Search Computing” awarded to prof. Stefano Ceri - * - the European ModaClouds project (FP7-ICT-2011-8-318484) of DEIB, - * Politecnico di Milano - * - the IBM Faculty Award 2013 grated to prof. Emanuele Della Valle; - * - the City Data Fusion for Event Management 2013 project funded - * by EIT Digital of DEIB, Politecnico di Milano - * - the Dynamic and Distributed Information Systems Group of the - * University of Zurich; - * - INSIGHT NUIG and Science Foundation Ireland (SFI) under grant - * No. SFI/12/RC/2289 - */ +/* CsparqlParserTokenManager.java */ /* Generated By:JavaCC: Do not edit this line. CsparqlParserTokenManager.java */ package eu.larkc.csparql.core.new_parser ; import java.io.StringReader; - import eu.larkc.csparql.core.new_parser.utility_files.*; /** Token Manager. */ -public class CsparqlParserTokenManager implements CsparqlParserConstants -{ +public class CsparqlParserTokenManager implements CsparqlParserConstants { /** Debug output. */ public java.io.PrintStream debugStream = System.out; @@ -52,8 +17,7 @@ private int jjStopAtPos(int pos, int kind) jjmatchedPos = pos; return pos + 1; } -private int jjMoveStringLiteralDfa0_0() -{ +private int jjMoveStringLiteralDfa0_0(){ switch(curChar) { case 9: @@ -117,8 +81,7 @@ private int jjMoveStringLiteralDfa0_0() return jjMoveNfa_0(0, 0); } } -private int jjMoveStringLiteralDfa1_0(long active0) -{ +private int jjMoveStringLiteralDfa1_0(long active0){ try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return jjMoveNfa_0(0, 0); @@ -170,8 +133,7 @@ private int jjMoveStringLiteralDfa1_0(long active0) } return jjMoveNfa_0(0, 1); } -private int jjMoveStringLiteralDfa2_0(long old0, long active0) -{ +private int jjMoveStringLiteralDfa2_0(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 1); try { curChar = input_stream.readChar(); } @@ -236,8 +198,7 @@ private int jjMoveStringLiteralDfa2_0(long old0, long active0) } return jjMoveNfa_0(0, 2); } -private int jjMoveStringLiteralDfa3_0(long old0, long active0) -{ +private int jjMoveStringLiteralDfa3_0(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 2); try { curChar = input_stream.readChar(); } @@ -303,8 +264,7 @@ else if ((active0 & 0x400L) != 0L) } return jjMoveNfa_0(0, 3); } -private int jjMoveStringLiteralDfa4_0(long old0, long active0) -{ +private int jjMoveStringLiteralDfa4_0(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 3); try { curChar = input_stream.readChar(); } @@ -374,8 +334,7 @@ else if ((active0 & 0x2000000L) != 0L) } return jjMoveNfa_0(0, 4); } -private int jjMoveStringLiteralDfa5_0(long old0, long active0) -{ +private int jjMoveStringLiteralDfa5_0(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 4); try { curChar = input_stream.readChar(); } @@ -425,8 +384,7 @@ else if ((active0 & 0x800000L) != 0L) } return jjMoveNfa_0(0, 5); } -private int jjMoveStringLiteralDfa6_0(long old0, long active0) -{ +private int jjMoveStringLiteralDfa6_0(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 5); try { curChar = input_stream.readChar(); } @@ -489,8 +447,7 @@ else if ((active0 & 0x1000000L) != 0L) } return jjMoveNfa_0(0, 6); } -private int jjMoveStringLiteralDfa7_0(long old0, long active0) -{ +private int jjMoveStringLiteralDfa7_0(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 6); try { curChar = input_stream.readChar(); } @@ -527,8 +484,7 @@ private int jjMoveStringLiteralDfa7_0(long old0, long active0) } return jjMoveNfa_0(0, 7); } -private int jjMoveStringLiteralDfa8_0(long old0, long active0) -{ +private int jjMoveStringLiteralDfa8_0(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 7); try { curChar = input_stream.readChar(); } @@ -558,8 +514,7 @@ else if ((active0 & 0x4000000L) != 0L) } return jjMoveNfa_0(0, 8); } -private int jjMoveStringLiteralDfa9_0(long old0, long active0) -{ +private int jjMoveStringLiteralDfa9_0(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 8); try { curChar = input_stream.readChar(); } @@ -588,8 +543,7 @@ private int jjMoveStringLiteralDfa9_0(long old0, long active0) } return jjMoveNfa_0(0, 9); } -private int jjMoveStringLiteralDfa10_0(long old0, long active0) -{ +private int jjMoveStringLiteralDfa10_0(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 9); try { curChar = input_stream.readChar(); } @@ -611,8 +565,7 @@ private int jjMoveStringLiteralDfa10_0(long old0, long active0) } return jjMoveNfa_0(0, 10); } -private int jjMoveStringLiteralDfa11_0(long old0, long active0) -{ +private int jjMoveStringLiteralDfa11_0(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 10); try { curChar = input_stream.readChar(); } @@ -634,8 +587,7 @@ private int jjMoveStringLiteralDfa11_0(long old0, long active0) } return jjMoveNfa_0(0, 11); } -private int jjMoveStringLiteralDfa12_0(long old0, long active0) -{ +private int jjMoveStringLiteralDfa12_0(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 11); try { curChar = input_stream.readChar(); } @@ -657,8 +609,7 @@ private int jjMoveStringLiteralDfa12_0(long old0, long active0) } return jjMoveNfa_0(0, 12); } -private int jjMoveStringLiteralDfa13_0(long old0, long active0) -{ +private int jjMoveStringLiteralDfa13_0(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 12); try { curChar = input_stream.readChar(); } @@ -680,8 +631,7 @@ private int jjMoveStringLiteralDfa13_0(long old0, long active0) } return jjMoveNfa_0(0, 13); } -private int jjMoveStringLiteralDfa14_0(long old0, long active0) -{ +private int jjMoveStringLiteralDfa14_0(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 13); try { curChar = input_stream.readChar(); } @@ -706,8 +656,7 @@ private int jjMoveStringLiteralDfa14_0(long old0, long active0) } return jjMoveNfa_0(0, 14); } -private int jjMoveStringLiteralDfa15_0(long old0, long active0) -{ +private int jjMoveStringLiteralDfa15_0(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 14); try { curChar = input_stream.readChar(); } @@ -768,7 +717,7 @@ else if ((0x3ff000000000000L & l) != 0L) kind = 15; } if (curChar == 60) - jjCheckNAddTwoStates(4, 5); + { jjCheckNAddTwoStates(4, 5); } break; case 1: if ((0x3ff000000000000L & l) != 0L && kind > 15) @@ -780,11 +729,11 @@ else if ((0x3ff000000000000L & l) != 0L) break; case 3: if (curChar == 60) - jjCheckNAddTwoStates(4, 5); + { jjCheckNAddTwoStates(4, 5); } break; case 4: if ((0xfffffffa00000000L & l) != 0L) - jjCheckNAddTwoStates(4, 5); + { jjCheckNAddTwoStates(4, 5); } break; case 5: if (curChar == 62 && kind > 17) @@ -819,7 +768,7 @@ else if ((0x78000000e8000001L & l) != 0L) break; case 4: if ((0xc7fffffeafffffffL & l) != 0L) - jjAddStates(0, 1); + { jjAddStates(0, 1); } break; default : break; } @@ -835,7 +784,7 @@ else if ((0x78000000e8000001L & l) != 0L) { case 4: if ((jjbitVec0[i2] & l2) != 0L) - jjAddStates(0, 1); + { jjAddStates(0, 1); } break; default : break; } @@ -873,75 +822,12 @@ else if (jjmatchedPos == strPos && jjmatchedKind > strKind) return toRet; } -static final int[] jjnextStates = { - 4, 5, -}; /** Token literal values. */ public static final String[] jjstrLiteralImages = { "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "\40", null, null, null, null, null, null, null, null, null, }; - -/** Lexer state names. */ -public static final String[] lexStateNames = { - "DEFAULT", -}; -static final long[] jjtoToken = { - 0xfffffe1L, -}; -static final long[] jjtoSkip = { - 0x1eL, -}; -protected SimpleCharStream input_stream; -private final int[] jjrounds = new int[6]; -private final int[] jjstateSet = new int[12]; -protected char curChar; -/** Constructor. */ -public CsparqlParserTokenManager(SimpleCharStream stream){ - if (SimpleCharStream.staticFlag) - throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); - input_stream = stream; -} - -/** Constructor. */ -public CsparqlParserTokenManager(SimpleCharStream stream, int lexState){ - this(stream); - SwitchTo(lexState); -} - -/** Reinitialise parser. */ -public void ReInit(SimpleCharStream stream) -{ - jjmatchedPos = jjnewStateCnt = 0; - curLexState = defaultLexState; - input_stream = stream; - ReInitRounds(); -} -private void ReInitRounds() -{ - int i; - jjround = 0x80000001; - for (i = 6; i-- > 0;) - jjrounds[i] = 0x80000000; -} - -/** Reinitialise parser. */ -public void ReInit(SimpleCharStream stream, int lexState) -{ - ReInit(stream); - SwitchTo(lexState); -} - -/** Switch to specified lex state. */ -public void SwitchTo(int lexState) -{ - if (lexState >= 1 || lexState < 0) - throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); - else - curLexState = lexState; -} - protected Token jjFillToken() { final Token t; @@ -965,6 +851,9 @@ protected Token jjFillToken() return t; } +static final int[] jjnextStates = { + 4, 5, +}; int curLexState = 0; int defaultLexState = 0; @@ -986,9 +875,10 @@ public Token getNextToken() { curChar = input_stream.BeginToken(); } - catch(java.io.IOException e) + catch(Exception e) { jjmatchedKind = 0; + jjmatchedPos = -1; matchedToken = jjFillToken(); return matchedToken; } @@ -1033,6 +923,31 @@ public Token getNextToken() } } +void SkipLexicalActions(Token matchedToken) +{ + switch(jjmatchedKind) + { + default : + break; + } +} +void MoreLexicalActions() +{ + jjimageLen += (lengthOfMatch = jjmatchedPos + 1); + switch(jjmatchedKind) + { + default : + break; + } +} +void TokenLexicalActions(Token matchedToken) +{ + switch(jjmatchedKind) + { + default : + break; + } +} private void jjCheckNAdd(int state) { if (jjrounds[state] != jjround) @@ -1053,4 +968,90 @@ private void jjCheckNAddTwoStates(int state1, int state2) jjCheckNAdd(state2); } + /** Constructor. */ + public CsparqlParserTokenManager(SimpleCharStream stream){ + + if (SimpleCharStream.staticFlag) + throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); + + input_stream = stream; + } + + /** Constructor. */ + public CsparqlParserTokenManager (SimpleCharStream stream, int lexState){ + ReInit(stream); + SwitchTo(lexState); + } + + /** Reinitialise parser. */ + + public void ReInit(SimpleCharStream stream) + { + + + jjmatchedPos = + jjnewStateCnt = + 0; + curLexState = defaultLexState; + input_stream = stream; + ReInitRounds(); + } + + private void ReInitRounds() + { + int i; + jjround = 0x80000001; + for (i = 6; i-- > 0;) + jjrounds[i] = 0x80000000; + } + + /** Reinitialise parser. */ + public void ReInit(SimpleCharStream stream, int lexState) + + { + ReInit(stream); + SwitchTo(lexState); + } + + /** Switch to specified lex state. */ + public void SwitchTo(int lexState) + { + if (lexState >= 1 || lexState < 0) + throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); + else + curLexState = lexState; + } + + +/** Lexer state names. */ +public static final String[] lexStateNames = { + "DEFAULT", +}; + +/** Lex State array. */ +public static final int[] jjnewLexState = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, +}; +static final long[] jjtoToken = { + 0xfffffe1L, +}; +static final long[] jjtoSkip = { + 0x1eL, +}; +static final long[] jjtoSpecial = { + 0x0L, +}; +static final long[] jjtoMore = { + 0x0L, +}; + protected SimpleCharStream input_stream; + + private final int[] jjrounds = new int[6]; + private final int[] jjstateSet = new int[2 * 6]; + private final StringBuilder jjimage = new StringBuilder(); + private StringBuilder image = jjimage; + private int jjimageLen; + private int lengthOfMatch; + protected int curChar; } diff --git a/csparql-core/src/main/java/eu/larkc/csparql/core/new_parser/TokenMgrError.java b/csparql-core/src/main/java/eu/larkc/csparql/core/new_parser/TokenMgrError.java index e98b9bd..33c9941 100644 --- a/csparql-core/src/main/java/eu/larkc/csparql/core/new_parser/TokenMgrError.java +++ b/csparql-core/src/main/java/eu/larkc/csparql/core/new_parser/TokenMgrError.java @@ -174,8 +174,8 @@ public TokenMgrError(String message, int reason) { } /** Full Constructor. */ - public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { - this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); + public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar, int reason) { + this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, (char) curChar), reason); } } /* JavaCC - OriginalChecksum=9adf20c5bdef0f97786f25efba7e1fb3 (do not edit this line) */