@Override protected ASTNode parseInternal(IParseContext context) throws ParseException { ITextRegion region = new TextRegion(context.currentParseIndex(), 0); this.macroName = context.parseIdentifier(region, false); if (context.getCurrentlyExpandingMacro() != null) { context.addCompilationError( "Sorry, invoking macros from another macro is currently not implemented", this); } // actual existance of invoked macro is checked by ExpandMacrosPhase region.merge(context.skipWhitespace(false)); if (!context.eof() && context.peek(TokenType.PARENS_OPEN)) { // parse arguments region.merge(context.read(TokenType.PARENS_OPEN)); region.merge(context.skipWhitespace(false)); while (!context.eof() && !context.peek(TokenType.PARENS_CLOSE)) { arguments.add(new MacroArgumentNode().parse(context)); region.merge(context.skipWhitespace(false)); if (context.eof() || context.peek(TokenType.PARENS_CLOSE)) { break; } region.merge(context.read(TokenType.COMMA)); } region.merge(context.read(TokenType.PARENS_CLOSE)); } mergeWithAllTokensTextRegion(region); return this; }
private void setNodeAndLocation(ASTNode node, ITextRegion range) { if (node != null) { setAttribute(IMarker.ATTR_AST_NODE, node); if (range == null && node.getTextRegion() != null) { setLocation(new TextRegion(node.getTextRegion())); if (!hasAttribute(IMarker.ATTR_SRC_OFFSET)) { setErrorOffset(node.getTextRegion().getStartingOffset()); } } } if (range != null) { setLocation(new TextRegion(range)); if (!hasAttribute(IMarker.ATTR_SRC_OFFSET)) { setErrorOffset(range.getStartingOffset()); } } }