Class: Parser::Base
- Defined in:
 - sorbet/rbi/parser@3.3.8.0.rbi
 
Overview
Base class for version-specific parsers.
source://parser//lib/parser/base.rb#19
Direct Known Subclasses
Class Method Summary collapse
- 
  
    
      .default_parser  ⇒ Parser::Base 
    
    
  
  
  
  
  
  
  
  
  
    
source://parser//lib/parser/base.rb#87.
 - 
  
    
      .parse(string, file = T.unsafe(nil), line = T.unsafe(nil))  ⇒ Parser::AST::Node 
    
    
  
  
  
  
  
  
  
  
  
    
Parses a string of Ruby code and returns the AST.
 - 
  
    
      .parse_file(filename)  ⇒ Parser::AST::Node 
    
    
  
  
  
  
  
  
  
  
  
    
Parses Ruby source code by reading it from a file.
 - 
  
    
      .parse_file_with_comments(filename)  ⇒ Array 
    
    
  
  
  
  
  
  
  
  
  
    
Parses Ruby source code by reading it from a file and returns the AST and comments.
 - 
  
    
      .parse_with_comments(string, file = T.unsafe(nil), line = T.unsafe(nil))  ⇒ Array 
    
    
  
  
  
  
  
  
  
  
  
    
Parses a string of Ruby code and returns the AST and comments.
 
Instance Method Summary collapse
- 
  
    
      #builder  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
source://parser//lib/parser/base.rb#117.
 - 
  
    
      #context  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
source://parser//lib/parser/base.rb#120.
 - 
  
    
      #current_arg_stack  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
source://parser//lib/parser/base.rb#122.
 - 
  
    
      #diagnostics  ⇒ Parser::Diagnostic::Engine 
    
    
  
  
  
  
  
  
  
  
  
    
source://parser//lib/parser/base.rb#116.
 - 
  
    
      #initialize(builder = T.unsafe(nil))  ⇒ Base 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
source://parser//lib/parser/base.rb#129.
 - 
  
    
      #lexer  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
source://parser//lib/parser/base.rb#115.
 - 
  
    
      #max_numparam_stack  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
source://parser//lib/parser/base.rb#121.
 - 
  
    
      #parse(source_buffer)  ⇒ Parser::AST::Node? 
    
    
  
  
  
  
  
  
  
  
  
    
Parses a source buffer and returns the AST, or
nilin case of a non fatal error. - 
  
    
      #parse_with_comments(source_buffer)  ⇒ Array 
    
    
  
  
  
  
  
  
  
  
  
    
Parses a source buffer and returns the AST and the source code comments.
 - 
  
    
      #pattern_hash_keys  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
source://parser//lib/parser/base.rb#124.
 - 
  
    
      #pattern_variables  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
source://parser//lib/parser/base.rb#123.
 - 
  
    
      #reset  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Resets the state of the parser.
 - 
  
    
      #source_buffer  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
source://parser//lib/parser/base.rb#119.
 - 
  
    
      #static_env  ⇒ Parser::StaticEnvironment 
    
    
  
  
  
  
  
  
  
  
  
    
source://parser//lib/parser/base.rb#118.
 - 
  
    
      #tokenize(source_buffer, recover = T.unsafe(nil))  ⇒ Array 
    
    
  
  
  
  
  
  
  
  
  
    
Parses a source buffer and returns the AST, the source code comments, and the tokens emitted by the lexer.
 
Constructor Details
#initialize(builder = T.unsafe(nil)) ⇒ Base
source://parser//lib/parser/base.rb#129
      676  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 676 def initialize(builder = T.unsafe(nil)); end  | 
  
Class Method Details
.default_parser ⇒ Parser::Base
source://parser//lib/parser/base.rb#87
      807  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 807 def default_parser; end  | 
  
.parse(string, file = T.unsafe(nil), line = T.unsafe(nil)) ⇒ Parser::AST::Node
Parses a string of Ruby code and returns the AST. If the source
cannot be parsed, SyntaxError is raised and a diagnostic is
printed to stderr.
source://parser//lib/parser/base.rb#33
      822  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 822 def parse(string, file = T.unsafe(nil), line = T.unsafe(nil)); end  | 
  
