Skip to content

Commit

Permalink
merge MMcM: Initialize parser more carefully
Browse files Browse the repository at this point in the history
Merge pull request #162 from MMcM/sql-parser/parser-init-token
https://github.com/FoundationDB/sql-parser/pull/162
  • Loading branch information
fdb-build committed Dec 29, 2014
2 parents 0fe9de0 + e7b113d commit 00b0d1d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/main/java/com/foundationdb/sql/parser/SQLParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public class SQLParser implements SQLParserContext {
private int generatedColumnNameIndex;

private StringCharStream charStream = null;
private SQLGrammarTokenManager tokenManager = null;
private SQLGrammar parser = null;

private int maxStringLiteralLength = 65535;
Expand Down Expand Up @@ -180,26 +179,20 @@ private static int lineColumnErrorPosition(int line, int column, String sql) {

protected void reinit(String sqlText) throws StandardException {
this.sqlText = sqlText;
if (parser == null) {
// Construct parser + token manager with all references
// correct before anything real is parsed. Otherwise very
// first token might get NPE trying to check feature.
parser = new SQLGrammar(new StringCharStream(""));
parser.setParserContext(this);
}
if (charStream == null) {
charStream = new StringCharStream(sqlText);
}
else {
charStream.ReInit(sqlText);
}
if (tokenManager == null) {
tokenManager = new SQLGrammarTokenManager(null, charStream);
}
else {
tokenManager.ReInit(charStream);
}
if (parser == null) {
parser = new SQLGrammar(tokenManager);
parser.setParserContext(this);
}
else {
parser.ReInit(tokenManager);
}
tokenManager.parser = parser;
parser.ReInit(charStream);
parameterList = new ArrayList<ParameterNode>();
returnParameterFlag = false;
printedObjectsMap = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.foundationdb.sql.parser.SQLParserException: Lexical error at line 1, column 3. Encountered: <EOF> after : ""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
""

0 comments on commit 00b0d1d

Please sign in to comment.