mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
adding changes
This commit is contained in:
parent
dead305986
commit
2dad5d0d3d
@ -3,7 +3,7 @@ grammar VirtData;
|
||||
|
||||
virtdataRecipe : virtdataFlow (specend virtdataFlow?)* EOF ;
|
||||
|
||||
virtdataFlow : (COMPOSE)? expression (';' expression?)* ;
|
||||
virtdataFlow : (COMPOSE)? expression (';' expression? | WS? expression)* ;
|
||||
|
||||
expression : (lvalue ASSIGN)? virtdataCall ;
|
||||
|
||||
|
@ -20,9 +20,7 @@ import io.nosqlbench.virtdata.lang.ast.VirtDataAST;
|
||||
import io.nosqlbench.virtdata.lang.ast.VirtDataFlow;
|
||||
import io.nosqlbench.virtdata.lang.generated.VirtDataLexer;
|
||||
import io.nosqlbench.virtdata.lang.generated.VirtDataParser;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.CodePointCharStream;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.antlr.v4.runtime.*;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -36,14 +34,11 @@ public class VirtDataDSL {
|
||||
|
||||
try {
|
||||
CodePointCharStream cstream = CharStreams.fromString(input);
|
||||
VirtDataLexer lexer = new VirtDataLexer(cstream);
|
||||
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
||||
VirtDataParser parser = new VirtDataParser(tokens);
|
||||
VirtDataParser parser = getVirtDataParser(cstream);
|
||||
VirtDataBuilder astListener = new VirtDataBuilder();
|
||||
parser.addParseListener(astListener);
|
||||
|
||||
VirtDataParser.VirtdataFlowContext virtdataFlowContext = parser.virtdataFlow();
|
||||
logger.trace(() -> "parse tree: " + virtdataFlowContext.toStringTree(parser));
|
||||
VirtDataParser.VirtdataRecipeContext virtdataRecipeContext = parser.virtdataRecipe();
|
||||
logger.trace(() -> "parse tree: " + virtdataRecipeContext.toStringTree(parser));
|
||||
|
||||
if (astListener.hasErrors()) {
|
||||
System.out.println(astListener.getErrorNodes());
|
||||
@ -67,6 +62,18 @@ public class VirtDataDSL {
|
||||
}
|
||||
}
|
||||
|
||||
private static VirtDataParser getVirtDataParser(CodePointCharStream cstream) {
|
||||
VirtDataLexer lexer = new VirtDataLexer(cstream);
|
||||
lexer.addErrorListener(new BaseErrorListener() {
|
||||
@Override
|
||||
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
||||
return new VirtDataParser(tokens);
|
||||
}
|
||||
|
||||
public static class ParseResult {
|
||||
public Throwable throwable;
|
||||
public VirtDataFlow flow;
|
||||
|
Loading…
Reference in New Issue
Block a user