.parse_file(filename) ⇒ Parser::AST::Node
Parses Ruby source code by reading it from a file. If the source
cannot be parsed, SyntaxError is raised and a diagnostic is
printed to stderr.
source://parser//lib/parser/base.rb#67
      834  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 834 def parse_file(filename); end  | 
  
.parse_file_with_comments(filename) ⇒ Array
Parses Ruby source code by reading it from a file and returns the AST and
comments. If the source cannot be parsed, SyntaxError is raised and a
diagnostic is printed to stderr.
source://parser//lib/parser/base.rb#80
      846  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 846 def parse_file_with_comments(filename); end  | 
  
.parse_with_comments(string, file = T.unsafe(nil), line = T.unsafe(nil)) ⇒ Array
Parses a string of Ruby code and returns the AST and comments. If the
source cannot be parsed, SyntaxError is raised and a diagnostic is
printed to stderr.
source://parser//lib/parser/base.rb#52
      861  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 861 def parse_with_comments(string, file = T.unsafe(nil), line = T.unsafe(nil)); end  | 
  
Instance Method Details
#builder ⇒ Object
source://parser//lib/parser/base.rb#117
      681  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 681 def builder; end  | 
  
#context ⇒ Object
source://parser//lib/parser/base.rb#120
      686  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 686 def context; end  | 
  
#current_arg_stack ⇒ Object
source://parser//lib/parser/base.rb#122
      691  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 691 def current_arg_stack; end  | 
  
#diagnostics ⇒ Parser::Diagnostic::Engine
source://parser//lib/parser/base.rb#116
      697  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 697 def diagnostics; end  | 
  
#lexer ⇒ Object
source://parser//lib/parser/base.rb#115
      702  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 702 def lexer; end  | 
  
#max_numparam_stack ⇒ Object
source://parser//lib/parser/base.rb#121
      707  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 707 def max_numparam_stack; end  | 
  
#parse(source_buffer) ⇒ Parser::AST::Node?
Parses a source buffer and returns the AST, or nil in case of a non fatal error.
source://parser//lib/parser/base.rb#189
      716  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 716 def parse(source_buffer); end  | 
  
#parse_with_comments(source_buffer) ⇒ Array
Parses a source buffer and returns the AST and the source code comments.
source://parser//lib/parser/base.rb#207
      726  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 726 def parse_with_comments(source_buffer); end  | 
  
#pattern_hash_keys ⇒ Object
source://parser//lib/parser/base.rb#124
      731  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 731 def pattern_hash_keys; end  | 
  
#pattern_variables ⇒ Object
source://parser//lib/parser/base.rb#123
      736  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 736 def pattern_variables; end  | 
  
#reset ⇒ Object
Resets the state of the parser.
source://parser//lib/parser/base.rb#170
      743  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 743 def reset; end  | 
  
#source_buffer ⇒ Object
source://parser//lib/parser/base.rb#119
      748  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 748 def source_buffer; end  | 
  
#static_env ⇒ Parser::StaticEnvironment
source://parser//lib/parser/base.rb#118
      754  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 754 def static_env; end  | 
  
#tokenize(source_buffer, recover = T.unsafe(nil)) ⇒ Array
Parses a source buffer and returns the AST, the source code comments,
and the tokens emitted by the lexer. In case of a fatal error, a SyntaxError
is raised, unless recover is true. In case of an error
(non-fatal or recovered), nil is returned instead of the AST, and
comments as well as tokens are only returned up to the location of
the error.
Currently, token stream format returned by #tokenize is not documented, but is considered part of a public API and only changed according to Semantic Versioning.
However, note that the exact token composition of various constructs
might vary. For example, a string "foo" is represented equally well
by :tSTRING_BEG " :tSTRING_CONTENT foo :tSTRING_END " and
:tSTRING "foo"; such details must not be relied upon.
source://parser//lib/parser/base.rb#236
      778  | 
    
      # File 'sorbet/rbi/parser@3.3.8.0.rbi', line 778 def tokenize(source_buffer, recover = T.unsafe(nil)); end  |