Class ParserManager

java.lang.Object
org.jruby.parser.ParserManager

public class ParserManager extends Object
Front-end API to parsing Ruby source.

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

  • Field Details

    • PARSER_WASM

      public static final boolean PARSER_WASM
    • parserTiming

      public final boolean parserTiming
  • Constructor Details

    • ParserManager

      public ParserManager(Ruby runtime)
  • Method Details

    • getParser

      public Parser getParser()
    • parseEval

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

      public ParseResult parseEval(String fileName, int lineNumber, ByteList source, DynamicScope scope)
      Parameters:
      fileName - the potentially relative path file
      lineNumber - the zero-indexed line
      source - the source
      scope - scope of the eval
      Returns:
      the parsed Ruby
    • parseMainFile

      public ParseResult parseMainFile(String fileName, int lineNumber, InputStream in, org.jcodings.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 - the potentially relative path file
      lineNumber - the zero-indexed line
      in - the source
      encoding - the encoding to treat the source unless magic comments intervene
      scope - top-level binding in case of MAIN file (eval uses should call parseEval instead).
      type - whether this is eval, is -e, or should worry about DATA
      Returns:
      the parsed Ruby
    • parseFile

      public ParseResult parseFile(String fileName, int lineNumber, InputStream in, org.jcodings.Encoding encoding)
      Parse a (non-main) file. Other file parses should use parseFile. Evals should use parseEval.
      Parameters:
      fileName - the potentially relative path file
      lineNumber - the zero-indexed line
      in - the source
      encoding - the encoding to treat the source unless magic comments intervene
      Returns:
    • getParserStats

      public ParserStats getParserStats()
    • getLineStub

      public IRubyObject getLineStub(ThreadContext context, IRubyObject arg)
    • addGetsLoop

      public ParseResult addGetsLoop(Ruby runtime, ParseResult oldRoot, boolean printing, boolean processLineEndings, boolean split)