Top Description Fields Constructors Methods
org.jruby.parser

public Class ParserManager

extends Object
Class Inheritance
Imports
org.jcodings.Encoding, org.jruby.ParseResult, .Ruby, .RubyFile, .RubyInstanceConfig, .RubyString, org.jruby.ir.persistence.IRReader, .IRReaderStream, org.jruby.ir.persistence.util.IRFileExpert, org.jruby.management.ParserStats, org.jruby.platform.Platform, org.jruby.runtime.Block, .DynamicScope, .ThreadContext, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.load.LoadServiceResourceInputStream, org.jruby.util.ByteList, org.jruby.util.cli.Options, java.io.IOException, .InputStream, java.nio.charset.Charset

Front-end API to parsing Ruby source.

Notes

1. file parses can deserialize from IR but evals never do.

Field Summary

Modifier and TypeField and Description
private final Parser
public static final boolean
private final ParserStats
public final boolean
private final Ruby

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ParseResult
addGetsLoop(Ruby runtime, ParseResult oldRoot, boolean printing, boolean processLineEndings, boolean split)

private byte[]
private static String
public IRubyObject
public Parser
public ParserStats
private ParseResult
loadFileFromIRPersistence(String fileName, int lineNumber, InputStream in, Encoding encoding, DynamicScope scope, ParserType type)

public ParseResult

Returns:

the parsed Ruby
parseEval
(String
the potentially relative path file
fileName
,
int
the zero-indexed line
lineNumber
,
String
the source
source
,
DynamicScope
scope of the eval which for embedding can potentially be none
scope
)

public ParseResult

Returns:

the parsed Ruby
parseEval
(String
the potentially relative path file
fileName
,
int
the zero-indexed line
lineNumber
,
ByteList
the source
source
,
DynamicScope
scope of the eval
scope
)

public ParseResult
parseFile(String
the potentially relative path file
fileName
,
int
the zero-indexed line
lineNumber
,
InputStream
the source
in
,
Encoding
the encoding to treat the source unless magic comments intervene
encoding
)

Parse a (non-main) file.

public ParseResult

Returns:

the parsed Ruby
parseMainFile
(String
the potentially relative path file
fileName
,
int
the zero-indexed line
lineNumber
,
InputStream
the source
in
,
Encoding
the encoding to treat the source unless magic comments intervene
encoding
,
DynamicScope
top-level binding in case of MAIN file (eval uses should call parseEval instead).
scope
,
ParserType
whether this is eval, is -e, or should worry about DATA
type
)

Parse main file (-e or main script file).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

parserback to summary
private final Parser parser
PARSER_WASMback to summary
public static final boolean PARSER_WASM
parserStatsback to summary
private final ParserStats parserStats
parserTimingback to summary
public final boolean parserTiming
runtimeback to summary
private final Ruby runtime

Constructor Detail

ParserManagerback to summary
public ParserManager(Ruby runtime)

Method Detail

addGetsLoopback to summary
public ParseResult addGetsLoop(Ruby runtime, ParseResult oldRoot, boolean printing, boolean processLineEndings, boolean split)
encodeToBytesback to summary
private byte[] encodeToBytes(String string)
getLibraryExtensionback to summary
private static String getLibraryExtension()
getLineStubback to summary
public IRubyObject getLineStub(ThreadContext context, IRubyObject arg)
getParserback to summary
public Parser getParser()
getParserStatsback to summary
public ParserStats getParserStats()
loadFileFromIRPersistenceback to summary
private ParseResult loadFileFromIRPersistence(String fileName, int lineNumber, InputStream in, Encoding encoding, DynamicScope scope, ParserType type)
parseEvalback to summary
public ParseResult parseEval(String fileName, int lineNumber, String source, DynamicScope scope)
Parameters
fileName:String

the potentially relative path file

lineNumber:int

the zero-indexed line

source:String

the source

scope:DynamicScope

scope of the eval which for embedding can potentially be none

Returns:ParseResult

the parsed Ruby

parseEvalback to summary
public ParseResult parseEval(String fileName, int lineNumber, ByteList source, DynamicScope scope)
Parameters
fileName:String

the potentially relative path file

lineNumber:int

the zero-indexed line

source:ByteList

the source

scope:DynamicScope

scope of the eval

Returns:ParseResult

the parsed Ruby

parseFileback to summary
public ParseResult parseFile(String fileName, int lineNumber, InputStream in, Encoding encoding)

Parse a (non-main) file. Other file parses should use parseFile. Evals should use parseEval.

Parameters
fileName:String

the potentially relative path file

lineNumber:int

the zero-indexed line

in:InputStream

the source

encoding:Encoding

the encoding to treat the source unless magic comments intervene

parseMainFileback to summary
public ParseResult parseMainFile(String fileName, int lineNumber, InputStream in, Encoding encoding, DynamicScope scope, ParserType type)

Parse main file (-e or main script file). Other file parses should use parseFile. Evals should use parseEval.

Parameters
fileName:String

the potentially relative path file

lineNumber:int

the zero-indexed line

in:InputStream

the source

encoding:Encoding

the encoding to treat the source unless magic comments intervene

scope:DynamicScope

top-level binding in case of MAIN file (eval uses should call parseEval instead).

type:ParserType

whether this is eval, is -e, or should worry about DATA

Returns:ParseResult

the parsed Ruby