本文整理汇总了Java中com.espertech.esper.epl.generated.EsperEPL2GrammarLexer类的典型用法代码示例。如果您正苦于以下问题:Java EsperEPL2GrammarLexer类的具体用法?Java EsperEPL2GrammarLexer怎么用?Java EsperEPL2GrammarLexer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EsperEPL2GrammarLexer类属于com.espertech.esper.epl.generated包,在下文中一共展示了EsperEPL2GrammarLexer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tokenToMathEnum
import com.espertech.esper.epl.generated.EsperEPL2GrammarLexer; //导入依赖的package包/类
private static MathArithTypeEnum tokenToMathEnum(int token) {
switch (token) {
case EsperEPL2GrammarLexer.DIV:
return MathArithTypeEnum.DIVIDE;
case EsperEPL2GrammarLexer.STAR:
return MathArithTypeEnum.MULTIPLY;
case EsperEPL2GrammarLexer.PLUS:
return MathArithTypeEnum.ADD;
case EsperEPL2GrammarLexer.MINUS:
return MathArithTypeEnum.SUBTRACT;
case EsperEPL2GrammarLexer.MOD:
return MathArithTypeEnum.MODULO;
default:
throw ASTWalkException.from("Encountered unrecognized math token type " + token);
}
}
示例2: exitInsertIntoExpr
import com.espertech.esper.epl.generated.EsperEPL2GrammarLexer; //导入依赖的package包/类
public void exitInsertIntoExpr(EsperEPL2GrammarParser.InsertIntoExprContext ctx) {
SelectClauseStreamSelectorEnum selector = SelectClauseStreamSelectorEnum.ISTREAM_ONLY;
if (ctx.r != null) {
selector = SelectClauseStreamSelectorEnum.RSTREAM_ONLY;
} else if (ctx.ir != null) {
selector = SelectClauseStreamSelectorEnum.RSTREAM_ISTREAM_BOTH;
}
// type name
String eventTypeName = ASTUtil.unescapeClassIdent(ctx.classIdentifier());
InsertIntoDesc insertIntoDesc = new InsertIntoDesc(selector, eventTypeName);
// optional columns
if (ctx.columnList() != null) {
for (int i = 0; i < ctx.columnList().getChildCount(); i++) {
ParseTree node = ctx.columnList().getChild(i);
if (ASTUtil.isTerminatedOfType(node, EsperEPL2GrammarLexer.IDENT)) {
insertIntoDesc.add(node.getText());
}
}
}
statementSpec.setInsertIntoDesc(insertIntoDesc);
}
示例3: exitBitWiseExpression
import com.espertech.esper.epl.generated.EsperEPL2GrammarLexer; //导入依赖的package包/类
public void exitBitWiseExpression(EsperEPL2GrammarParser.BitWiseExpressionContext ctx) {
if (ctx.getChildCount() < 2) {
return;
}
BitWiseOpEnum bitWiseOpEnum;
int token = ASTUtil.getAssertTerminatedTokenType(ctx.getChild(1));
switch (token) {
case EsperEPL2GrammarLexer.BAND:
bitWiseOpEnum = BitWiseOpEnum.BAND;
break;
case EsperEPL2GrammarLexer.BOR:
bitWiseOpEnum = BitWiseOpEnum.BOR;
break;
case EsperEPL2GrammarLexer.BXOR:
bitWiseOpEnum = BitWiseOpEnum.BXOR;
break;
default:
throw ASTWalkException.from("Node type " + token + " not a recognized bit wise node type", tokenStream, ctx);
}
ExprBitWiseNode bwNode = new ExprBitWiseNode(bitWiseOpEnum);
ASTExprHelper.exprCollectAddSubNodesAddParentNode(bwNode, ctx, astExprNodeMap);
}
示例4: exitEvalEqualsExpression
import com.espertech.esper.epl.generated.EsperEPL2GrammarLexer; //导入依赖的package包/类
public void exitEvalEqualsExpression(EsperEPL2GrammarParser.EvalEqualsExpressionContext ctx) {
if (ctx.getChildCount() < 2) {
return;
}
ExprNode exprNode;
boolean isNot = ctx.ne != null || ctx.isnot != null || ctx.sqlne != null;
if (ctx.a == null) {
boolean isIs = ctx.is != null || ctx.isnot != null;
exprNode = new ExprEqualsNodeImpl(isNot, isIs);
} else {
boolean isAll = ctx.a.getType() == EsperEPL2GrammarLexer.ALL;
List<EsperEPL2GrammarParser.SubSelectGroupExpressionContext> subselect = ctx.subSelectGroupExpression();
if (subselect != null && !subselect.isEmpty()) {
StatementSpecRaw currentSpec = astStatementSpecMap.remove(ctx.subSelectGroupExpression().get(0).subQueryExpr());
exprNode = new ExprSubselectAllSomeAnyNode(currentSpec, isNot, isAll, null);
} else {
exprNode = new ExprEqualsAllAnyNode(isNot, isAll);
}
}
ASTExprHelper.exprCollectAddSubNodesAddParentNode(exprNode, ctx, astExprNodeMap);
}
示例5: exitSelectClause
import com.espertech.esper.epl.generated.EsperEPL2GrammarLexer; //导入依赖的package包/类
public void exitSelectClause(EsperEPL2GrammarParser.SelectClauseContext ctx) {
SelectClauseStreamSelectorEnum selector;
if (ctx.s != null) {
if (ctx.s.getType() == EsperEPL2GrammarLexer.RSTREAM) {
selector = SelectClauseStreamSelectorEnum.RSTREAM_ONLY;
} else if (ctx.s.getType() == EsperEPL2GrammarLexer.ISTREAM) {
selector = SelectClauseStreamSelectorEnum.ISTREAM_ONLY;
} else if (ctx.s.getType() == EsperEPL2GrammarLexer.IRSTREAM) {
selector = SelectClauseStreamSelectorEnum.RSTREAM_ISTREAM_BOTH;
} else {
throw ASTWalkException.from("Encountered unrecognized token type " + ctx.s.getType(), tokenStream, ctx);
}
statementSpec.setSelectStreamDirEnum(selector);
}
statementSpec.getSelectClauseSpec().setDistinct(ctx.d != null);
}
示例6: handleRecognitionEx
import com.espertech.esper.epl.generated.EsperEPL2GrammarLexer; //导入依赖的package包/类
private static EsperEPL2GrammarParser.StartEventPropertyRuleContext handleRecognitionEx(RecognitionException e, CommonTokenStream tokens, String propertyName, EsperEPL2GrammarParser g) {
// Check for keywords and escape each, parse again
String escapedPropertyName = escapeKeywords(tokens);
CharStream inputEscaped = new CaseInsensitiveInputStream(escapedPropertyName);
EsperEPL2GrammarLexer lexEscaped = ParseHelper.newLexer(inputEscaped);
CommonTokenStream tokensEscaped = new CommonTokenStream(lexEscaped);
EsperEPL2GrammarParser gEscaped = ParseHelper.newParser(tokensEscaped);
try {
return gEscaped.startEventPropertyRule();
} catch (Exception eEscaped) {
}
throw ExceptionConvertor.convertProperty(e, propertyName, true, g);
}
示例7: getTokenBefore
import com.espertech.esper.epl.generated.EsperEPL2GrammarLexer; //导入依赖的package包/类
private static Token getTokenBefore(int i, CommonTokenStream tokens) {
int position = i - 1;
while (position >= 0) {
Token t = tokens.get(position);
if (t.getChannel() != 99 && t.getType() != EsperEPL2GrammarLexer.WS) {
return t;
}
position--;
}
return null;
}
示例8: rewriteScripts
import com.espertech.esper.epl.generated.EsperEPL2GrammarLexer; //导入依赖的package包/类
private static String rewriteScripts(List<UniformPair<Integer>> ranges, CommonTokenStream tokens) {
if (ranges.isEmpty()) {
return tokens.getText();
}
StringWriter writer = new StringWriter();
int rangeIndex = 0;
UniformPair<Integer> current = ranges.get(rangeIndex);
for (int i = 0; i < tokens.size(); i++) {
Token t = tokens.get(i);
if (t.getType() == EsperEPL2GrammarLexer.EOF) {
break;
}
if (i < current.getFirst()) {
writer.append(t.getText());
} else if (i == current.getFirst()) {
writer.append(t.getText());
writer.append("'");
} else if (i == current.getSecond()) {
writer.append("'");
writer.append(t.getText());
rangeIndex++;
if (ranges.size() > rangeIndex) {
current = ranges.get(rangeIndex);
} else {
current = new UniformPair<Integer>(-1, -1);
}
} else if (t.getType() == EsperEPL2GrammarParser.SL_COMMENT || t.getType() == EsperEPL2GrammarParser.ML_COMMENT) {
writeCommentEscapeSingleQuote(writer, t);
} else {
if (t.getType() == EsperEPL2GrammarParser.QUOTED_STRING_LITERAL && i > current.getFirst() && i < current.getSecond()) {
writer.append("\\'");
writer.append(t.getText().substring(1, t.getText().length() - 1));
writer.append("\\'");
} else {
writer.append(t.getText());
}
}
}
return writer.toString();
}
示例9: parse
import com.espertech.esper.epl.generated.EsperEPL2GrammarLexer; //导入依赖的package包/类
/**
* Parse the AST constant node and return Object value.
*
* @param node - parse node for which to parse the string value
* @return value matching AST node type
*/
public static Object parse(ParseTree node) {
if (node instanceof TerminalNode) {
TerminalNode terminal = (TerminalNode) node;
switch (terminal.getSymbol().getType()) {
case EsperEPL2GrammarParser.BOOLEAN_TRUE:
return BoolValue.parseString(terminal.getText());
case EsperEPL2GrammarParser.BOOLEAN_FALSE:
return BoolValue.parseString(terminal.getText());
case EsperEPL2GrammarParser.VALUE_NULL:
return null;
default:
throw ASTWalkException.from("Encountered unexpected constant type " + terminal.getSymbol().getType(), terminal.getSymbol());
}
} else {
RuleNode ruleNode = (RuleNode) node;
int ruleIndex = ruleNode.getRuleContext().getRuleIndex();
if (ruleIndex == EsperEPL2GrammarParser.RULE_number) {
return parseNumber(ruleNode, 1);
} else if (ruleIndex == EsperEPL2GrammarParser.RULE_numberconstant) {
RuleNode number = findChildRuleByType(ruleNode, EsperEPL2GrammarParser.RULE_number);
if (ruleNode.getChildCount() > 1) {
if (ASTUtil.isTerminatedOfType(ruleNode.getChild(0), EsperEPL2GrammarLexer.MINUS)) {
return parseNumber(number, -1);
}
return parseNumber(number, 1);
} else {
return parseNumber(number, 1);
}
} else if (ruleIndex == EsperEPL2GrammarParser.RULE_stringconstant) {
return StringValue.parseString(node.getText());
} else if (ruleIndex == EsperEPL2GrammarParser.RULE_constant) {
return parse(ruleNode.getChild(0));
}
throw ASTWalkException.from("Encountered unrecognized constant", node.getText());
}
}
示例10: parseNumber
import com.espertech.esper.epl.generated.EsperEPL2GrammarLexer; //导入依赖的package包/类
private static Object parseNumber(RuleNode number, int factor) {
int tokenType = getSingleChildTokenType(number);
if (tokenType == EsperEPL2GrammarLexer.IntegerLiteral) {
return parseIntLongByte(number.getText(), factor);
} else if (tokenType == EsperEPL2GrammarLexer.FloatingPointLiteral) {
String numberText = number.getText();
if (numberText.endsWith("f") || numberText.endsWith("F")) {
return Float.parseFloat(number.getText()) * factor;
} else {
return Double.parseDouble(number.getText()) * factor;
}
}
throw ASTWalkException.from("Encountered unrecognized constant", number.getText());
}
示例11: visitTerminal
import com.espertech.esper.epl.generated.EsperEPL2GrammarLexer; //导入依赖的package包/类
public void visitTerminal(TerminalNode terminalNode) {
if (terminalNode.getSymbol().getType() == EsperEPL2GrammarLexer.STAR) {
int ruleIndex = ASTUtil.getRuleIndexIfProvided(terminalNode.getParent());
if (ruleIndex == EsperEPL2GrammarParser.RULE_selectionListElement) {
statementSpec.getSelectClauseSpec().add(new SelectClauseElementWildcard());
}
if (ruleIndex == EsperEPL2GrammarParser.STAR || ruleIndex == EsperEPL2GrammarParser.RULE_expressionWithTime) {
ExprWildcardImpl exprNode = new ExprWildcardImpl();
ASTExprHelper.exprCollectAddSubNodesAddParentNode(exprNode, terminalNode, astExprNodeMap);
}
}
}
示例12: escapeKeywords
import com.espertech.esper.epl.generated.EsperEPL2GrammarLexer; //导入依赖的package包/类
private synchronized static String escapeKeywords(CommonTokenStream tokens) {
if (keywordCache == null) {
keywordCache = new HashSet<String>();
Set<String> keywords = ParseHelper.newParser(tokens).getKeywords();
for (String keyword : keywords) {
if (keyword.charAt(0) == '\'' && keyword.charAt(keyword.length() - 1) == '\'') {
keywordCache.add(keyword.substring(1, keyword.length() - 1));
}
}
}
StringWriter writer = new StringWriter();
// Call getTokens first before invoking tokens.size! ANTLR problem
for (Object token : tokens.getTokens()) {
Token t = (Token) token;
if (t.getType() == EsperEPL2GrammarLexer.EOF) {
break;
}
boolean isKeyword = keywordCache.contains(t.getText().toLowerCase(Locale.ENGLISH));
if (isKeyword) {
writer.append('`');
writer.append(t.getText());
writer.append('`');
} else {
writer.append(t.getText());
}
}
return writer.toString();
}
示例13: parse
import com.espertech.esper.epl.generated.EsperEPL2GrammarLexer; //导入依赖的package包/类
public static Pair<Tree, CommonTokenStream> parse(ParseRuleSelector parseRuleSelector, String text) throws Exception {
EsperEPL2GrammarLexer lex = ParseHelper.newLexer(new CaseInsensitiveInputStream(text));
CommonTokenStream tokens = new CommonTokenStream(lex);
EsperEPL2GrammarParser g = ParseHelper.newParser(tokens);
Tree ctx = parseRuleSelector.invokeParseRule(g);
return new Pair<Tree, CommonTokenStream>(ctx, tokens);
}
示例14: newLexer
import com.espertech.esper.epl.generated.EsperEPL2GrammarLexer; //导入依赖的package包/类
public static EsperEPL2GrammarLexer newLexer(CharStream input) {
EsperEPL2GrammarLexer lex = new EsperEPL2GrammarLexer(input);
lex.removeErrorListeners();
lex.addErrorListener(Antlr4ErrorListener.INSTANCE);
return lex;
}
示例15: parse
import com.espertech.esper.epl.generated.EsperEPL2GrammarLexer; //导入依赖的package包/类
public static List<EPLModuleParseItem> parse(String module) throws ParseException {
CharStream input = new CaseInsensitiveInputStream(module);
EsperEPL2GrammarLexer lex = ParseHelper.newLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lex);
try {
tokens.fill();
} catch (RuntimeException ex) {
String message = "Unexpected exception recognizing module text";
if (ex instanceof LexerNoViableAltException) {
if (ParseHelper.hasControlCharacters(module)) {
message = "Unrecognized control characters found in text, failed to parse text";
} else {
message += ", recognition failed for " + ex.toString();
}
} else if (ex instanceof RecognitionException) {
RecognitionException recog = (RecognitionException) ex;
message += ", recognition failed for " + recog.toString();
} else if (ex.getMessage() != null) {
message += ": " + ex.getMessage();
}
message += " [" + module + "]";
log.error(message, ex);
throw new ParseException(message);
}
List<EPLModuleParseItem> statements = new ArrayList<EPLModuleParseItem>();
StringWriter current = new StringWriter();
Integer lineNum = null;
int charPosStart = 0;
int charPos = 0;
List<Token> tokenList = tokens.getTokens();
Set<Integer> skippedSemicolonIndexes = getSkippedSemicolons(tokenList);
int index = -1;
// Call getTokens first before invoking tokens.size! ANTLR problem
for (Object token : tokenList) {
index++;
Token t = (Token) token;
boolean semi = t.getType() == EsperEPL2GrammarLexer.SEMI && !skippedSemicolonIndexes.contains(index);
if (semi) {
if (current.toString().trim().length() > 0) {
statements.add(new EPLModuleParseItem(current.toString().trim(), lineNum == null ? 0 : lineNum, charPosStart, charPos));
lineNum = null;
}
current = new StringWriter();
} else {
if ((lineNum == null) && (t.getType() != EsperEPL2GrammarParser.WS)) {
lineNum = t.getLine();
charPosStart = charPos;
}
if (t.getType() != EsperEPL2GrammarLexer.EOF) {
current.append(t.getText());
charPos += t.getText().length();
}
}
}
if (current.toString().trim().length() > 0) {
statements.add(new EPLModuleParseItem(current.toString().trim(), lineNum == null ? 0 : lineNum, 0, 0));
}
return statements;
}