@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { support.getResult().addBeginNode(new PreExe19Node(((ISourcePosition)yyVals[-3+yyTop]), support.getCurrentScope(), ((Node)yyVals[-1+yyTop]))); yyVal = null; return yyVal; } };
public Node addRootNode(Node topOfAST, ISourcePosition position) { position = topOfAST != null ? topOfAST.getPosition() : position; if (result.getBeginNodes().isEmpty()) { if (topOfAST == null) topOfAST = NilImplicitNode.NIL; return new RootNode(position, result.getScope(), topOfAST); } BlockNode newTopOfAST = new BlockNode(position); for (Node beginNode: result.getBeginNodes()) { appendToBlock(newTopOfAST, beginNode); } // Add real top to new top (unless this top is empty [only begin/end nodes or truly empty]) if (topOfAST != null) newTopOfAST.add(topOfAST); return new RootNode(position, result.getScope(), newTopOfAST); }
/** * Description of the RubyMethod */ public void initTopLocalVariables() { DynamicScope scope = configuration.getScope(); currentScope = scope.getStaticScope(); result.setScope(scope); }
try { result = parser.parse(configuration, lexerSource); if (result.getEndOffset() >= 0 && configuration.isSaveData()) { IRubyObject verbose = runtime.getVerbose(); runtime.setVerbose(runtime.getNil()); result.setEndOffset(-1); if (result.getScope() != null) { result.getScope().growIfNeeded(); Node ast = result.getAST();
/** The parse method use an lexer stream and parse it to an AST node * structure */ public RubyParserResult parse(ParserConfiguration configuration) throws IOException { support.reset(); support.setConfiguration(configuration); support.setResult(new RubyParserResult()); yyparse(lexer, configuration.isDebug() ? new YYDebug() : null); return support.getResult(); } }
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { /* ENEBO: Removed !compile_for_eval which probably is to reduce warnings*/ if (((Node)yyVals[0+yyTop]) != null) { /* last expression should not be void */ if (((Node)yyVals[0+yyTop]) instanceof BlockNode) { support.checkUselessStatement(((BlockNode)yyVals[0+yyTop]).getLast()); } else { support.checkUselessStatement(((Node)yyVals[0+yyTop])); } } support.getResult().setAST(support.addRootNode(((Node)yyVals[0+yyTop]))); return yyVal; } };
case '_': if (src.wasBeginOfLine() && src.matchMarker(END_MARKER, false, true)) { parserSupport.getResult().setEndOffset(src.getOffset()); return EOF;
try { result = parser.parse(configuration, lexerSource); if (result.getEndOffset() >= 0 && configuration.isSaveData()) { IRubyObject verbose = runtime.getVerbose(); runtime.setVerbose(runtime.getNil()); result.setEndOffset(-1); if (result.getScope() != null) { result.getScope().growIfNeeded(); Node ast = result.getAST();
/** The parse method use an lexer stream and parse it to an AST node * structure */ public RubyParserResult parse(ParserConfiguration configuration) throws IOException { support.reset(); support.setConfiguration(configuration); support.setResult(new RubyParserResult()); yyparse(lexer, configuration.isDebug() ? new YYDebug() : null); return support.getResult(); } }
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { /* ENEBO: Removed !compile_for_eval which probably is to reduce warnings*/ if (((Node)yyVals[0+yyTop]) != null) { /* last expression should not be void */ if (((Node)yyVals[0+yyTop]) instanceof BlockNode) { support.checkUselessStatement(((BlockNode)yyVals[0+yyTop]).getLast()); } else { support.checkUselessStatement(((Node)yyVals[0+yyTop])); } } support.getResult().setAST(support.addRootNode(((Node)yyVals[0+yyTop]))); return yyVal; } };
case '_': if (src.wasBeginOfLine() && src.matchMarker(END_MARKER, false, true)) { parserSupport.getResult().setEndOffset(src.getOffset()); return EOF;
public Node addRootNode(Node topOfAST, ISourcePosition position) { position = topOfAST != null ? topOfAST.getPosition() : position; if (result.getBeginNodes().isEmpty()) { if (topOfAST == null) topOfAST = NilImplicitNode.NIL; return new RootNode(position, result.getScope(), topOfAST); } BlockNode newTopOfAST = new BlockNode(position); for (Node beginNode: result.getBeginNodes()) { appendToBlock(newTopOfAST, beginNode); } // Add real top to new top (unless this top is empty [only begin/end nodes or truly empty]) if (topOfAST != null) newTopOfAST.add(topOfAST); return new RootNode(position, result.getScope(), newTopOfAST); }
/** The parse method use an lexer stream and parse it to an AST node * structure */ public RubyParserResult parse(ParserConfiguration configuration, LexerSource source) throws IOException { support.reset(); support.setConfiguration(configuration); support.setResult(new RubyParserResult()); lexer.reset(); lexer.setSource(source); lexer.setEncoding(configuration.getDefaultEncoding()); yyparse(lexer, configuration.isDebug() ? new YYDebug() : null); return support.getResult(); } }
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { support.getResult().addBeginNode(new PreExe19Node(((ISourcePosition)yyVals[-3+yyTop]), support.getCurrentScope(), ((Node)yyVals[-1+yyTop]))); yyVal = null; return yyVal; } };
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { if (((Node)yyVals[0+yyTop]) != null) { /* last expression should not be void */ if (((Node)yyVals[0+yyTop]) instanceof BlockNode) { support.checkUselessStatement(((BlockNode)yyVals[0+yyTop]).getLast()); } else { support.checkUselessStatement(((Node)yyVals[0+yyTop])); } } support.getResult().setAST(support.addRootNode(((Node)yyVals[0+yyTop]), support.getPosition(((Node)yyVals[0+yyTop])))); return yyVal; } };
/** * Description of the RubyMethod */ public void initTopLocalVariables() { DynamicScope scope = configuration.getScope(); currentScope = scope.getStaticScope(); result.setScope(scope); }
public Node addRootNode(Node topOfAST) { final int endPosition; if (lexer.isEndSeen()) { endPosition = lexer.getLineOffset(); } else { endPosition = -1; } ISourcePosition position; CoverageData coverageData = configuration.finishCoverage(lexer.getFile(), lexer.lineno()); if (result.getBeginNodes().isEmpty()) { if (topOfAST == null) { topOfAST = NilImplicitNode.NIL; position = lexer.getPosition(); } else { position = topOfAST.getPosition(); } } else { position = topOfAST != null ? topOfAST.getPosition() : result.getBeginNodes().get(0).getPosition(); BlockNode newTopOfAST = new BlockNode(position); for (Node beginNode : result.getBeginNodes()) { appendToBlock(newTopOfAST, beginNode); } // Add real top to new top (unless this top is empty [only begin/end nodes or truly empty]) if (topOfAST != null) newTopOfAST.add(topOfAST); topOfAST = newTopOfAST; } return new RootNode(position, result.getScope(), topOfAST, lexer.getFile(), endPosition, coverageData != null); }
/** The parse method use an lexer stream and parse it to an AST node * structure */ public RubyParserResult parse(ParserConfiguration configuration, LexerSource source) throws IOException { support.reset(); support.setConfiguration(configuration); support.setResult(new RubyParserResult()); lexer.reset(); lexer.setSource(source); lexer.setEncoding(configuration.getDefaultEncoding()); yyparse(lexer, configuration.isDebug() ? new YYDebug() : null); return support.getResult(); } }