@Override public void setEncoding(Encoding encoding) { completeSource.setEncoding(encoding); encodeExistingScriptLines(encoding); }
@Override public IRubyObject getRemainingAsIO() { if (scriptLines == null) return null; return new RubyIO(scriptLines.getRuntime(), getRemainingAsChannel()); } }
@SuppressWarnings("unchecked") public Node parse(String file, byte[] content, DynamicScope blockScope, ParserConfiguration configuration) { RubyArray list = getLines(configuration, runtime, file); ByteList in = new ByteList(content, configuration.getDefaultEncoding()); LexerSource lexerSource = new ByteListLexerSource(file, configuration.getLineNumber(), in, list); return parse(file, lexerSource, blockScope, configuration); }
@SuppressWarnings("unchecked") public Node parse(String file, ByteList content, DynamicScope blockScope, ParserConfiguration configuration) { configuration.setDefaultEncoding(content.getEncoding()); RubyArray list = getLines(configuration, runtime, file); LexerSource lexerSource = new ByteListLexerSource(file, configuration.getLineNumber(), content, list); return parse(file, lexerSource, blockScope, configuration); }
@SuppressWarnings("unchecked") public Node parse(String file, ByteList content, DynamicScope blockScope, ParserConfiguration configuration) { configuration.setDefaultEncoding(content.getEncoding()); RubyArray list = getLines(configuration, runtime, file); LexerSource lexerSource = new ByteListLexerSource(file, configuration.getLineNumber(), content, list); return parse(file, lexerSource, blockScope, configuration); }
@Override public void setEncoding(Encoding encoding) { completeSource.setEncoding(encoding); encodeExistingScriptLines(encoding); }
@Override public IRubyObject getRemainingAsIO() { if (scriptLines == null) return null; return new RubyIO(scriptLines.getRuntime(), getRemainingAsChannel()); } }
@SuppressWarnings("unchecked") public Node parse(String file, byte[] content, DynamicScope blockScope, ParserConfiguration configuration) { RubyArray list = getLines(configuration, runtime, file); ByteList in = new ByteList(content, configuration.getDefaultEncoding()); LexerSource lexerSource = new ByteListLexerSource(file, configuration.getLineNumber(), in, list); return parse(file, lexerSource, blockScope, configuration); }
private LexerSource source(ThreadContext context, IRubyObject src, String filename, int lineno) { // FIXME: respond_to? returns private methods DynamicMethod method = src.getMetaClass().searchMethod("gets"); if (method.isUndefined() || method.getVisibility() == Visibility.PRIVATE) { return new ByteListLexerSource(filename, lineno, src.convertToString().getByteList(), null); } return new GetsLexerSource(filename, lineno, src, null); }
private LexerSource source(ThreadContext context, IRubyObject src, String filename, int lineno) { // FIXME: respond_to? returns private methods DynamicMethod method = src.getMetaClass().searchMethod("gets"); if (method.isUndefined() || method.getVisibility() == Visibility.PRIVATE) { return new ByteListLexerSource(filename, lineno, src.convertToString().getByteList(), null); } return new GetsLexerSource(filename, lineno, src, null); }
private void initLexer(String title) { LexerSource lexerSource = new ByteListLexerSource(title, 0, new ByteList(utf8Bytes), null); lexerSource.setEncoding(UTF8Encoding.INSTANCE); ParserSupport parserSupport = new ParserSupport(); lexer = new RubyLexer(parserSupport, lexerSource, new NullWarnings(Ruby.getGlobalRuntime())); parserSupport.setLexer(lexer); parserSupport.setConfiguration(new ParserConfiguration(Ruby.getGlobalRuntime(), 0, false, true, false)); parserSupport.setResult(new RubyParserResult()); parserSupport.setWarnings(new NullWarnings(Ruby.getGlobalRuntime())); parserSupport.initTopLocalVariables(); lexer.setState(LexingCommon.EXPR_BEG); }