-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a791fd3
commit 2373cb7
Showing
11 changed files
with
9,412 additions
and
11,117 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
DB/src/main/java/com/github/javaparser/ExpressionParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.github.javaparser; | ||
|
||
import com.github.javaparser.ast.expr.Expression; | ||
|
||
import java.io.IOException; | ||
import java.io.StringReader; | ||
|
||
/** | ||
* Helpful class which parses expressions | ||
* and performs extra "this is exactly one expression" validation | ||
*/ | ||
public class ExpressionParser { | ||
public static Expression parseExpression(String expression) throws ParseException, IOException { | ||
// nothing static here, so no synchronization needed (javaparser used to create a static-only parser instance) | ||
StringReader sr = new StringReader(expression); | ||
ParseResult<Expression> result = new JavaParser().parse(ParseStart.EXPRESSION, Providers.provider(sr)); | ||
if (!result.isSuccessful()) { | ||
throw new IllegalArgumentException("Invalid expression " + expression + ": " + result.getProblems().toString()); | ||
} | ||
// a successful parse does not always mean there is a result. | ||
Expression expr = null; | ||
if (result.getResult().isPresent()) { | ||
expr = result.getResult().get(); | ||
} | ||
|
||
// unlikely for there to be tokens left w/out parser.token.next already being non-null (we would already have thrown...) | ||
int test; | ||
try { | ||
while ((test = sr.read()) != -1) { | ||
if (!Character.isWhitespace(test)) { | ||
throw new IllegalArgumentException("Invalid expression " + expression + " was already terminated after " + expr); | ||
} | ||
} | ||
sr.close(); | ||
} catch (IOException ignored){} | ||
return expr; | ||
} | ||
} |
214 changes: 105 additions & 109 deletions
214
DB/src/main/java/io/deephaven/db/tables/lang/DBLanguageFunctionGenerator.java
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.