Class: Prism::ParseResult
| Relationships & Source Files | |
| Namespace Children | |
|
Classes:
| |
| Inherits: | Object |
| Defined in: | lib/prism/parse_result.rb, lib/prism/parse_result/comments.rb, lib/prism/parse_result/newlines.rb, prism/extension.c |
Overview
This represents the result of a call to parse or parse_file. It contains the AST, any comments that were encounters, and any errors that were encountered.
Class Method Summary
-
.new(value, comments, magic_comments, data_loc, errors, warnings, source) ⇒ ParseResult
constructor
Create a new parse result object with the given values.
Instance Attribute Summary
-
#comments
readonly
The list of comments that were encountered during parsing.
-
#data_loc
readonly
An optional location that represents the location of the content after the END marker.
-
#errors
readonly
The list of errors that were generated during parsing.
-
#failure? ⇒ Boolean
readonly
Returns true if there were errors during parsing and false if there were not.
-
#magic_comments
readonly
The list of magic comments that were encountered during parsing.
-
#source
readonly
A Source instance that represents the source code that was parsed.
-
#success? ⇒ Boolean
readonly
Returns true if there were no errors during parsing and false if there were.
-
#value
readonly
The value that was generated by parsing.
-
#warnings
readonly
The list of warnings that were generated during parsing.
Instance Method Summary
-
#attach_comments!
Attach the list of comments to their respective locations in the tree.
-
#deconstruct_keys(keys)
Implement the hash pattern matching interface for
ParseResult. -
#mark_newlines!
Walk the tree and mark nodes that are on a new line.
Constructor Details
.new(value, comments, magic_comments, data_loc, errors, warnings, source) ⇒ ParseResult
Create a new parse result object with the given values.
Instance Attribute Details
#comments (readonly)
The list of comments that were encountered during parsing.
# File 'lib/prism/parse_result.rb', line 367
attr_reader :comments
#data_loc (readonly)
An optional location that represents the location of the content after the END marker. This content is loaded into the DATA constant when the file being parsed is the main file being executed.
# File 'lib/prism/parse_result.rb', line 375
attr_reader :data_loc
#errors (readonly)
The list of errors that were generated during parsing.
# File 'lib/prism/parse_result.rb', line 378
attr_reader :errors
#failure? ⇒ Boolean (readonly)
Returns true if there were errors during parsing and false if there were not.
# File 'lib/prism/parse_result.rb', line 410
def failure? !success? end
#magic_comments (readonly)
The list of magic comments that were encountered during parsing.
# File 'lib/prism/parse_result.rb', line 370
attr_reader :magic_comments
#source (readonly)
A Source instance that represents the source code that was parsed.
# File 'lib/prism/parse_result.rb', line 384
attr_reader :source
#success? ⇒ Boolean (readonly)
Returns true if there were no errors during parsing and false if there were.
# File 'lib/prism/parse_result.rb', line 404
def success? errors.empty? end
#value (readonly)
The value that was generated by parsing. Normally this holds the AST, but it can sometimes how a list of tokens or other results passed back from the parser.
# File 'lib/prism/parse_result.rb', line 364
attr_reader :value
#warnings (readonly)
The list of warnings that were generated during parsing.
# File 'lib/prism/parse_result.rb', line 381
attr_reader :warnings
Instance Method Details
#attach_comments!
Attach the list of comments to their respective locations in the tree.
#deconstruct_keys(keys)
Implement the hash pattern matching interface for ParseResult.
#mark_newlines!
Walk the tree and mark nodes that are on a new line.