/** Add a child to this node based upon badToken. It * creates a ErrorNodeImpl rather than using * {@link Parser#createErrorNode(ParserRuleContext, Token)}. I'm leaving this * in for compatibility but the parser doesn't use this anymore. */ @Deprecated public ErrorNode addErrorNode(Token badToken) { ErrorNodeImpl t = new ErrorNodeImpl(badToken); addAnyChild(t); t.setParent(this); return t; }
/** How to create an error node, given a token, associated with a parent. * Typically, the error node to create is not a function of the parent. * * @since 4.7 */ public ErrorNode createErrorNode(ParserRuleContext parent, Token t) { return new ErrorNodeImpl(t); }
/** * COPY a ctx (I'm deliberately not using copy constructor) to avoid * confusion with creating node with parent. Does not copy children * (except error leaves). * * <p>This is used in the generated parser code to flip a generic XContext * node for rule X to a YContext for alt label Y. In that sense, it is not * really a generic copy function.</p> * * <p>If we do an error sync() at start of a rule, we might add error nodes * to the generic XContext so this function must copy those nodes to the * YContext as well else they are lost!</p> */ public void copyFrom(ParserRuleContext ctx) { this.parent = ctx.parent; this.invokingState = ctx.invokingState; this.start = ctx.start; this.stop = ctx.stop; // copy any error nodes to alt label node if ( ctx.children!=null ) { this.children = new ArrayList<ParseTree>(); // reset parent pointer for any error nodes for (ParseTree child : ctx.children) { if (child instanceof ErrorNodeImpl) { ((ErrorNodeImpl)child).setParent(this); } addAnyChild(child); } } }
if (child instanceof ErrorNodeImpl) { ErrorNodeImpl eni = (ErrorNodeImpl) child; CommonToken offendingToken = (CommonToken) eni.getSymbol(); int offendingStart = offendingToken.getCharPositionInLine(); int offendingStop = -1;
/** How to create an error node, given a token, associated with a parent. * Typically, the error node to create is not a function of the parent. * * @since 4.7 */ public ErrorNode createErrorNode(ParserRuleContext parent, Token t) { return new ErrorNodeImpl(t); }
if (child instanceof ErrorNodeImpl) { ErrorNodeImpl eni = (ErrorNodeImpl) child; CommonToken offendingToken = (CommonToken) eni.getSymbol(); int offendingStart = offendingToken.getCharPositionInLine(); int offendingStop = -1;
/** How to create an error node, given a token, associated with a parent. * Typically, the error node to create is not a function of the parent. * * @since 4.7 */ public ErrorNode createErrorNode(ParserRuleContext parent, Token t) { ErrorNodeImpl node = new ErrorNodeImpl(t); node.setParent(parent); return node; }
public ErrorNode addErrorNode(Token badToken) { ErrorNodeImpl t = new ErrorNodeImpl(badToken); addChild(t); t.parent = this; return t; }
/** Add a child to this node based upon badToken. It * creates a ErrorNodeImpl rather than using * {@link Parser#createErrorNode(ParserRuleContext, Token)}. I'm leaving this * in for compatibility but the parser doesn't use this anymore. */ @Deprecated public ErrorNode addErrorNode(Token badToken) { ErrorNodeImpl t = new ErrorNodeImpl(badToken); addAnyChild(t); t.setParent(this); return t; }
public ErrorNode addErrorNode(Token badToken) { ErrorNodeImpl t = new ErrorNodeImpl(badToken); addChild(t); t.parent = this; return t; }
/** Add a child to this node based upon badToken. It * creates a ErrorNodeImpl rather than using * {@link Parser#createErrorNode(ParserRuleContext, Token)}. I'm leaving this * in for compatibility but the parser doesn't use this anymore. */ @Deprecated public ErrorNode addErrorNode(Token badToken) { ErrorNodeImpl t = new ErrorNodeImpl(badToken); addAnyChild(t); t.setParent(this); return t; }