List of usage examples for org.antlr.v4.runtime ParserRuleContext getText
@Override
public String getText()
From source file:org.opencypher.tools.g4processors.G4Listener.java
License:Apache License
private String cleanQuasiComment(ParserRuleContext cmtCtx) { if (cmtCtx != null) { return cmtCtx.getText().replaceFirst("/\\*\\*", "").replaceFirst("\\*/", "") .replaceAll("\r?\n\\s*\\*", "\n").replaceFirst("\r?\n$", ""); } else {// w ww . j a v a 2s.com return null; } }
From source file:org.wso2.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl.java
License:Open Source License
public SiddhiParserException newSiddhiParserException(ParserRuleContext context) { return new SiddhiParserException("You have an error in your SiddhiQL near '" + context.getText() + "' line " + context.start.getLine() + ":" + context.start.getCharPositionInLine()); }
From source file:org.wso2.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl.java
License:Open Source License
public SiddhiParserException newSiddhiParserException(ParserRuleContext context, String message) { return new SiddhiParserException( "You have an error in your SiddhiQL near '" + context.getText() + "' line " + context.start.getLine() + ":" + context.start.getCharPositionInLine() + ", " + message); }
From source file:org.xgmtk.lore.ast.ASTBuilder.java
License:Apache License
protected static void printContext(ParserRuleContext ctx) { System.err.println("(Context object id: " + ctx + ", line: " + ctx.start.getLine() + ", \"" + ctx.getText() + "\", child count: " + ctx.getChildCount() + "){"); for (int i = 0; i < ctx.getChildCount(); ++i) { ParseTree ptree = ctx.getChild(i); System.err.println("\t\"" + ptree.getText() + "\"(has: " + ptree.getChildCount() + ")"); }/* w w w .ja v a 2 s. com*/ System.err.println("}"); }
From source file:parser.listeners.CheckListener.java
License:Open Source License
private void add(ParserRuleContext ctx, Boolean valid, Boolean print, GlobalInfo.nodeTypes type, ClassInfo value) {//from w ww .j a va2s . c om if (print) Logger.printValue(ctx, valid.toString() + " : " + ctx.getText()); WalkInfo info = new WalkInfo(valid, ctx.getText()); info.setClassType(value); info.setNodeType(type); globalInfo.getCurrentQueue().add(info); }
From source file:parser.listeners.CheckListener.java
License:Open Source License
private void checkAndAdd(ParserRuleContext ctx, Boolean valid, Boolean print, GlobalInfo.nodeTypes type) { Boolean symbolExists;// w ww . java2 s.co m String code = ctx.getText(); ClassInfo classType = null; if (globalInfo.getObjectContext() != null) { ClassInfo ci = globalInfo.getObjectContext(); globalInfo.setPreviousObjectContext(ci); // this avoids issues in case one Class overwrites a method from it's parent if (globalInfo.isTopLevel() && globalInfo.isLeftSideAssignment()) classType = ci.getPropertyExcludeParents(code); // we supose that inside a function we don't modify the prototype else { classType = ci.getProperty(code); //example: Object.keys will fail because we're checking //the function, instead of the class if (classType == null) { if (globalInfo.getClasses().get(ci.getName()) != null) { ci = globalInfo.getClasses().get(ci.getName()); globalInfo.setPreviousObjectContext(ci); classType = ci.getProperty(code); } } } if (code.equals("prototype")) { symbolExists = true; classType = ci; } else if (classType != null) { symbolExists = true; } else symbolExists = false; //TODO add property automatically to all objects instead of hardcoding it here if (classType == null && code.equals("constructor")) { symbolExists = true; // TODO eventually we may need to support multiple parentClass ClassInfo constructor = globalInfo.getDocumentScope() .getSymbolOfStack(globalInfo.getObjectContext().getParentClasses().getAllParents().get(0)); globalInfo.setObjectContext(constructor); classType = constructor; } } else { classType = globalInfo.getCurrentScope().getSymbolOfStack(code); if (classType == null) classType = globalInfo.getClasses().get(code); symbolExists = classType != null; } if (classType != null) classType = new ClassInfo(classType); add(ctx, symbolExists, print, type, classType); }
From source file:ruke.vrj.phase.TypeCheck.java
License:Open Source License
private final void checkForNumeric(final ParserRuleContext ctx, final Symbol expression) { if (!TypeChecker.isValidNumber(expression)) { this.results.add(new Result(ctx.getStart().getInputStream().getSourceName(), ctx.getStart().getLine(), ctx.getStart().getCharPositionInLine(), ctx.getStart().getCharPositionInLine() + ctx.getText().length(), "Expected number")); }//from ww w . j a v a 2s . c o m }
From source file:ruke.vrj.phase.TypeCheck.java
License:Open Source License
private final void checkForBoolean(final ParserRuleContext ctx, final Symbol expression) { if (!TypeChecker.compatible(this.booleanType, expression)) { this.results.add(new Result(ctx.getStart().getInputStream().getSourceName(), ctx.getStart().getLine(), ctx.getStart().getCharPositionInLine(), ctx.getStart().getCharPositionInLine() + ctx.getText().length(), "Expected boolean expression")); }//from w w w . j a v a2 s . c o m }
From source file:tilda.grammar.TildaSQLTreePrinter.java
License:Apache License
@Override public void enterEveryRule(ParserRuleContext ctx) { LOG.debug(PaddingUtil.getPad(ctx.depth() * 3) + _Parser.getRuleNames()[ctx.getRuleIndex()]); if (isLeafNode(ctx) == true) LOG.debug(PaddingUtil.getPad(ctx.depth() * 3) + " -] " + ctx.getText()); if (_Path.containsKey(ctx.parent) == false) _Path.put(ctx.parent, new ArrayList<String>()); if (_Path.containsKey(ctx) == false) _Path.put(ctx, new ArrayList<String>()); _Path.get(ctx).add(_Parser.getRuleNames()[ctx.getRuleIndex()]); }
From source file:tilda.grammar.TypeManager.java
License:Apache License
public boolean handleType(ColumnType Type, ParserRuleContext ctx) { TypeWrapper w = _ArgumentTypes.isEmpty() == true ? null : _ArgumentTypes.peek(); if (w != null) { if (w.addType(Type, ctx.getText()) == false) { _LastError = w.getLastError(); return false; }//from ww w.j a v a 2 s. co m } return true; }