/** 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(); } }
public RubyParser borrowParser(CompatVersion version) { if (version == CompatVersion.RUBY1_8) { return new DefaultRubyParser(); } else if (version == CompatVersion.RUBY1_9) { return new Ruby19Parser(); } else { return new Ruby20Parser(); } }
/** * Is the top of this scope a block scope (which happens in evals). * This is supposed to serve same purpose as MRIs: dyna_in_block but * I don't quite get why it is so complicated. All non-eval parsers * have local scopes except eval but they combine in_main || compile_for_eval? */ public boolean isBlockTopLevel() { return getConfiguration().isEvalParse(); }
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { yyVal = support.new_args(((ArgsTailHolder)yyVals[0+yyTop]).getPosition(), null, null, null, null, ((ArgsTailHolder)yyVals[0+yyTop])); return yyVal; } };
private static IRScope getEvalContainerScope(Ruby runtime, StaticScope evalScope) { // SSS FIXME: Weirdness here. We cannot get the containing IR scope from evalScope because of static-scope wrapping // that is going on // 1. In all cases, DynamicScope.getEvalScope wraps the executing static scope in a new local scope. // 2. For instance-eval (module-eval, class-eval) scenarios, there is an extra scope that is added to // the stack in ThreadContext.java:preExecuteUnder // I dont know what rule to apply when. However, in both these cases, since there is no IR-scope associated, // I have used the hack below where I first unwrap once and see if I get a non-null IR scope. If that doesn't // work, I unwarp once more and I am guaranteed to get the IR scope I want. IRScope containingIRScope = ((IRStaticScope)evalScope.getEnclosingScope()).getIRScope(); if (containingIRScope == null) containingIRScope = ((IRStaticScope)evalScope.getEnclosingScope().getEnclosingScope()).getIRScope(); return containingIRScope; }
@Override public String toString() { return "BlockScope: " + super.toString() + "\n" + getEnclosingScope(); }
/** 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) { yyVal = support.new_args(((ArgsTailHolder)yyVals[0+yyTop]).getPosition(), null, null, null, null, ((ArgsTailHolder)yyVals[0+yyTop])); return yyVal; } };
/** * Is the top of this scope a block scope (which happens in evals). * This is supposed to serve same purpose as MRIs: dyna_in_block but * I don't quite get why it is so complicated. All non-eval parsers * have local scopes except eval but they combine in_main || compile_for_eval? */ public boolean isBlockTopLevel() { return getConfiguration().isEvalParse(); }
public RubyParser borrowParser(CompatVersion version) { if (version == CompatVersion.RUBY1_8) { return new DefaultRubyParser(); } else if (version == CompatVersion.RUBY1_9) { return new Ruby19Parser(); } else { return new Ruby20Parser(); } }
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { yyVal = support.new_args(((ArgsTailHolder)yyVals[0+yyTop]).getPosition(), null, null, null, null, ((ArgsTailHolder)yyVals[0+yyTop])); return yyVal; } };
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { yyVal = support.new_args(((ArgsTailHolder)yyVals[0+yyTop]).getPosition(), null, null, null, null, ((ArgsTailHolder)yyVals[0+yyTop])); return yyVal; } };
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { yyVal = support.new_args(((ArgsTailHolder)yyVals[0+yyTop]).getPosition(), null, null, null, null, ((ArgsTailHolder)yyVals[0+yyTop])); return yyVal; } };
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { yyVal = support.new_args(((ArgsTailHolder)yyVals[0+yyTop]).getPosition(), null, null, null, null, ((ArgsTailHolder)yyVals[0+yyTop])); return yyVal; } };
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { yyVal = support.new_args(((ArgsTailHolder)yyVals[0+yyTop]).getPosition(), null, null, null, null, ((ArgsTailHolder)yyVals[0+yyTop])); return yyVal; } };
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { yyVal = support.new_args(((ArgsTailHolder)yyVals[0+yyTop]).getPosition(), null, null, null, null, ((ArgsTailHolder)yyVals[0+yyTop])); return yyVal; } };