/** * Create a source. * * @param name the name of the source (e.g a filename: foo.rb) * @param content the data of the source * @return the new source */ public static LexerSource getSource(String name, InputStream content, List<String> list, ParserConfiguration configuration) { return new InputStreamLexerSource(name, content, list, configuration.getLineNumber(), configuration.hasExtraPositionInformation()); }
/** * Create a source. * * @param name the name of the source (e.g a filename: foo.rb) * @param content the data of the source * @return the new source */ public static LexerSource getSource(String name, InputStream content, List<String> list, ParserConfiguration configuration) { return new InputStreamLexerSource(name, content, list, configuration.getLineNumber(), configuration.hasExtraPositionInformation()); }
public static LexerSource getSource(String name, byte[] content, List<String> list, ParserConfiguration configuration) { return new ByteArrayLexerSource(name, content, list, configuration.getLineNumber(), configuration.hasExtraPositionInformation()); }
public static LexerSource getSource(String name, byte[] content, List<String> list, ParserConfiguration configuration) { return new ByteArrayLexerSource(name, content, list, configuration.getLineNumber(), configuration.hasExtraPositionInformation()); }
@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, 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, 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, InputStream content, DynamicScope blockScope, ParserConfiguration configuration) { if (content instanceof LoadServiceResourceInputStream) { return parse(file, ((LoadServiceResourceInputStream) content).getBytes(), blockScope, configuration); } else { RubyArray list = getLines(configuration, runtime, file); RubyIO io; if (content instanceof FileInputStream) { io = new RubyFile(runtime, file, ((FileInputStream) content).getChannel()); } else { io = RubyIO.newIO(runtime, Channels.newChannel(content)); } LexerSource lexerSource = new GetsLexerSource(file, configuration.getLineNumber(), io, list, configuration.getDefaultEncoding()); try { return parse(file, lexerSource, blockScope, configuration); } finally { // In case of GetsLexerSource we actually will dispatch to gets which will increment $. // We do not want that in the case of raw parsing. runtime.setCurrentLine(0); } } }
@SuppressWarnings("unchecked") public Node parse(String file, InputStream content, DynamicScope blockScope, ParserConfiguration configuration) { if (content instanceof LoadServiceResourceInputStream) { return parse(file, ((LoadServiceResourceInputStream) content).getBytes(), blockScope, configuration); } else { RubyArray list = getLines(configuration, runtime, file); RubyIO io; if (content instanceof FileInputStream) { io = new RubyFile(runtime, file, ((FileInputStream) content).getChannel()); } else { io = RubyIO.newIO(runtime, Channels.newChannel(content)); } LexerSource lexerSource = new GetsLexerSource(file, configuration.getLineNumber(), io, list, configuration.getDefaultEncoding()); try { return parse(file, lexerSource, blockScope, configuration); } finally { // In case of GetsLexerSource we actually will dispatch to gets which will increment $. // We do not want that in the case of raw parsing. runtime.setCurrentLine(0); } } }