Class: Prism::Translation::Ripper::Lexer
| Relationships & Source Files | |
| Namespace Children | |
|
Classes:
| |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
|
|
|
Instance Chain:
|
|
| Inherits: |
Prism::Translation::Ripper
|
| Defined in: | lib/prism/translation/ripper/lexer.rb |
Constant Summary
::Prism::Translation::Ripper - Inherited
BINARY_OPERATORS, EVENTS, EXPR_ARG_ANY, EXPR_BEG_ANY, EXPR_END_ANY, EXPR_NONE, EXPR_VALUE, KEYWORDS, LEX_STATE_NAMES, PARSER_EVENTS, PARSER_EVENT_TABLE, SCANNER_EVENTS, SCANNER_EVENT_TABLE
Class Method Summary
::Prism::Translation::Ripper - Inherited
| .lex | Tokenizes the Ruby program and returns an array of an array, which is formatted like |
| .new | Create a new |
| .parse | Parses the given Ruby program read from |
| .sexp | Parses |
| .sexp_raw | Parses |
| .tokenize | Tokenizes the Ruby program and returns an array of strings. |
| .lex_state_name | |
Instance Attribute Summary
::Prism::Translation::Ripper - Inherited
Instance Method Summary
-
#lex(raise_errors: false)
Pretty much just the same as Prism.lex_compat.
-
#parse
Returns the lex_compat result wrapped in
Elem. -
#scan
Similar to parse but ripper sorts the elements by position in the source.
::Prism::Translation::Ripper - Inherited
| #parse | Parse the source and return the result. |
| #visit_alias_global_variable_node | alias $foo $bar ^^^^^^^^^^^^^^^. |
| #visit_alias_method_node | alias foo bar ^^^^^^^^^^^^^. |
| #visit_alternation_pattern_node | foo => bar | baz. |
| #visit_and_node | a and b ^^^^^^^. |
| #visit_arguments_node | foo(bar). |
| #visit_array_node |
|
| #visit_array_pattern_node | foo => [bar]. |
| #visit_assoc_node | { a: 1 } |
| #visit_assoc_splat_node | def foo(**); bar(**); end. |
| #visit_back_reference_read_node | $+ ^^. |
| #visit_begin_node | begin end ^^^^^^^^^. |
| #visit_block_argument_node | foo(&bar). |
| #visit_block_local_variable_node | foo { |; bar| } |
| #visit_block_node | Visit a |
| #visit_block_parameter_node | def foo(&bar); end. |
| #visit_block_parameters_node | A block’s parameters. |
| #visit_break_node | break ^^^^^. |
| #visit_call_and_write_node | foo.bar &&= baz ^^^^^^^^^^^^^^^. |
| #visit_call_node | foo ^^^. |
| #visit_call_operator_write_node | foo.bar += baz ^^^^^^^^^^^^^^^. |
| #visit_call_or_write_node | foo.bar ||= baz ^^^^^^^^^^^^^^^. |
| #visit_call_target_node | foo.bar, = 1 ^^^^^^^. |
| #visit_capture_pattern_node | foo => bar => baz. |
| #visit_case_match_node | case foo; in bar; end ^^^^^^^^^^^^^^^^^^^^^. |
| #visit_case_node | case foo; when bar; end ^^^^^^^^^^^^^^^^^^^^^^^. |
| #visit_class_node | class Foo; end ^^^^^^^^^^^^^^. |
| #visit_class_variable_and_write_node | @@foo &&= bar ^^^^^^^^^^^^^. |
| #visit_class_variable_operator_write_node | @@foo += bar ^^^^^^^^^^^^. |
| #visit_class_variable_or_write_node | @@foo ||= bar ^^^^^^^^^^^^^. |
| #visit_class_variable_read_node | @@foo ^^^^^. |
| #visit_class_variable_target_node | @@foo, = bar ^^^^^. |
| #visit_class_variable_write_node | @@foo = 1 ^^^^^^^^^. |
| #visit_constant_and_write_node | Foo &&= bar ^^^^^^^^^^^^. |
| #visit_constant_operator_write_node | Foo += bar ^^^^^^^^^^^. |
| #visit_constant_or_write_node | Foo ||= bar ^^^^^^^^^^^^. |
| #visit_constant_path_and_write_node |
|
| #visit_constant_path_node |
|
| #visit_constant_path_operator_write_node |
|
| #visit_constant_path_or_write_node |
|
| #visit_constant_path_target_node |
|
| #visit_constant_path_write_node |
|
| #visit_constant_read_node | Foo ^^^. |
| #visit_constant_target_node | Foo, = bar ^^^. |
| #visit_constant_write_node | Foo = 1 ^^^^^^^. |
| #visit_def_node | def foo; end ^^^^^^^^^^^^. |
| #visit_defined_node | defined? a ^^^^^^^^^^. |
| #visit_else_node | if foo then bar else baz end. |
| #visit_embedded_statements_node | “foo # |
| #visit_embedded_variable_node | “foo |
| #visit_ensure_node | Visit an |
| #visit_false_node | false ^^^^^. |
| #visit_find_pattern_node | foo => [*, bar, *]. |
| #visit_flip_flop_node | if foo .. |
| #visit_float_node | 1.0 ^^^. |
| #visit_for_node | for foo in bar do end ^^^^^^^^^^^^^^^^^^^^^. |
| #visit_forwarding_arguments_node | def foo(…); bar(…); end. |
| #visit_forwarding_parameter_node | def foo(…); end. |
| #visit_forwarding_super_node | super ^^^^^. |
| #visit_global_variable_and_write_node | $foo &&= bar ^^^^^^^^^^^^. |
| #visit_global_variable_operator_write_node | $foo += bar ^^^^^^^^^^^. |
| #visit_global_variable_or_write_node | $foo ||= bar ^^^^^^^^^^^^. |
| #visit_global_variable_read_node | $foo ^^^^. |
| #visit_global_variable_target_node | $foo, = bar ^^^^. |
| #visit_global_variable_write_node | $foo = 1 ^^^^^^^^. |
| #visit_hash_node | {} ^^. |
| #visit_hash_pattern_node | foo => {} |
| #visit_if_node | if foo then bar end ^^^^^^^^^^^^^^^^^^^. |
| #visit_imaginary_node | 1i ^^. |
| #visit_implicit_node | { foo: } |
| #visit_implicit_rest_node | foo { |bar,| } |
| #visit_in_node | case foo; in bar; end ^^^^^^^^^^^^^^^^^^^^^. |
| #visit_index_and_write_node | foo &&= baz ^^^^^^^^^^^^^^^^. |
| #visit_index_operator_write_node | foo += baz ^^^^^^^^^^^^^^^. |
| #visit_index_or_write_node | foo ||= baz ^^^^^^^^^^^^^^^^. |
| #visit_index_target_node | foo, = 1 ^^^^^^^^. |
| #visit_instance_variable_and_write_node | ^^^^^^^^^^^^. |
| #visit_instance_variable_operator_write_node | ^^^^^^^^^^^. |
| #visit_instance_variable_or_write_node | ^^^^^^^^^^^^. |
| #visit_instance_variable_read_node | ^^^^. |
| #visit_instance_variable_target_node | @foo, = bar ^^^^. |
| #visit_instance_variable_write_node | ^^^^^^^^. |
| #visit_integer_node | 1 ^. |
| #visit_interpolated_match_last_line_node | if /foo # |
| #visit_interpolated_regular_expression_node | /foo # |
| #visit_interpolated_string_node | “foo # |
| #visit_interpolated_symbol_node | :“foo # |
| #visit_interpolated_x_string_node |
|
| #visit_it_local_variable_read_node | -> { it } |
| #visit_it_parameters_node | -> { it } ^^^^^^^^^. |
| #visit_keyword_hash_node | foo(bar: baz). |
| #visit_keyword_rest_parameter_node | def foo(**bar); end. |
| #visit_lambda_node | -> {} |
| #visit_local_variable_and_write_node | foo &&= bar ^^^^^^^^^^^. |
| #visit_local_variable_operator_write_node | foo += bar ^^^^^^^^^^. |
| #visit_local_variable_or_write_node | foo ||= bar ^^^^^^^^^^^. |
| #visit_local_variable_read_node | foo ^^^. |
| #visit_local_variable_target_node | foo, = bar ^^^. |
| #visit_local_variable_write_node | foo = 1 ^^^^^^^. |
| #visit_match_last_line_node | if /foo/ then end. |
| #visit_match_predicate_node | foo in bar ^^^^^^^^^^. |
| #visit_match_required_node | foo => bar ^^^^^^^^^^. |
| #visit_match_write_node | /(?<foo>foo)/ =~ bar ^^^^^^^^^^^^^^^^^^^^. |
| #visit_missing_node | A node that is missing from the syntax tree. |
| #visit_module_node | module Foo; end ^^^^^^^^^^^^^^^. |
| #visit_multi_target_node | (foo, bar), bar = qux ^^^^^^^^^^. |
| #visit_multi_write_node | foo, bar = baz ^^^^^^^^^^^^^^. |
| #visit_next_node | next ^^^^. |
| #visit_nil_node | nil ^^^. |
| #visit_no_keywords_parameter_node | def foo(**nil); end. |
| #visit_numbered_parameters_node | -> { _1 + _2 } ^^^^^^^^^^^^^^. |
| #visit_numbered_reference_read_node | $1 ^^. |
| #visit_optional_keyword_parameter_node | def foo(bar: baz); end. |
| #visit_optional_parameter_node | def foo(bar = 1); end. |
| #visit_or_node | a or b ^^^^^^. |
| #visit_parameters_node | def foo(bar, *baz); end. |
| #visit_parentheses_node | () ^^. |
| #visit_pinned_expression_node | foo => ^(bar). |
| #visit_pinned_variable_node | foo = 1 and bar => ^foo. |
| #visit_post_execution_node | END {} ^^^^^^. |
| #visit_pre_execution_node | BEGIN {} ^^^^^^^^. |
| #visit_program_node | The top-level program node. |
| #visit_range_node | 0..5 ^^^^. |
| #visit_rational_node | 1r ^^. |
| #visit_redo_node | redo ^^^^. |
| #visit_regular_expression_node | /foo/ ^^^^^. |
| #visit_required_keyword_parameter_node | def foo(bar:); end. |
| #visit_required_parameter_node | def foo(bar); end. |
| #visit_rescue_modifier_node | foo rescue bar ^^^^^^^^^^^^^^. |
| #visit_rescue_node | begin; rescue; end. |
| #visit_rest_parameter_node | def foo(*bar); end. |
| #visit_retry_node | retry ^^^^^. |
| #visit_return_node | return ^^^^^^. |
| #visit_self_node | self ^^^^. |
| #visit_shareable_constant_node | A shareable constant. |
| #visit_singleton_class_node | class << self; end ^^^^^^^^^^^^^^^^^^. |
| #visit_source_encoding_node | __ENCODING__ ^^^^^^^^^^^^. |
| #visit_source_file_node | __FILE__ ^^^^^^^^. |
| #visit_source_line_node | __LINE__ ^^^^^^^^. |
| #visit_splat_node | foo(*bar). |
| #visit_statements_node | A list of statements. |
| #visit_string_node | “foo” ^^^^^. |
| #visit_super_node | super(foo) ^^^^^^^^^^. |
| #visit_symbol_node |
|
| #visit_true_node | true ^^^^. |
| #visit_undef_node | undef foo ^^^^^^^^^. |
| #visit_unless_node | unless foo; bar end ^^^^^^^^^^^^^^^^^^^. |
| #visit_until_node | until foo; bar end ^^^^^^^^^^^^^^^^^. |
| #visit_when_node | case foo; when bar; end. |
| #visit_while_node | while foo; bar end ^^^^^^^^^^^^^^^^^^. |
| #visit_x_string_node |
|
| #visit_yield_node | yield ^^^^^. |
| #bounds | This method is responsible for updating lineno and column information to reflect the current node. |
| #command? | Returns true if the given node is a command node. |
| #compile_error | This method is called when the parser found syntax error. |
| #dedent_string | This method is provided by the |
| #get_arguments_and_block | Extract the arguments and block Ripper-style, which means if the block is like |
| #result | Lazily initialize the parse result. |
| #trailing_comma? | Returns true if there is a comma between the two locations. |
| #visit_alias_global_variable_node_value | Visit one side of an alias global variable node. |
| #visit_arguments | Visit a list of elements, like the elements of an array or arguments. |
| #visit_begin_node_clauses | Visit the clauses of a begin node to form an on_bodystmt call. |
| #visit_body_node | Visit the body of a structure that can have either a set of statements or statements wrapped in rescue/else/ensure. |
| #visit_call_node_arguments | Visit the arguments and block of a call node and return the arguments and block as they should be used. |
| #visit_constant_path_write_node_target | Visit a constant path that is part of a write node. |
| #visit_destructured_parameter_node | Visit a destructured positional parameter node. |
| #visit_heredoc_node | Visit a string that is expressed using a <<~ heredoc. |
| #visit_heredoc_node_whitespace |
|
| #visit_heredoc_string_node | Visit a heredoc node that is representing a string. |
| #visit_heredoc_x_string_node | Visit a heredoc node that is representing an xstring. |
| #visit_multi_target_node_targets | Visit the targets of a multi-target node. |
| #visit_number_node | Visit a node that represents a number. |
| #visit_pattern_node | Visit a pattern within a pattern match. |
| #visit_statements_node_body | Visit the list of statements of a statements node. |
| #visit_string_content | Visit an individual part of a string-like node. |
| #visit_token | Visit the string content of a particular node. |
| #visit_words_sep | Dispatch a words_sep event that contains the space between the elements of list literals. |
| #visit_write_value | Visit a node that represents a write value. |
| #void_stmt? | Returns true if there is a semicolon between the two locations. |
| #warn | This method is called when weak warning is produced by the parser. |
| #warning | This method is called when strong warning is produced by the parser. |
| #_dispatch_0, #_dispatch_1, #_dispatch_2, #_dispatch_3, #_dispatch_4, #_dispatch_5, #_dispatch_7 | |
::Prism::Compiler - Inherited
::Prism::Visitor - Inherited
::Prism::BasicVisitor - Inherited
| #visit | Calls |
| #visit_all | Visits each node in |
| #visit_child_nodes | Visits the child nodes of |
Constructor Details
This class inherits a constructor from Prism::Translation::Ripper
Instance Method Details
#lex(raise_errors: false)
Pretty much just the same as Prism.lex_compat.
#parse
Returns the lex_compat result wrapped in Lexer::Elem. Errors are omitted. Since ripper is a streaming parser, tokens are expected to be emitted in the order that the parser encounters them. This is not implemented.
#scan
Similar to parse but ripper sorts the elements by position in the source. Also includes errors. Since prism does error recovery, in cases of syntax errors the result may differ greatly compared to ripper.
# File 'lib/prism/translation/ripper/lexer.rb', line 127
def scan(...) parse(...) end