Skip to content
Snippets Groups Projects
Commit deba2e14 authored by Grégory Mantelet's avatar Grégory Mantelet
Browse files

[ADQL] ADQLParser is no longer a Java Interface and ADQLParserFactory does not

exist anymore.

ADQLParser is now a mix between the former ADQLParserFactory and ADQLParser2xx.
All ADQLParser2xx resulting from the compilation of the JavaCC files are
now named ADQLGrammar2xx and implement the new interface ADQLGrammar. The JavaCC
parsers are no longer used directly. This is the role of ADQLParser to simplify
the parser usage and to allow an easy switch between different grammar versions.

Besides, for more clarity in the class organisation, all generated parser
classes have been moved into the package `adql.parser.grammar`.
parent c00d21d8
No related branches found
No related tags found
No related merge requests found
Showing
with 1288 additions and 69 deletions
...@@ -38,8 +38,8 @@ import adql.db.exception.UnresolvedColumnException; ...@@ -38,8 +38,8 @@ import adql.db.exception.UnresolvedColumnException;
import adql.db.exception.UnresolvedFunctionException; import adql.db.exception.UnresolvedFunctionException;
import adql.db.exception.UnresolvedIdentifiersException; import adql.db.exception.UnresolvedIdentifiersException;
import adql.db.exception.UnresolvedTableException; import adql.db.exception.UnresolvedTableException;
import adql.parser.ParseException;
import adql.parser.QueryChecker; import adql.parser.QueryChecker;
import adql.parser.grammar.ParseException;
import adql.query.ADQLIterator; import adql.query.ADQLIterator;
import adql.query.ADQLObject; import adql.query.ADQLObject;
import adql.query.ADQLQuery; import adql.query.ADQLQuery;
......
...@@ -26,11 +26,10 @@ import java.util.regex.Pattern; ...@@ -26,11 +26,10 @@ import java.util.regex.Pattern;
import adql.db.DBType.DBDatatype; import adql.db.DBType.DBDatatype;
import adql.parser.ADQLParser; import adql.parser.ADQLParser;
import adql.parser.ADQLParserFactory; import adql.parser.ADQLParser.ADQLVersion;
import adql.parser.ADQLParserFactory.ADQLVersion;
import adql.parser.ParseException;
import adql.parser.Token;
import adql.parser.feature.LanguageFeature; import adql.parser.feature.LanguageFeature;
import adql.parser.grammar.ParseException;
import adql.parser.grammar.Token;
import adql.query.operand.ADQLOperand; import adql.query.operand.ADQLOperand;
import adql.query.operand.function.ADQLFunction; import adql.query.operand.function.ADQLFunction;
import adql.query.operand.function.DefaultUDF; import adql.query.operand.function.DefaultUDF;
...@@ -334,7 +333,7 @@ public class FunctionDef implements Comparable<FunctionDef> { ...@@ -334,7 +333,7 @@ public class FunctionDef implements Comparable<FunctionDef> {
* of the ADQL grammar. * of the ADQL grammar.
*/ */
public FunctionDef(final String fctName, final DBType returnType, final FunctionParam[] params) throws ParseException { public FunctionDef(final String fctName, final DBType returnType, final FunctionParam[] params) throws ParseException {
this(fctName, returnType, params, ADQLParserFactory.DEFAULT_VERSION); this(fctName, returnType, params, ADQLParser.DEFAULT_VERSION);
} }
/** /**
...@@ -415,8 +414,8 @@ public class FunctionDef implements Comparable<FunctionDef> { ...@@ -415,8 +414,8 @@ public class FunctionDef implements Comparable<FunctionDef> {
// Tokenize the given function name: // Tokenize the given function name:
try { try {
parser = (new ADQLParserFactory()).createParser(adqlVersion == null ? ADQLParserFactory.DEFAULT_VERSION : adqlVersion); parser = new ADQLParser(adqlVersion);
tokens = parser.tokenize(fctName); tokens = parser.tokenize(fctName, true);
} catch(ParseException ex) { } catch(ParseException ex) {
throw new ParseException("Invalid UDF name: " + ex.getMessage()); throw new ParseException("Invalid UDF name: " + ex.getMessage());
} }
...@@ -428,7 +427,7 @@ public class FunctionDef implements Comparable<FunctionDef> { ...@@ -428,7 +427,7 @@ public class FunctionDef implements Comparable<FunctionDef> {
throw new ParseException("Invalid UDF name: too many words (a function name must be a single Regular Identifier)!"); throw new ParseException("Invalid UDF name: too many words (a function name must be a single Regular Identifier)!");
// ...that it is a regular identifier: // ...that it is a regular identifier:
if (!parser.isRegularIdentifier(tokens[0].image)) if (!parser.getGrammarParser().isRegularIdentifier(tokens[0].image))
throw new ParseException("Invalid UDF name: \"" + fctName + "\" is not a Regular Identifier!"); throw new ParseException("Invalid UDF name: \"" + fctName + "\" is not a Regular Identifier!");
// ...that it is not already an existing ADQL function name: // ...that it is not already an existing ADQL function name:
......
...@@ -24,7 +24,7 @@ import java.util.regex.Matcher; ...@@ -24,7 +24,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import adql.parser.ADQLQueryFactory; import adql.parser.ADQLQueryFactory;
import adql.parser.ParseException; import adql.parser.grammar.ParseException;
import adql.query.TextPosition; import adql.query.TextPosition;
import adql.query.operand.ADQLOperand; import adql.query.operand.ADQLOperand;
import adql.query.operand.NegativeOperand; import adql.query.operand.NegativeOperand;
......
...@@ -20,7 +20,7 @@ package adql.db.exception; ...@@ -20,7 +20,7 @@ package adql.db.exception;
*/ */
import adql.db.DBChecker; import adql.db.DBChecker;
import adql.parser.ParseException; import adql.parser.grammar.ParseException;
import adql.query.operand.ADQLColumn; import adql.query.operand.ADQLColumn;
/** /**
......
...@@ -19,7 +19,7 @@ package adql.db.exception; ...@@ -19,7 +19,7 @@ package adql.db.exception;
* Copyright 2014-2015 - Astronomisches Rechen Institut (ARI) * Copyright 2014-2015 - Astronomisches Rechen Institut (ARI)
*/ */
import adql.parser.ParseException; import adql.parser.grammar.ParseException;
import adql.query.TextPosition; import adql.query.TextPosition;
import adql.query.operand.function.ADQLFunction; import adql.query.operand.function.ADQLFunction;
......
...@@ -24,7 +24,7 @@ import java.util.ArrayList; ...@@ -24,7 +24,7 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import adql.db.DBChecker; import adql.db.DBChecker;
import adql.parser.ParseException; import adql.parser.grammar.ParseException;
/** /**
* This exception is thrown by {@link DBChecker} when several columns, tables, * This exception is thrown by {@link DBChecker} when several columns, tables,
......
...@@ -19,7 +19,7 @@ package adql.db.exception; ...@@ -19,7 +19,7 @@ package adql.db.exception;
* Copyright 2013-2015 - Astronomisches Rechen Institut (ARI) * Copyright 2013-2015 - Astronomisches Rechen Institut (ARI)
*/ */
import adql.parser.ParseException; import adql.parser.grammar.ParseException;
import adql.query.TextPosition; import adql.query.TextPosition;
/** /**
......
...@@ -20,8 +20,7 @@ package adql.db.exception; ...@@ -20,8 +20,7 @@ package adql.db.exception;
*/ */
import adql.db.DBChecker; import adql.db.DBChecker;
import adql.parser.ParseException; import adql.parser.grammar.ParseException;
import adql.query.from.ADQLTable; import adql.query.from.ADQLTable;
import adql.query.operand.ADQLColumn; import adql.query.operand.ADQLColumn;
......
...@@ -19,8 +19,8 @@ package adql.db.exception; ...@@ -19,8 +19,8 @@ package adql.db.exception;
* Copyright 2019 - UDS/Centre de Données astronomiques de Strasbourg (CDS) * Copyright 2019 - UDS/Centre de Données astronomiques de Strasbourg (CDS)
*/ */
import adql.parser.ParseException;
import adql.parser.feature.LanguageFeature; import adql.parser.feature.LanguageFeature;
import adql.parser.grammar.ParseException;
import adql.query.ADQLObject; import adql.query.ADQLObject;
/** /**
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment