2024-03-06 21:18:55 +03:00
errors :
- ALIAS_ARGUMENT
2024-04-01 21:36:38 +03:00
- ALIAS_ARGUMENT_NUMBERED_REFERENCE
2024-03-06 21:18:55 +03:00
- AMPAMPEQ_MULTI_ASSIGN
- ARGUMENT_AFTER_BLOCK
- ARGUMENT_AFTER_FORWARDING_ELLIPSES
- ARGUMENT_BARE_HASH
- ARGUMENT_BLOCK_FORWARDING
- ARGUMENT_BLOCK_MULTI
2024-05-06 18:01:50 +03:00
- ARGUMENT_CONFLICT_AMPERSAND
- ARGUMENT_CONFLICT_STAR
- ARGUMENT_CONFLICT_STAR_STAR
2024-03-06 21:18:55 +03:00
- ARGUMENT_FORMAL_CLASS
- ARGUMENT_FORMAL_CONSTANT
- ARGUMENT_FORMAL_GLOBAL
- ARGUMENT_FORMAL_IVAR
- ARGUMENT_FORWARDING_UNBOUND
2024-05-06 18:01:50 +03:00
- ARGUMENT_NO_FORWARDING_AMPERSAND
2024-03-06 21:18:55 +03:00
- ARGUMENT_NO_FORWARDING_ELLIPSES
- ARGUMENT_NO_FORWARDING_STAR
2024-03-19 07:06:19 +03:00
- ARGUMENT_NO_FORWARDING_STAR_STAR
2024-03-06 21:18:55 +03:00
- ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT
- ARGUMENT_SPLAT_AFTER_SPLAT
- ARGUMENT_TERM_PAREN
- ARGUMENT_UNEXPECTED_BLOCK
- ARRAY_ELEMENT
- ARRAY_EXPRESSION
- ARRAY_EXPRESSION_AFTER_STAR
- ARRAY_SEPARATOR
- ARRAY_TERM
- BEGIN_LONELY_ELSE
- BEGIN_TERM
- BEGIN_UPCASE_BRACE
- BEGIN_UPCASE_TERM
- BEGIN_UPCASE_TOPLEVEL
- BLOCK_PARAM_LOCAL_VARIABLE
- BLOCK_PARAM_PIPE_TERM
- BLOCK_TERM_BRACE
- BLOCK_TERM_END
2024-02-16 05:27:46 +03:00
- CANNOT_PARSE_EXPRESSION
2024-03-06 21:18:55 +03:00
- CANNOT_PARSE_STRING_PART
- CASE_EXPRESSION_AFTER_CASE
- CASE_EXPRESSION_AFTER_WHEN
- CASE_MATCH_MISSING_PREDICATE
- CASE_MISSING_CONDITIONS
- CASE_TERM
- CLASS_IN_METHOD
- CLASS_NAME
- CLASS_SUPERCLASS
- CLASS_TERM
- CLASS_UNEXPECTED_END
2024-04-01 21:59:41 +03:00
- CLASS_VARIABLE_BARE
2024-03-06 21:18:55 +03:00
- CONDITIONAL_ELSIF_PREDICATE
- CONDITIONAL_IF_PREDICATE
- CONDITIONAL_PREDICATE_TERM
- CONDITIONAL_TERM
- CONDITIONAL_TERM_ELSE
- CONDITIONAL_UNLESS_PREDICATE
- CONDITIONAL_UNTIL_PREDICATE
- CONDITIONAL_WHILE_PREDICATE
- CONSTANT_PATH_COLON_COLON_CONSTANT
- DEF_ENDLESS
- DEF_ENDLESS_SETTER
- DEF_NAME
- DEF_PARAMS_TERM
- DEF_PARAMS_TERM_PAREN
- DEF_RECEIVER
- DEF_RECEIVER_TERM
- DEF_TERM
- DEFINED_EXPRESSION
- EMBDOC_TERM
- EMBEXPR_END
- EMBVAR_INVALID
- END_UPCASE_BRACE
- END_UPCASE_TERM
- ESCAPE_INVALID_CONTROL
- ESCAPE_INVALID_CONTROL_REPEAT
- ESCAPE_INVALID_HEXADECIMAL
- ESCAPE_INVALID_META
- ESCAPE_INVALID_META_REPEAT
- ESCAPE_INVALID_UNICODE
- ESCAPE_INVALID_UNICODE_CM_FLAGS
2024-08-23 22:03:39 +03:00
- ESCAPE_INVALID_UNICODE_LIST
2024-03-06 21:18:55 +03:00
- ESCAPE_INVALID_UNICODE_LITERAL
- ESCAPE_INVALID_UNICODE_LONG
2024-08-15 19:24:49 +03:00
- ESCAPE_INVALID_UNICODE_SHORT
2024-03-06 21:18:55 +03:00
- ESCAPE_INVALID_UNICODE_TERM
- EXPECT_ARGUMENT
- EXPECT_EOL_AFTER_STATEMENT
- EXPECT_EXPRESSION_AFTER_AMPAMPEQ
- EXPECT_EXPRESSION_AFTER_COMMA
- EXPECT_EXPRESSION_AFTER_EQUAL
- EXPECT_EXPRESSION_AFTER_LESS_LESS
- EXPECT_EXPRESSION_AFTER_LPAREN
- EXPECT_EXPRESSION_AFTER_OPERATOR
2024-02-16 05:27:46 +03:00
- EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ
- EXPECT_EXPRESSION_AFTER_QUESTION
2024-03-06 21:18:55 +03:00
- EXPECT_EXPRESSION_AFTER_SPLAT
- EXPECT_EXPRESSION_AFTER_SPLAT_HASH
- EXPECT_EXPRESSION_AFTER_STAR
2024-09-30 17:51:01 +03:00
- EXPECT_FOR_DELIMITER
2024-03-06 21:18:55 +03:00
- EXPECT_IDENT_REQ_PARAMETER
2024-05-07 20:02:25 +03:00
- EXPECT_IN_DELIMITER
2024-03-06 21:18:55 +03:00
- EXPECT_LPAREN_REQ_PARAMETER
2024-04-12 20:43:30 +03:00
- EXPECT_MESSAGE
2024-03-06 21:18:55 +03:00
- EXPECT_RBRACKET
- EXPECT_RPAREN
- EXPECT_RPAREN_AFTER_MULTI
- EXPECT_RPAREN_REQ_PARAMETER
2024-09-30 17:15:21 +03:00
- EXPECT_SINGLETON_CLASS_DELIMITER
2024-03-06 21:18:55 +03:00
- EXPECT_STRING_CONTENT
- EXPECT_WHEN_DELIMITER
- EXPRESSION_BARE_HASH
2024-04-13 03:16:07 +03:00
- EXPRESSION_NOT_WRITABLE
- EXPRESSION_NOT_WRITABLE_ENCODING
- EXPRESSION_NOT_WRITABLE_FALSE
- EXPRESSION_NOT_WRITABLE_FILE
- EXPRESSION_NOT_WRITABLE_LINE
- EXPRESSION_NOT_WRITABLE_NIL
2024-05-21 16:55:31 +03:00
- EXPRESSION_NOT_WRITABLE_NUMBERED
2024-04-13 03:16:07 +03:00
- EXPRESSION_NOT_WRITABLE_SELF
- EXPRESSION_NOT_WRITABLE_TRUE
2024-03-06 21:18:55 +03:00
- FLOAT_PARSE
- FOR_COLLECTION
- FOR_IN
- FOR_INDEX
- FOR_TERM
2024-04-01 22:03:41 +03:00
- GLOBAL_VARIABLE_BARE
2024-03-06 21:18:55 +03:00
- HASH_EXPRESSION_AFTER_LABEL
- HASH_KEY
- HASH_ROCKET
- HASH_TERM
- HASH_VALUE
2024-05-02 00:49:41 +03:00
- HEREDOC_IDENTIFIER
2024-03-06 21:18:55 +03:00
- HEREDOC_TERM
- INCOMPLETE_QUESTION_MARK
- INCOMPLETE_VARIABLE_CLASS
2024-05-02 01:54:05 +03:00
- INCOMPLETE_VARIABLE_CLASS_3_3
2024-03-06 21:18:55 +03:00
- INCOMPLETE_VARIABLE_INSTANCE
2024-05-02 01:54:05 +03:00
- INCOMPLETE_VARIABLE_INSTANCE_3_3
2024-04-01 21:59:41 +03:00
- INSTANCE_VARIABLE_BARE
2024-04-02 18:02:59 +03:00
- INVALID_BLOCK_EXIT
2024-02-16 05:27:46 +03:00
- INVALID_CHARACTER
2024-10-07 19:27:52 +03:00
- INVALID_COMMA
2024-03-06 21:18:55 +03:00
- INVALID_ENCODING_MAGIC_COMMENT
2024-05-08 19:27:47 +03:00
- INVALID_ESCAPE_CHARACTER
2024-03-06 21:18:55 +03:00
- INVALID_FLOAT_EXPONENT
2024-04-19 21:15:14 +03:00
- INVALID_LOCAL_VARIABLE_READ
- INVALID_LOCAL_VARIABLE_WRITE
2024-02-16 05:27:46 +03:00
- INVALID_MULTIBYTE_CHAR
- INVALID_MULTIBYTE_CHARACTER
- INVALID_MULTIBYTE_ESCAPE
2024-03-06 21:18:55 +03:00
- INVALID_NUMBER_BINARY
- INVALID_NUMBER_DECIMAL
2024-05-06 18:21:28 +03:00
- INVALID_NUMBER_FRACTION
2024-03-06 21:18:55 +03:00
- INVALID_NUMBER_HEXADECIMAL
- INVALID_NUMBER_OCTAL
2024-05-01 22:40:27 +03:00
- INVALID_NUMBER_UNDERSCORE_INNER
- INVALID_NUMBER_UNDERSCORE_TRAILING
2024-03-06 21:18:55 +03:00
- INVALID_PERCENT
2024-05-16 17:38:16 +03:00
- INVALID_PERCENT_EOF
2024-02-16 05:27:46 +03:00
- INVALID_PRINTABLE_CHARACTER
2024-04-02 18:11:06 +03:00
- INVALID_RETRY_AFTER_ELSE
- INVALID_RETRY_AFTER_ENSURE
- INVALID_RETRY_WITHOUT_RESCUE
2024-05-01 19:35:28 +03:00
- INVALID_SYMBOL
2024-04-02 19:19:39 +03:00
- INVALID_VARIABLE_GLOBAL
2024-05-02 01:54:05 +03:00
- INVALID_VARIABLE_GLOBAL_3_3
2024-04-02 19:19:39 +03:00
- INVALID_YIELD
2024-03-06 21:18:55 +03:00
- IT_NOT_ALLOWED_NUMBERED
- IT_NOT_ALLOWED_ORDINARY
- LAMBDA_OPEN
- LAMBDA_TERM_BRACE
- LAMBDA_TERM_END
- LIST_I_LOWER_ELEMENT
- LIST_I_LOWER_TERM
- LIST_I_UPPER_ELEMENT
- LIST_I_UPPER_TERM
- LIST_W_LOWER_ELEMENT
- LIST_W_LOWER_TERM
- LIST_W_UPPER_ELEMENT
- LIST_W_UPPER_TERM
- MALLOC_FAILED
- MIXED_ENCODING
- MODULE_IN_METHOD
- MODULE_NAME
- MODULE_TERM
- MULTI_ASSIGN_MULTI_SPLATS
- MULTI_ASSIGN_UNEXPECTED_REST
2024-09-24 19:52:39 +03:00
- NESTING_TOO_DEEP
2024-03-06 21:18:55 +03:00
- NO_LOCAL_VARIABLE
2024-09-26 17:28:35 +03:00
- NON_ASSOCIATIVE_OPERATOR
2024-02-16 05:27:46 +03:00
- NOT_EXPRESSION
2024-03-06 21:18:55 +03:00
- NUMBER_LITERAL_UNDERSCORE
2024-05-21 16:55:31 +03:00
- NUMBERED_PARAMETER_INNER_BLOCK
2024-03-06 21:18:55 +03:00
- NUMBERED_PARAMETER_IT
- NUMBERED_PARAMETER_ORDINARY
2024-05-21 16:55:31 +03:00
- NUMBERED_PARAMETER_OUTER_BLOCK
2024-03-06 21:18:55 +03:00
- OPERATOR_MULTI_ASSIGN
- OPERATOR_WRITE_ARGUMENTS
- OPERATOR_WRITE_BLOCK
- PARAMETER_ASSOC_SPLAT_MULTI
- PARAMETER_BLOCK_MULTI
- PARAMETER_CIRCULAR
2024-05-10 18:39:51 +03:00
- PARAMETER_FORWARDING_AFTER_REST
2024-03-06 21:18:55 +03:00
- PARAMETER_METHOD_NAME
2024-03-30 01:25:39 +03:00
- PARAMETER_NAME_DUPLICATED
2024-03-06 21:18:55 +03:00
- PARAMETER_NO_DEFAULT
- PARAMETER_NO_DEFAULT_KW
- PARAMETER_NUMBERED_RESERVED
- PARAMETER_ORDER
- PARAMETER_SPLAT_MULTI
- PARAMETER_STAR
- PARAMETER_UNEXPECTED_FWD
2024-05-03 19:36:54 +03:00
- PARAMETER_UNEXPECTED_NO_KW
2024-06-05 17:50:18 +03:00
- PARAMETER_WILD_LOOSE_COMMA
2024-07-01 17:59:51 +03:00
- PATTERN_ARRAY_MULTIPLE_RESTS
2024-04-01 20:08:21 +03:00
- PATTERN_CAPTURE_DUPLICATE
2024-03-06 21:18:55 +03:00
- PATTERN_EXPRESSION_AFTER_BRACKET
- PATTERN_EXPRESSION_AFTER_COMMA
2024-02-16 05:27:46 +03:00
- PATTERN_EXPRESSION_AFTER_HROCKET
2024-03-06 21:18:55 +03:00
- PATTERN_EXPRESSION_AFTER_IN
- PATTERN_EXPRESSION_AFTER_KEY
- PATTERN_EXPRESSION_AFTER_PAREN
- PATTERN_EXPRESSION_AFTER_PIN
- PATTERN_EXPRESSION_AFTER_PIPE
- PATTERN_EXPRESSION_AFTER_RANGE
- PATTERN_EXPRESSION_AFTER_REST
2024-07-01 17:59:51 +03:00
- PATTERN_FIND_MISSING_INNER
2024-05-07 20:02:25 +03:00
- PATTERN_HASH_IMPLICIT
2024-03-06 21:18:55 +03:00
- PATTERN_HASH_KEY
2024-04-01 20:33:16 +03:00
- PATTERN_HASH_KEY_DUPLICATE
2024-05-07 19:15:44 +03:00
- PATTERN_HASH_KEY_INTERPOLATED
2024-03-06 21:18:55 +03:00
- PATTERN_HASH_KEY_LABEL
2024-04-19 21:15:14 +03:00
- PATTERN_HASH_KEY_LOCALS
2024-03-06 21:18:55 +03:00
- PATTERN_IDENT_AFTER_HROCKET
- PATTERN_LABEL_AFTER_COMMA
- PATTERN_REST
- PATTERN_TERM_BRACE
- PATTERN_TERM_BRACKET
- PATTERN_TERM_PAREN
- PIPEPIPEEQ_MULTI_ASSIGN
2024-02-16 05:27:46 +03:00
- REGEXP_ENCODING_OPTION_MISMATCH
- REGEXP_INCOMPAT_CHAR_ENCODING
- REGEXP_INVALID_UNICODE_RANGE
- REGEXP_NON_ESCAPED_MBC
2024-06-05 17:50:18 +03:00
- REGEXP_PARSE_ERROR
2024-03-06 21:18:55 +03:00
- REGEXP_TERM
[ruby/prism] Fix incorrect paring when using invalid regexp options
Fixes https://github.com/ruby/prism/pull/2617.
There was an issue with the lexer as follows.
The following are valid regexp options:
```console
$ bundle exec ruby -Ilib -rprism -ve 'p Prism.lex("/x/io").value.map {|token| token[0].type }'
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75) [x86_64-darwin22]
[:REGEXP_BEGIN, :STRING_CONTENT, :REGEXP_END, :EOF]
```
The following are invalid regexp options. Unnecessary the `IDENTIFIER` token is appearing:
```console
$ bundle exec ruby -Ilib -rprism -ve 'p Prism.lex("/x/az").value.map {|token| token[0].type }'
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75) [x86_64-darwin22]
[:REGEXP_BEGIN, :STRING_CONTENT, :REGEXP_END, :IDENTIFIER, :EOF]
```
As a behavior of Ruby, when given `A` to `Z` and `a` to `z`, they act as invalid regexp options. e.g.,
```console
$ ruby -e '/regexp/az'
-e:1: unknown regexp options - az
/regexp/az
-e: compile error (SyntaxError)
```
Thus, it should probably not be construed as `IDENTIFIER` token.
Therefore, `pm_byte_table` has been adapted to accept those invalid regexp option values.
Whether it is a valid regexp option or not is checked by `pm_regular_expression_flags_create`.
For invalid regexp options, `PM_ERR_REGEXP_UNKNOWN_OPTIONS` is added to diagnostics.
https://github.com/ruby/prism/commit/d2a6096fcf
2024-03-20 19:46:53 +03:00
- REGEXP_UNKNOWN_OPTIONS
2024-02-16 05:27:46 +03:00
- REGEXP_UTF8_CHAR_NON_UTF8_REGEXP
2024-03-06 21:18:55 +03:00
- RESCUE_EXPRESSION
- RESCUE_MODIFIER_VALUE
- RESCUE_TERM
- RESCUE_VARIABLE
- RETURN_INVALID
2024-03-28 16:51:16 +03:00
- SCRIPT_NOT_FOUND
2024-03-06 21:18:55 +03:00
- SINGLETON_FOR_LITERALS
- STATEMENT_ALIAS
- STATEMENT_POSTEXE_END
- STATEMENT_PREEXE_BEGIN
- STATEMENT_UNDEF
- STRING_CONCATENATION
- STRING_INTERPOLATED_TERM
- STRING_LITERAL_EOF
- STRING_LITERAL_TERM
- SYMBOL_INVALID
- SYMBOL_TERM_DYNAMIC
- SYMBOL_TERM_INTERPOLATED
- TERNARY_COLON
- TERNARY_EXPRESSION_FALSE
- TERNARY_EXPRESSION_TRUE
2024-06-21 00:30:12 +03:00
- UNARY_DISALLOWED
2024-03-06 21:18:55 +03:00
- UNARY_RECEIVER
2024-02-16 05:27:46 +03:00
- UNDEF_ARGUMENT
2024-04-12 20:18:47 +03:00
- UNEXPECTED_BLOCK_ARGUMENT
2024-05-03 19:03:48 +03:00
- UNEXPECTED_INDEX_BLOCK
- UNEXPECTED_INDEX_KEYWORDS
2024-09-25 20:23:42 +03:00
- UNEXPECTED_LABEL
2024-06-10 20:11:41 +03:00
- UNEXPECTED_MULTI_WRITE
2024-06-14 22:09:25 +03:00
- UNEXPECTED_RANGE_OPERATOR
2024-05-03 19:51:32 +03:00
- UNEXPECTED_SAFE_NAVIGATION
2024-03-06 21:18:55 +03:00
- UNEXPECTED_TOKEN_CLOSE_CONTEXT
- UNEXPECTED_TOKEN_IGNORE
- UNTIL_TERM
- VOID_EXPRESSION
- WHILE_TERM
- WRITE_TARGET_IN_METHOD
- WRITE_TARGET_READONLY
- WRITE_TARGET_UNEXPECTED
- XSTRING_TERM
warnings :
2024-05-20 16:54:14 +03:00
- AMBIGUOUS_BINARY_OPERATOR
2024-03-06 21:18:55 +03:00
- AMBIGUOUS_FIRST_ARGUMENT_MINUS
- AMBIGUOUS_FIRST_ARGUMENT_PLUS
2024-03-13 04:46:10 +03:00
- AMBIGUOUS_PREFIX_AMPERSAND
2024-03-06 21:18:55 +03:00
- AMBIGUOUS_PREFIX_STAR
2024-03-13 03:47:26 +03:00
- AMBIGUOUS_PREFIX_STAR_STAR
2024-03-06 21:18:55 +03:00
- AMBIGUOUS_SLASH
2024-03-12 21:46:21 +03:00
- COMPARISON_AFTER_COMPARISON
2024-03-06 21:18:55 +03:00
- DOT_DOT_DOT_EOL
- EQUAL_IN_CONDITIONAL
2024-05-02 01:54:05 +03:00
- EQUAL_IN_CONDITIONAL_3_3
2024-03-06 21:18:55 +03:00
- END_IN_METHOD
- DUPLICATED_HASH_KEY
- DUPLICATED_WHEN_CLAUSE
- FLOAT_OUT_OF_RANGE
2024-03-18 19:20:44 +03:00
- IGNORED_FROZEN_STRING_LITERAL
2024-07-19 18:08:06 +03:00
- INDENTATION_MISMATCH
2024-03-06 21:18:55 +03:00
- INTEGER_IN_FLIP_FLOP
2024-03-12 21:01:30 +03:00
- INVALID_CHARACTER
2024-07-19 18:08:06 +03:00
- INVALID_MAGIC_COMMENT_VALUE
2024-03-13 21:22:31 +03:00
- INVALID_NUMBERED_REFERENCE
2024-03-06 21:18:55 +03:00
- KEYWORD_EOL
2024-03-12 18:42:07 +03:00
- LITERAL_IN_CONDITION_DEFAULT
- LITERAL_IN_CONDITION_VERBOSE
2024-05-07 16:53:17 +03:00
- SHAREABLE_CONSTANT_VALUE_LINE
2024-03-28 16:51:16 +03:00
- SHEBANG_CARRIAGE_RETURN
2024-03-12 21:20:33 +03:00
- UNEXPECTED_CARRIAGE_RETURN
2024-04-12 17:49:30 +03:00
- UNREACHABLE_STATEMENT
2024-04-05 20:13:25 +03:00
- UNUSED_LOCAL_VARIABLE
2024-04-11 22:54:40 +03:00
- VOID_STATEMENT
2023-08-18 00:39:04 +03:00
tokens :
- name : EOF
value : 1
comment : final token in the file
- name : MISSING
comment : "a token that was expected but not found"
- name : NOT_PROVIDED
comment : "a token that was not present but it is okay"
- name : AMPERSAND
comment : "&"
- name : AMPERSAND_AMPERSAND
comment : "&&"
- name : AMPERSAND_AMPERSAND_EQUAL
comment : "&&="
- name : AMPERSAND_DOT
comment : "&."
- name : AMPERSAND_EQUAL
comment : "&="
- name : BACKTICK
comment : "`"
- name : BACK_REFERENCE
comment : "a back reference"
- name : BANG
comment : "! or !@"
- name : BANG_EQUAL
comment : "!="
- name : BANG_TILDE
comment : "!~"
- name : BRACE_LEFT
comment : "{"
- name : BRACE_RIGHT
comment : "}"
- name : BRACKET_LEFT
comment : "["
- name : BRACKET_LEFT_ARRAY
comment : "[ for the beginning of an array"
- name : BRACKET_LEFT_RIGHT
comment : "[]"
- name : BRACKET_LEFT_RIGHT_EQUAL
comment : "[]="
- name : BRACKET_RIGHT
comment : "]"
- name : CARET
comment : "^"
- name : CARET_EQUAL
comment : "^="
- name : CHARACTER_LITERAL
comment : "a character literal"
- name : CLASS_VARIABLE
comment : "a class variable"
- name : COLON
comment : ":"
- name : COLON_COLON
comment : "::"
- name : COMMA
comment : ","
- name : COMMENT
comment : "a comment"
- name : CONSTANT
comment : "a constant"
- name : DOT
2023-10-31 20:26:31 +03:00
comment : "the . call operator"
2023-08-18 00:39:04 +03:00
- name : DOT_DOT
2023-10-31 20:26:31 +03:00
comment : "the .. range operator"
2023-08-18 00:39:04 +03:00
- name : DOT_DOT_DOT
2023-10-31 20:26:31 +03:00
comment : "the ... range operator or forwarding parameter"
2023-08-18 00:39:04 +03:00
- name : EMBDOC_BEGIN
comment : "=begin"
- name : EMBDOC_END
comment : "=end"
- name : EMBDOC_LINE
comment : "a line inside of embedded documentation"
- name : EMBEXPR_BEGIN
comment : "#{"
- name : EMBEXPR_END
comment : "}"
- name : EMBVAR
comment : "#"
- name : EQUAL
comment : "="
- name : EQUAL_EQUAL
comment : "=="
- name : EQUAL_EQUAL_EQUAL
comment : "==="
- name : EQUAL_GREATER
comment : "=>"
- name : EQUAL_TILDE
comment : "=~"
- name : FLOAT
comment : "a floating point number"
- name : FLOAT_IMAGINARY
comment : "a floating pointer number with an imaginary suffix"
- name : FLOAT_RATIONAL
comment : "a floating pointer number with a rational suffix"
- name : FLOAT_RATIONAL_IMAGINARY
comment : "a floating pointer number with a rational and imaginary suffix"
- name : GLOBAL_VARIABLE
comment : "a global variable"
- name : GREATER
comment : ">"
- name : GREATER_EQUAL
comment : ">="
- name : GREATER_GREATER
comment : ">>"
- name : GREATER_GREATER_EQUAL
comment : ">>="
- name : HEREDOC_END
comment : "the end of a heredoc"
- name : HEREDOC_START
comment : "the start of a heredoc"
- name : IDENTIFIER
comment : "an identifier"
- name : IGNORED_NEWLINE
comment : "an ignored newline"
- name : INSTANCE_VARIABLE
comment : "an instance variable"
- name : INTEGER
comment : "an integer (any base)"
- name : INTEGER_IMAGINARY
comment : "an integer with an imaginary suffix"
- name : INTEGER_RATIONAL
comment : "an integer with a rational suffix"
- name : INTEGER_RATIONAL_IMAGINARY
comment : "an integer with a rational and imaginary suffix"
- name : KEYWORD_ALIAS
comment : "alias"
- name : KEYWORD_AND
comment : "and"
- name : KEYWORD_BEGIN
comment : "begin"
- name : KEYWORD_BEGIN_UPCASE
comment : "BEGIN"
- name : KEYWORD_BREAK
comment : "break"
- name : KEYWORD_CASE
comment : "case"
- name : KEYWORD_CLASS
comment : "class"
- name : KEYWORD_DEF
comment : "def"
- name : KEYWORD_DEFINED
comment : "defined?"
- name : KEYWORD_DO
comment : "do"
- name : KEYWORD_DO_LOOP
comment : "do keyword for a predicate in a while, until, or for loop"
- name : KEYWORD_ELSE
comment : "else"
- name : KEYWORD_ELSIF
comment : "elsif"
- name : KEYWORD_END
comment : "end"
- name : KEYWORD_END_UPCASE
comment : "END"
- name : KEYWORD_ENSURE
comment : "ensure"
- name : KEYWORD_FALSE
comment : "false"
- name : KEYWORD_FOR
comment : "for"
- name : KEYWORD_IF
comment : "if"
- name : KEYWORD_IF_MODIFIER
comment : "if in the modifier form"
- name : KEYWORD_IN
comment : "in"
- name : KEYWORD_MODULE
comment : "module"
- name : KEYWORD_NEXT
comment : "next"
- name : KEYWORD_NIL
comment : "nil"
- name : KEYWORD_NOT
comment : "not"
- name : KEYWORD_OR
comment : "or"
- name : KEYWORD_REDO
comment : "redo"
- name : KEYWORD_RESCUE
comment : "rescue"
- name : KEYWORD_RESCUE_MODIFIER
comment : "rescue in the modifier form"
- name : KEYWORD_RETRY
comment : "retry"
- name : KEYWORD_RETURN
comment : "return"
- name : KEYWORD_SELF
comment : "self"
- name : KEYWORD_SUPER
comment : "super"
- name : KEYWORD_THEN
comment : "then"
- name : KEYWORD_TRUE
comment : "true"
- name : KEYWORD_UNDEF
comment : "undef"
- name : KEYWORD_UNLESS
comment : "unless"
- name : KEYWORD_UNLESS_MODIFIER
comment : "unless in the modifier form"
- name : KEYWORD_UNTIL
comment : "until"
- name : KEYWORD_UNTIL_MODIFIER
comment : "until in the modifier form"
- name : KEYWORD_WHEN
comment : "when"
- name : KEYWORD_WHILE
comment : "while"
- name : KEYWORD_WHILE_MODIFIER
comment : "while in the modifier form"
- name : KEYWORD_YIELD
comment : "yield"
- name : KEYWORD___ENCODING__
comment : "__ENCODING__"
- name : KEYWORD___FILE__
comment : "__FILE__"
- name : KEYWORD___LINE__
comment : "__LINE__"
- name : LABEL
comment : "a label"
- name : LABEL_END
comment : "the end of a label"
- name : LAMBDA_BEGIN
comment : "{"
- name : LESS
comment : "<"
- name : LESS_EQUAL
comment : "<="
- name : LESS_EQUAL_GREATER
comment : "<=>"
- name : LESS_LESS
comment : "<<"
- name : LESS_LESS_EQUAL
comment : "<<="
2023-09-22 18:18:02 +03:00
- name : METHOD_NAME
comment : "a method name"
2023-08-18 00:39:04 +03:00
- name : MINUS
comment : "-"
- name : MINUS_EQUAL
comment : "-="
- name : MINUS_GREATER
comment : "->"
- name : NEWLINE
comment : "a newline character outside of other tokens"
- name : NUMBERED_REFERENCE
comment : "a numbered reference to a capture group in the previous regular expression match"
- name : PARENTHESIS_LEFT
comment : "("
- name : PARENTHESIS_LEFT_PARENTHESES
comment : "( for a parentheses node"
- name : PARENTHESIS_RIGHT
comment : ")"
- name : PERCENT
comment : "%"
- name : PERCENT_EQUAL
comment : "%="
- name : PERCENT_LOWER_I
comment : "%i"
- name : PERCENT_LOWER_W
comment : "%w"
- name : PERCENT_LOWER_X
comment : "%x"
- name : PERCENT_UPPER_I
comment : "%I"
- name : PERCENT_UPPER_W
comment : "%W"
- name : PIPE
comment : "|"
- name : PIPE_EQUAL
comment : "|="
- name : PIPE_PIPE
comment : "||"
- name : PIPE_PIPE_EQUAL
comment : "||="
- name : PLUS
comment : "+"
- name : PLUS_EQUAL
comment : "+="
- name : QUESTION_MARK
comment : "?"
- name : REGEXP_BEGIN
comment : "the beginning of a regular expression"
- name : REGEXP_END
comment : "the end of a regular expression"
- name : SEMICOLON
comment : ";"
- name : SLASH
comment : "/"
- name : SLASH_EQUAL
comment : "/="
- name : STAR
comment : "*"
- name : STAR_EQUAL
comment : "*="
- name : STAR_STAR
comment : "**"
- name : STAR_STAR_EQUAL
comment : "**="
- name : STRING_BEGIN
comment : "the beginning of a string"
- name : STRING_CONTENT
comment : "the contents of a string"
- name : STRING_END
comment : "the end of a string"
- name : SYMBOL_BEGIN
comment : "the beginning of a symbol"
- name : TILDE
comment : "~ or ~@"
- name : UAMPERSAND
comment : "unary &"
- name : UCOLON_COLON
comment : "unary ::"
- name : UDOT_DOT
2023-10-31 20:26:31 +03:00
comment : "unary .. operator"
2023-08-18 00:39:04 +03:00
- name : UDOT_DOT_DOT
2023-10-31 20:26:31 +03:00
comment : "unary ... operator"
2023-08-18 00:39:04 +03:00
- name : UMINUS
comment : "-@"
- name : UMINUS_NUM
comment : "-@ for a number"
- name : UPLUS
comment : "+@"
- name : USTAR
comment : "unary *"
- name : USTAR_STAR
comment : "unary **"
- name : WORDS_SEP
comment : "a separator between words in a list"
- name : __END__
comment : "marker for the point in the file at which the parser should stop"
flags :
2023-10-26 21:02:27 +03:00
- name : ArgumentsNodeFlags
values :
2024-09-11 19:29:13 +03:00
- name : CONTAINS_FORWARDING
comment : "if the arguments contain forwarding"
2024-05-03 19:03:48 +03:00
- name : CONTAINS_KEYWORDS
2024-09-11 19:29:13 +03:00
comment : "if the arguments contain keywords"
2023-11-21 23:46:48 +03:00
- name : CONTAINS_KEYWORD_SPLAT
2024-09-11 19:29:13 +03:00
comment : "if the arguments contain a keyword splat"
2024-08-27 23:40:48 +03:00
- name : CONTAINS_SPLAT
2024-09-11 19:29:13 +03:00
comment : "if the arguments contain a splat"
2024-08-28 23:56:05 +03:00
- name : CONTAINS_MULTIPLE_SPLATS
2024-09-11 19:29:13 +03:00
comment : "if the arguments contain multiple splats"
2023-10-30 21:00:44 +03:00
comment : Flags for arguments nodes.
2023-11-21 23:17:09 +03:00
- name : ArrayNodeFlags
values :
- name : CONTAINS_SPLAT
comment : "if array contains splat nodes"
comment : Flags for array nodes.
2023-08-18 00:39:04 +03:00
- name : CallNodeFlags
values :
- name : SAFE_NAVIGATION
comment : "&. operator"
- name : VARIABLE_CALL
comment : "a call that could have been a local variable"
2023-12-12 18:39:41 +03:00
- name : ATTRIBUTE_WRITE
comment : "a call that is an attribute write, so the value being written should be returned"
2024-01-02 22:54:45 +03:00
- name : IGNORE_VISIBILITY
comment : "a call that ignores method visibility"
2023-10-30 21:00:44 +03:00
comment : Flags for call nodes.
2023-12-04 20:51:22 +03:00
- name : EncodingFlags
values :
- name : FORCED_UTF8_ENCODING
comment : "internal bytes forced the encoding to UTF-8"
- name : FORCED_BINARY_ENCODING
comment : "internal bytes forced the encoding to binary"
comment : Flags for nodes that have unescaped content.
2023-09-11 19:05:14 +03:00
- name : IntegerBaseFlags
values :
- name : BINARY
comment : "0b prefix"
- name : DECIMAL
comment : "0d or no prefix"
2023-12-07 18:39:21 +03:00
- name : OCTAL
comment : "0o or 0 prefix"
2023-09-11 19:05:14 +03:00
- name : HEXADECIMAL
comment : "0x prefix"
2023-10-30 21:00:44 +03:00
comment : Flags for integer nodes that correspond to the base of the integer.
2024-03-25 22:32:54 +03:00
- name : InterpolatedStringNodeFlags
values :
- name : FROZEN
2024-03-28 17:12:45 +03:00
comment : "frozen by virtue of a `frozen_string_literal: true` comment or `--enable-frozen-string-literal`; only for adjacent string literals like `'a' 'b'`"
2024-03-25 22:32:54 +03:00
- name : MUTABLE
2024-03-28 17:12:45 +03:00
comment : "mutable by virtue of a `frozen_string_literal: false` comment or `--disable-frozen-string-literal`; only for adjacent string literals like `'a' 'b'`"
2024-03-25 22:32:54 +03:00
comment : Flags for interpolated string nodes that indicated mutability if they are also marked as literals.
2023-12-11 23:26:06 +03:00
- name : KeywordHashNodeFlags
values :
2023-12-25 11:34:06 +03:00
- name : SYMBOL_KEYS
comment : "a keyword hash which only has `AssocNode` elements all with symbol keys, which means the elements can be treated as keyword arguments"
2023-12-11 23:26:06 +03:00
comment : Flags for keyword hash nodes.
2023-08-18 00:39:04 +03:00
- name : LoopFlags
values :
- name : BEGIN_MODIFIER
comment : "a loop after a begin statement, so the body is executed first before the condition"
2023-10-30 21:00:44 +03:00
comment : Flags for while and until loop nodes.
2024-01-09 21:12:03 +03:00
- name : ParameterFlags
values :
- name : REPEATED_PARAMETER
comment : "a parameter name that has been repeated in the method signature"
comment : Flags for parameter nodes.
2023-08-18 00:39:04 +03:00
- name : RangeFlags
values :
- name : EXCLUDE_END
comment : "... operator"
2023-10-30 21:00:44 +03:00
comment : Flags for range and flip-flop nodes.
2023-08-18 00:39:04 +03:00
- name : RegularExpressionFlags
values :
- name : IGNORE_CASE
comment : "i - ignores the case of characters when matching"
- name : EXTENDED
comment : "x - ignores whitespace and allows comments in regular expressions"
2023-09-11 14:01:36 +03:00
- name : MULTI_LINE
comment : "m - allows $ to match the end of lines within strings"
2023-10-13 20:30:02 +03:00
- name : ONCE
comment : "o - only interpolates values into the regular expression once"
2023-08-18 00:39:04 +03:00
- name : EUC_JP
comment : "e - forces the EUC-JP encoding"
- name : ASCII_8BIT
comment : "n - forces the ASCII-8BIT encoding"
- name : WINDOWS_31J
comment : "s - forces the Windows-31J encoding"
- name : UTF_8
comment : "u - forces the UTF-8 encoding"
2023-12-08 18:10:43 +03:00
- name : FORCED_UTF8_ENCODING
comment : "internal bytes forced the encoding to UTF-8"
- name : FORCED_BINARY_ENCODING
comment : "internal bytes forced the encoding to binary"
- name : FORCED_US_ASCII_ENCODING
comment : "internal bytes forced the encoding to US-ASCII"
2023-10-30 21:00:44 +03:00
comment : Flags for regular expression and match last line nodes.
2024-03-15 04:37:16 +03:00
- name : ShareableConstantNodeFlags
values :
- name : LITERAL
comment : "constant writes that should be modified with shareable constant value literal"
- name : EXPERIMENTAL_EVERYTHING
comment : "constant writes that should be modified with shareable constant value experimental everything"
- name : EXPERIMENTAL_COPY
comment : "constant writes that should be modified with shareable constant value experimental copy"
comment : Flags for shareable constant nodes.
2023-09-12 20:06:41 +03:00
- name : StringFlags
values :
2023-12-04 20:51:22 +03:00
- name : FORCED_UTF8_ENCODING
comment : "internal bytes forced the encoding to UTF-8"
- name : FORCED_BINARY_ENCODING
comment : "internal bytes forced the encoding to binary"
2023-09-12 20:06:41 +03:00
- name : FROZEN
2024-03-12 14:17:55 +03:00
comment : "frozen by virtue of a `frozen_string_literal: true` comment or `--enable-frozen-string-literal`"
- name : MUTABLE
comment : "mutable by virtue of a `frozen_string_literal: false` comment or `--disable-frozen-string-literal`"
2023-10-30 21:00:44 +03:00
comment : Flags for string nodes.
2023-12-08 18:10:43 +03:00
- name : SymbolFlags
values :
- name : FORCED_UTF8_ENCODING
comment : "internal bytes forced the encoding to UTF-8"
- name : FORCED_BINARY_ENCODING
comment : "internal bytes forced the encoding to binary"
- name : FORCED_US_ASCII_ENCODING
comment : "internal bytes forced the encoding to US-ASCII"
comment : Flags for symbol nodes.
2023-08-18 00:39:04 +03:00
nodes :
2023-09-11 18:52:01 +03:00
- name : AliasGlobalVariableNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : new_name
type : node
2024-07-25 23:49:42 +03:00
kind :
- GlobalVariableReadNode
- BackReferenceReadNode
- NumberedReferenceReadNode
2024-01-04 06:08:59 +03:00
comment : |
2024-07-25 23:49:42 +03:00
Represents the new name of the global variable that can be used after aliasing.
2024-01-04 06:08:59 +03:00
alias $foo $bar
^^^^
2023-08-18 00:39:04 +03:00
- name : old_name
type : node
2024-07-25 23:49:42 +03:00
kind :
- GlobalVariableReadNode
- BackReferenceReadNode
- NumberedReferenceReadNode
2024-08-28 23:32:30 +03:00
- on error : SymbolNode # alias $a b
- on error : MissingNode # alias $a 42
2024-01-04 06:08:59 +03:00
comment : |
2024-07-25 23:49:42 +03:00
Represents the old name of the global variable that can be used before aliasing.
2024-01-04 06:08:59 +03:00
alias $foo $bar
^^^^
2023-08-18 00:39:04 +03:00
- name : keyword_loc
type : location
2024-01-04 06:08:59 +03:00
comment : |
The location of the `alias` keyword.
alias $foo $bar
^^^^^
2023-08-18 00:39:04 +03:00
comment : |
2023-09-11 18:52:01 +03:00
Represents the use of the `alias` keyword to alias a global variable.
alias $foo $bar
^^^^^^^^^^^^^^^
- name : AliasMethodNode
fields :
- name : new_name
type : node
2024-07-25 23:49:42 +03:00
kind :
- SymbolNode
- InterpolatedSymbolNode
2024-09-26 03:40:06 +03:00
comment : |
Represents the new name of the method that will be aliased.
alias foo bar
^^^
alias :foo :bar
^^^^
alias :"#{foo}" :"#{bar}"
^^^^^^^^^
2023-09-11 18:52:01 +03:00
- name : old_name
type : node
2024-07-25 23:49:42 +03:00
kind :
- SymbolNode
- InterpolatedSymbolNode
2024-08-28 23:32:30 +03:00
- on error : GlobalVariableReadNode # alias a $b
- on error : MissingNode # alias a 42
2024-09-26 03:40:06 +03:00
comment : |
Represents the old name of the method that will be aliased.
alias foo bar
^^^
alias :foo :bar
^^^^
alias :"#{foo}" :"#{bar}"
^^^^^^^^^
2023-09-11 18:52:01 +03:00
- name : keyword_loc
type : location
comment : |
Represents the use of the `alias` keyword to alias a method.
2023-08-18 00:39:04 +03:00
alias foo bar
^^^^^^^^^^^^^
- name : AlternationPatternNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : left
type : node
2024-08-28 23:32:30 +03:00
kind : pattern expression
2024-09-26 03:40:06 +03:00
comment : |
2024-09-26 18:18:35 +03:00
Represents the left side of the expression.
2024-09-26 03:40:06 +03:00
foo => bar | baz
^^^
2023-08-18 00:39:04 +03:00
- name : right
type : node
2024-08-28 23:32:30 +03:00
kind : pattern expression
2024-09-26 03:40:06 +03:00
comment : |
2024-09-26 18:18:35 +03:00
Represents the right side of the expression.
2024-09-26 03:40:06 +03:00
foo => bar | baz
^^^
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location
2024-09-26 03:40:06 +03:00
comment : |
Represents the alternation operator location.
foo => bar | baz
^
2023-08-18 00:39:04 +03:00
comment : |
Represents an alternation pattern in pattern matching.
foo => bar | baz
^^^^^^^^^
- name : AndNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : left
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-01-14 11:58:30 +03:00
comment : |
2024-01-19 19:22:40 +03:00
Represents the left side of the expression. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
2024-01-14 11:58:30 +03:00
2024-01-17 20:42:44 +03:00
left and right
^^^^
1 && 2
^
2023-08-18 00:39:04 +03:00
- name : right
type : node
2024-08-28 23:32:30 +03:00
kind : Node
2024-01-14 11:58:30 +03:00
comment : |
2024-08-28 23:32:30 +03:00
Represents the right side of the expression.
2024-01-14 11:58:30 +03:00
2024-01-17 20:42:44 +03:00
left && right
^^^^^
1 and 2
^
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location
2024-01-14 11:58:30 +03:00
comment : |
2024-01-17 20:42:44 +03:00
The location of the `and` keyword or the `&&` operator.
2024-01-14 11:58:30 +03:00
2024-01-17 20:42:44 +03:00
left and right
^^^
2023-08-18 00:39:04 +03:00
comment : |
Represents the use of the `&&` operator or the `and` keyword.
left and right
^^^^^^^^^^^^^^
- name : ArgumentsNode
2024-07-02 22:43:01 +03:00
flags : ArgumentsNodeFlags
2023-08-30 23:09:51 +03:00
fields :
2023-12-06 23:32:53 +03:00
- name : arguments
type : node[]
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-18 00:39:04 +03:00
comment : |
Represents a set of arguments to a method or a keyword.
return foo, bar, baz
^^^^^^^^^^^^^
- name : ArrayNode
2024-07-02 22:43:01 +03:00
flags : ArrayNodeFlags
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : elements
type : node[]
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-01-04 03:52:10 +03:00
comment : Represent the list of zero or more [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression) within the array.
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location?
2024-01-04 03:52:10 +03:00
comment : |
Represents the optional source location for the opening token.
[ 1 , 2 , 3 ] # "["
%w[foo bar baz] # "%w["
%I(apple orange banana) # "%I("
foo = 1, 2, 3 # nil
2023-08-18 00:39:04 +03:00
- name : closing_loc
type : location?
2024-01-04 03:52:10 +03:00
comment : |
Represents the optional source location for the closing token.
[ 1 , 2 , 3 ] # "]"
%w[foo bar baz] # "]"
%I(apple orange banana) # ")"
foo = 1, 2, 3 # nil
2023-08-18 00:39:04 +03:00
comment : |
2024-01-19 19:22:40 +03:00
Represents an array literal. This can be a regular array using brackets or a special array using % like %w or %i.
2023-08-18 00:39:04 +03:00
[ 1 , 2 , 3 ]
^^^^^^^^^
- name : ArrayPatternNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : constant
type : node?
2024-08-28 23:32:30 +03:00
kind :
- ConstantReadNode
- ConstantPathNode
2023-08-18 00:39:04 +03:00
- name : requireds
type : node[]
2024-08-28 23:32:30 +03:00
kind : pattern expression
2023-08-18 00:39:04 +03:00
- name : rest
type : node?
2024-08-28 23:32:30 +03:00
kind : pattern expression
2023-08-18 00:39:04 +03:00
- name : posts
type : node[]
2024-08-28 23:32:30 +03:00
kind : pattern expression
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location?
- name : closing_loc
type : location?
comment : |
Represents an array pattern in pattern matching.
foo in 1, 2
^^^^^^^^^^^
foo in [1, 2]
^^^^^^^^^^^^^
foo in *1
^^^^^^^^^
foo in Bar[]
^^^^^^^^^^^^
foo in Bar[1, 2, 3]
^^^^^^^^^^^^^^^^^^^
- name : AssocNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : key
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-01-07 12:56:22 +03:00
comment : |
2024-01-19 19:22:40 +03:00
The key of the association. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
2024-01-07 12:56:22 +03:00
{ a : b }
^
{ foo => bar }
^^^
{ def a; end => 1 }
^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : value
2024-01-24 20:11:45 +03:00
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-01-07 12:56:22 +03:00
comment : |
2024-01-24 20:11:45 +03:00
The value of the association, if present. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
2024-01-07 12:56:22 +03:00
{ foo => bar }
^^^
{ x : 1 }
^
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location?
2024-01-07 12:56:22 +03:00
comment : |
The location of the `=>` operator, if present.
{ foo => bar }
^^
2023-08-18 00:39:04 +03:00
comment : |
Represents a hash key/value pair.
{ a => b }
^^^^^^
- name : AssocSplatNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : value
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-01-07 13:07:55 +03:00
comment : |
2024-01-19 19:22:40 +03:00
The value to be splatted, if present. Will be missing when keyword rest argument forwarding is used.
2024-01-07 13:07:55 +03:00
{ **foo }
^^^
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location
2024-01-07 13:07:55 +03:00
comment : |
The location of the `**` operator.
{ **x }
^^
2023-08-18 00:39:04 +03:00
comment : |
Represents a splat in a hash literal.
{ **foo }
^^^^^
- name : BackReferenceReadNode
2023-10-14 03:23:13 +03:00
fields :
- name : name
type : constant
2024-01-08 23:25:30 +03:00
comment : |
The name of the back-reference variable, including the leading `$`.
$& # name `:$&`
$+ # name `:$+`
2023-08-18 00:39:04 +03:00
comment : |
Represents reading a reference to a field in the previous match.
$'
^^
- name : BeginNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : begin_keyword_loc
type : location?
- name : statements
type : node?
kind : StatementsNode
- name : rescue_clause
type : node?
kind : RescueNode
- name : else_clause
type : node?
kind : ElseNode
- name : ensure_clause
type : node?
kind : EnsureNode
- name : end_keyword_loc
type : location?
newline : false
comment : |
Represents a begin statement.
begin
foo
end
^^^^^
- name : BlockArgumentNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : expression
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location
comment : |
2024-07-25 23:49:42 +03:00
Represents a block argument using `&`.
2023-08-18 00:39:04 +03:00
bar(&args)
^^^^^^^^^^
2023-09-05 19:34:16 +03:00
- name : BlockLocalVariableNode
2024-07-02 22:43:01 +03:00
flags : ParameterFlags
2023-09-05 19:34:16 +03:00
fields :
- name : name
type : constant
comment : |
Represents a block local variable.
a { |; b| }
^
2023-08-18 00:39:04 +03:00
- name : BlockNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : locals
type : constant[]
- name : parameters
type : node?
2024-07-25 23:49:42 +03:00
kind :
- BlockParametersNode
- NumberedParametersNode
- ItParametersNode
2023-08-19 03:47:58 +03:00
- name : body
2023-08-18 00:39:04 +03:00
type : node?
2024-07-25 23:49:42 +03:00
kind :
- StatementsNode
- BeginNode
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location
- name : closing_loc
type : location
comment : |
Represents a block of ruby code.
2024-01-17 20:42:44 +03:00
[ 1 , 2 , 3 ] .each { |i| puts x }
^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : BlockParameterNode
2024-07-02 22:43:01 +03:00
flags : ParameterFlags
2023-08-30 23:09:51 +03:00
fields :
2023-09-06 17:46:20 +03:00
- name : name
type : constant?
2023-08-18 00:39:04 +03:00
- name : name_loc
type : location?
- name : operator_loc
type : location
comment : |
2024-07-25 23:49:42 +03:00
Represents a block parameter of a method, block, or lambda definition.
2023-08-18 00:39:04 +03:00
def a(&b)
^^
end
- name : BlockParametersNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : parameters
type : node?
kind : ParametersNode
- name : locals
2023-09-05 19:34:16 +03:00
type : node[]
2023-12-21 07:41:52 +03:00
kind : BlockLocalVariableNode
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location?
- name : closing_loc
type : location?
comment : |
Represents a block's parameters declaration.
-> (a, b = 1; local) { }
^^^^^^^^^^^^^^^^^
foo do |a, b = 1; local|
^^^^^^^^^^^^^^^^^
end
- name : BreakNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : arguments
type : node?
kind : ArgumentsNode
2024-01-19 17:45:49 +03:00
comment : |
The arguments to the break statement, if present. These can be any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
break foo
^^^
2023-08-18 00:39:04 +03:00
- name : keyword_loc
type : location
2024-01-19 17:45:49 +03:00
comment : |
The location of the `break` keyword.
break foo
^^^^^
2023-08-18 00:39:04 +03:00
comment : |
Represents the use of the `break` keyword.
break foo
^^^^^^^^^
2023-09-05 21:16:33 +03:00
- name : CallAndWriteNode
2024-07-02 22:43:01 +03:00
flags : CallNodeFlags
2023-09-05 21:16:33 +03:00
fields :
- name : receiver
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-09-05 21:16:33 +03:00
- name : call_operator_loc
type : location?
- name : message_loc
type : location?
- name : read_name
2023-10-01 13:34:55 +03:00
type : constant
2023-09-05 21:16:33 +03:00
- name : write_name
2023-10-01 13:34:55 +03:00
type : constant
2023-09-05 21:16:33 +03:00
- name : operator_loc
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-09-05 21:16:33 +03:00
comment : |
Represents the use of the `&&=` operator on a call.
foo.bar &&= value
^^^^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : CallNode
2024-07-02 22:43:01 +03:00
flags : CallNodeFlags
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : receiver
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-01-02 23:26:21 +03:00
comment : |
2024-01-19 19:22:40 +03:00
The object that the method is being called on. This can be either `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
2024-01-02 23:26:21 +03:00
foo.bar
^^^
+foo
^^^
foo + bar
^^^
2023-09-05 20:58:48 +03:00
- name : call_operator_loc
2023-08-18 00:39:04 +03:00
type : location?
2023-11-20 19:43:26 +03:00
- name : name
type : constant
2023-08-18 00:39:04 +03:00
- name : message_loc
type : location?
- name : opening_loc
type : location?
- name : arguments
type : node?
kind : ArgumentsNode
- name : closing_loc
type : location?
- name : block
type : node?
2024-08-28 23:32:30 +03:00
kind :
- BlockNode
- BlockArgumentNode
2023-08-18 00:39:04 +03:00
comment : |
Represents a method call, in all of the various forms that can take.
foo
^^^
foo()
^^^^^
+foo
^^^^
foo + bar
^^^^^^^^^
foo.bar
^^^^^^^
foo&.bar
^^^^^^^^
2023-09-05 21:16:33 +03:00
- name : CallOperatorWriteNode
2024-07-02 22:43:01 +03:00
flags : CallNodeFlags
2023-08-30 23:09:51 +03:00
fields :
2023-09-05 21:16:33 +03:00
- name : receiver
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-09-05 21:16:33 +03:00
- name : call_operator_loc
type : location?
- name : message_loc
type : location?
- name : read_name
2023-10-01 13:34:55 +03:00
type : constant
2023-09-05 21:16:33 +03:00
- name : write_name
2023-10-01 13:34:55 +03:00
type : constant
2024-05-10 17:19:11 +03:00
- name : binary_operator
2023-09-05 21:16:33 +03:00
type : constant
2024-05-10 17:19:11 +03:00
- name : binary_operator_loc
2023-08-18 00:39:04 +03:00
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-18 00:39:04 +03:00
comment : |
2023-09-05 21:16:33 +03:00
Represents the use of an assignment operator on a call.
2023-08-18 00:39:04 +03:00
2023-09-05 21:16:33 +03:00
foo.bar += baz
^^^^^^^^^^^^^^
- name : CallOrWriteNode
2024-07-02 22:43:01 +03:00
flags : CallNodeFlags
2023-08-30 23:09:51 +03:00
fields :
2023-09-05 21:16:33 +03:00
- name : receiver
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-09-05 21:16:33 +03:00
- name : call_operator_loc
type : location?
- name : message_loc
type : location?
- name : read_name
2023-10-01 13:34:55 +03:00
type : constant
2023-09-05 21:16:33 +03:00
- name : write_name
2023-10-01 13:34:55 +03:00
type : constant
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location
2023-09-05 21:16:33 +03:00
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-18 00:39:04 +03:00
comment : |
Represents the use of the `||=` operator on a call.
foo.bar ||= value
^^^^^^^^^^^^^^^^^
[ruby/prism] Split up CallNode in target position
In this commit we're splitting up the call nodes that were in target
positions (that is, for loop indices, rescue error captures, and
multi assign targets).
Previously, we would simply leave the call nodes in place. This had
the benefit of keeping the AST relatively simple, but had the
downside of not being very explicit. If a static analysis tool wanted
to only look at call nodes, it could easily be confused because the
method would have 1 fewer argument than it would actually be called
with.
This also brings some consistency to the AST. All of the nodes in
a target position are now *TargetNode nodes. These should all be
treated the same, and the call nodes can now be treated the same.
Finally, there is benefit to memory. Because being in a target
position ensures we don't have some fields, we can strip down the
number of fields on these nodes.
So this commit introduces two new nodes: CallTargetNode and
IndexTargetNode. For CallTargetNode we get to drop the opening_loc,
closing_loc, arguments, and block. Those can never be present. We
also get to mark their fields as non-null, so they will always be
seen as present.
The IndexTargetNode keeps around most of its fields but gets to
drop both the name (because it will always be []=) and the
message_loc (which was always super confusing because it included
the arguments by virtue of being inside the []).
Overall, this adds complexity to the AST at the expense of memory
savings and explicitness. I believe this tradeoff is worth it in
this case, especially because these are very much not common nodes
in the first place.
https://github.com/ruby/prism/commit/3ef71cdb45
2023-12-08 17:57:31 +03:00
- name : CallTargetNode
2024-07-02 22:43:01 +03:00
flags : CallNodeFlags
[ruby/prism] Split up CallNode in target position
In this commit we're splitting up the call nodes that were in target
positions (that is, for loop indices, rescue error captures, and
multi assign targets).
Previously, we would simply leave the call nodes in place. This had
the benefit of keeping the AST relatively simple, but had the
downside of not being very explicit. If a static analysis tool wanted
to only look at call nodes, it could easily be confused because the
method would have 1 fewer argument than it would actually be called
with.
This also brings some consistency to the AST. All of the nodes in
a target position are now *TargetNode nodes. These should all be
treated the same, and the call nodes can now be treated the same.
Finally, there is benefit to memory. Because being in a target
position ensures we don't have some fields, we can strip down the
number of fields on these nodes.
So this commit introduces two new nodes: CallTargetNode and
IndexTargetNode. For CallTargetNode we get to drop the opening_loc,
closing_loc, arguments, and block. Those can never be present. We
also get to mark their fields as non-null, so they will always be
seen as present.
The IndexTargetNode keeps around most of its fields but gets to
drop both the name (because it will always be []=) and the
message_loc (which was always super confusing because it included
the arguments by virtue of being inside the []).
Overall, this adds complexity to the AST at the expense of memory
savings and explicitness. I believe this tradeoff is worth it in
this case, especially because these are very much not common nodes
in the first place.
https://github.com/ruby/prism/commit/3ef71cdb45
2023-12-08 17:57:31 +03:00
fields :
- name : receiver
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
[ruby/prism] Split up CallNode in target position
In this commit we're splitting up the call nodes that were in target
positions (that is, for loop indices, rescue error captures, and
multi assign targets).
Previously, we would simply leave the call nodes in place. This had
the benefit of keeping the AST relatively simple, but had the
downside of not being very explicit. If a static analysis tool wanted
to only look at call nodes, it could easily be confused because the
method would have 1 fewer argument than it would actually be called
with.
This also brings some consistency to the AST. All of the nodes in
a target position are now *TargetNode nodes. These should all be
treated the same, and the call nodes can now be treated the same.
Finally, there is benefit to memory. Because being in a target
position ensures we don't have some fields, we can strip down the
number of fields on these nodes.
So this commit introduces two new nodes: CallTargetNode and
IndexTargetNode. For CallTargetNode we get to drop the opening_loc,
closing_loc, arguments, and block. Those can never be present. We
also get to mark their fields as non-null, so they will always be
seen as present.
The IndexTargetNode keeps around most of its fields but gets to
drop both the name (because it will always be []=) and the
message_loc (which was always super confusing because it included
the arguments by virtue of being inside the []).
Overall, this adds complexity to the AST at the expense of memory
savings and explicitness. I believe this tradeoff is worth it in
this case, especially because these are very much not common nodes
in the first place.
https://github.com/ruby/prism/commit/3ef71cdb45
2023-12-08 17:57:31 +03:00
- name : call_operator_loc
type : location
- name : name
type : constant
- name : message_loc
type : location
comment : |
Represents assigning to a method call.
foo.bar, = 1
^^^^^^^
begin
rescue => foo.bar
^^^^^^^
end
for foo.bar in baz do end
^^^^^^^
2023-08-18 00:39:04 +03:00
- name : CapturePatternNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : pattern expression
2023-08-18 00:39:04 +03:00
- name : target
type : node
2024-08-28 23:32:30 +03:00
kind : LocalVariableTargetNode
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location
comment : |
Represents assigning to a local variable in pattern matching.
foo => [bar => baz]
^^^^^^^^^^^^
2023-11-21 05:38:03 +03:00
- name : CaseMatchNode
fields :
- name : predicate
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-11-21 05:38:03 +03:00
- name : conditions
type : node[]
2024-08-28 23:32:30 +03:00
kind : InNode
2024-08-28 21:11:41 +03:00
- name : else_clause
2023-11-21 05:38:03 +03:00
type : node?
kind : ElseNode
- name : case_keyword_loc
type : location
- name : end_keyword_loc
type : location
comment : |
Represents the use of a case statement for pattern matching.
case true
in false
end
^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : CaseNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : predicate
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-18 00:39:04 +03:00
- name : conditions
type : node[]
2024-08-28 23:32:30 +03:00
kind : WhenNode
2024-08-28 21:11:41 +03:00
- name : else_clause
2023-08-18 00:39:04 +03:00
type : node?
kind : ElseNode
- name : case_keyword_loc
type : location
- name : end_keyword_loc
type : location
comment : |
Represents the use of a case statement.
2023-10-30 20:01:35 +03:00
case true
when false
end
^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : ClassNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : locals
type : constant[]
- name : class_keyword_loc
type : location
- name : constant_path
type : node
2024-08-28 23:32:30 +03:00
kind :
- ConstantReadNode
- ConstantPathNode
- on error : CallNode # class 0.X end
2023-08-18 00:39:04 +03:00
- name : inheritance_operator_loc
type : location?
- name : superclass
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-19 03:47:58 +03:00
- name : body
2023-08-18 00:39:04 +03:00
type : node?
2024-08-28 23:32:30 +03:00
kind :
- StatementsNode
- BeginNode
2023-08-18 00:39:04 +03:00
- name : end_keyword_loc
type : location
2023-08-25 04:22:20 +03:00
- name : name
2023-09-06 19:19:38 +03:00
type : constant
2023-08-18 00:39:04 +03:00
comment : |
Represents a class declaration involving the `class` keyword.
class Foo end
^^^^^^^^^^^^^
2023-08-25 17:49:00 +03:00
- name : ClassVariableAndWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-30 22:28:10 +03:00
- name : name
type : constant
2023-08-25 17:49:00 +03:00
- name : name_loc
type : location
- name : operator_loc
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-25 17:49:00 +03:00
comment : |
Represents the use of the `&&=` operator for assignment to a class variable.
@@target &&= value
2023-10-30 20:01:35 +03:00
^^^^^^^^^^^^^^^^^^
2023-08-25 17:49:00 +03:00
- name : ClassVariableOperatorWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-30 22:28:10 +03:00
- name : name
type : constant
2023-08-25 17:49:00 +03:00
- name : name_loc
type : location
2024-05-10 17:19:11 +03:00
- name : binary_operator_loc
2023-08-25 17:49:00 +03:00
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-05-10 17:19:11 +03:00
- name : binary_operator
2023-08-25 17:49:00 +03:00
type : constant
comment : |
Represents assigning to a class variable using an operator that isn't `=`.
@@target += value
^^^^^^^^^^^^^^^^^
- name : ClassVariableOrWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-30 22:28:10 +03:00
- name : name
type : constant
2023-08-25 17:49:00 +03:00
- name : name_loc
type : location
- name : operator_loc
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-25 17:49:00 +03:00
comment : |
Represents the use of the `||=` operator for assignment to a class variable.
@@target ||= value
^^^^^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : ClassVariableReadNode
2023-08-30 23:12:50 +03:00
fields :
2023-08-30 22:28:10 +03:00
- name : name
type : constant
2024-01-08 23:03:47 +03:00
comment : |
2024-01-19 19:22:40 +03:00
The name of the class variable, which is a `@@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
2024-01-08 23:03:47 +03:00
@@abc # name `:@@abc`
@@_test # name `:@@_test`
2023-08-18 00:39:04 +03:00
comment : |
Represents referencing a class variable.
@@foo
^^^^^
2023-08-25 18:57:37 +03:00
- name : ClassVariableTargetNode
2023-08-30 23:12:50 +03:00
fields :
2023-08-30 22:28:10 +03:00
- name : name
type : constant
2023-08-25 18:57:37 +03:00
comment : |
Represents writing to a class variable in a context that doesn't have an explicit value.
@@foo, @@bar = baz
^^^^^ ^^^^^
2023-08-18 00:39:04 +03:00
- name : ClassVariableWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-30 22:28:10 +03:00
- name : name
type : constant
2024-03-11 22:45:54 +03:00
comment : |
The name of the class variable, which is a `@@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
@@abc = 123 # name `@@abc`
@@_test = :test # name `@@_test`
2023-08-18 00:39:04 +03:00
- name : name_loc
type : location
2024-03-11 22:45:54 +03:00
comment : |
The location of the variable name.
@@foo = :bar
^^^^^
2023-08-18 00:39:04 +03:00
- name : value
2023-09-04 13:46:06 +03:00
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-03-11 22:45:54 +03:00
comment : |
2024-04-26 22:03:07 +03:00
The value to write to the class variable. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
2024-03-11 22:45:54 +03:00
@@foo = :bar
^^^^
@@_xyz = 123
^^^
2023-08-18 00:39:04 +03:00
- name : operator_loc
2024-03-11 22:45:54 +03:00
type : location
comment : |
The location of the `=` operator.
@@foo = :bar
^
2023-08-18 00:39:04 +03:00
comment : |
Represents writing to a class variable.
@@foo = 1
^^^^^^^^^
2023-08-25 17:49:00 +03:00
- name : ConstantAndWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-09-05 20:53:37 +03:00
- name : name
type : constant
2023-08-25 17:49:00 +03:00
- name : name_loc
type : location
- name : operator_loc
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-25 17:49:00 +03:00
comment : |
Represents the use of the `&&=` operator for assignment to a constant.
Target &&= value
^^^^^^^^^^^^^^^^
- name : ConstantOperatorWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-09-05 20:53:37 +03:00
- name : name
type : constant
2023-08-25 17:49:00 +03:00
- name : name_loc
type : location
2024-05-10 17:19:11 +03:00
- name : binary_operator_loc
2023-08-25 17:49:00 +03:00
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-05-10 17:19:11 +03:00
- name : binary_operator
2023-08-25 17:49:00 +03:00
type : constant
comment : |
Represents assigning to a constant using an operator that isn't `=`.
Target += value
^^^^^^^^^^^^^^^
- name : ConstantOrWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-09-05 20:53:37 +03:00
- name : name
type : constant
2023-08-25 17:49:00 +03:00
- name : name_loc
type : location
- name : operator_loc
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-25 17:49:00 +03:00
comment : |
Represents the use of the `||=` operator for assignment to a constant.
Target ||= value
^^^^^^^^^^^^^^^^
- name : ConstantPathAndWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-25 17:49:00 +03:00
- name : target
type : node
kind : ConstantPathNode
- name : operator_loc
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-25 17:49:00 +03:00
comment : |
Represents the use of the `&&=` operator for assignment to a constant path.
Parent::Child &&= value
^^^^^^^^^^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : ConstantPathNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : parent
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-04-26 22:03:07 +03:00
comment : |
The left-hand node of the path, if present. It can be `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). It will be `nil` when the constant lookup is at the root of the module tree.
Foo::Bar
^^^
self::Test
^^^^
a.b::C
^^^
2024-05-03 16:35:32 +03:00
- name : name
type : constant?
comment : The name of the constant being accessed. This could be `nil` in the event of a syntax error.
2023-08-18 00:39:04 +03:00
- name : delimiter_loc
type : location
2024-04-26 22:03:07 +03:00
comment : |
The location of the `::` delimiter.
: : Foo
^^
One::Two
^^
2024-05-03 16:35:32 +03:00
- name : name_loc
type : location
comment : |
The location of the name of the constant.
: : Foo
^^^
One::Two
^^^
2023-08-18 00:39:04 +03:00
comment : |
Represents accessing a constant through a path of `::` operators.
Foo::Bar
^^^^^^^^
2023-08-25 17:49:00 +03:00
- name : ConstantPathOperatorWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-25 17:49:00 +03:00
- name : target
type : node
kind : ConstantPathNode
2024-05-10 17:19:11 +03:00
- name : binary_operator_loc
2023-08-25 17:49:00 +03:00
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-05-10 17:19:11 +03:00
- name : binary_operator
2023-08-25 17:49:00 +03:00
type : constant
comment : |
Represents assigning to a constant path using an operator that isn't `=`.
Parent::Child += value
^^^^^^^^^^^^^^^^^^^^^^
- name : ConstantPathOrWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-25 17:49:00 +03:00
- name : target
type : node
kind : ConstantPathNode
- name : operator_loc
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-25 17:49:00 +03:00
comment : |
Represents the use of the `||=` operator for assignment to a constant path.
Parent::Child ||= value
^^^^^^^^^^^^^^^^^^^^^^^
2023-08-25 18:57:37 +03:00
- name : ConstantPathTargetNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-25 18:57:37 +03:00
- name : parent
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-05-03 16:35:32 +03:00
- name : name
type : constant?
2023-08-25 18:57:37 +03:00
- name : delimiter_loc
type : location
2024-05-03 16:35:32 +03:00
- name : name_loc
type : location
2023-08-25 18:57:37 +03:00
comment : |
Represents writing to a constant path in a context that doesn't have an explicit value.
Foo::Foo, Bar::Bar = baz
^^^^^^^^ ^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : ConstantPathWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : target
type : node
kind : ConstantPathNode
2024-04-26 22:03:07 +03:00
comment : |
A node representing the constant path being written to.
Foo::Bar = 1
^^^^^^^^
: : Foo = :abc
^^^^^
2023-08-18 00:39:04 +03:00
- name : operator_loc
2023-08-25 20:03:16 +03:00
type : location
2024-04-26 22:03:07 +03:00
comment : |
The location of the `=` operator.
: : ABC = 123
^
2023-08-18 00:39:04 +03:00
- name : value
2023-08-25 20:03:16 +03:00
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-04-26 22:03:07 +03:00
comment : |
The value to write to the constant path. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
FOO::BAR = :abc
^^^^
2023-08-18 00:39:04 +03:00
comment : |
Represents writing to a constant path.
: : Foo = 1
^^^^^^^^^
Foo::Bar = 1
^^^^^^^^^^^^
: : Foo::Bar = 1
^^^^^^^^^^^^^^
- name : ConstantReadNode
2023-09-05 20:53:37 +03:00
fields :
- name : name
type : constant
2024-01-09 00:07:01 +03:00
comment : |
2024-01-19 19:12:12 +03:00
The name of the [constant](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#constants).
2024-01-09 00:07:01 +03:00
X # name `:X`
SOME_CONSTANT # name `:SOME_CONSTANT`
2023-08-18 00:39:04 +03:00
comment : |
Represents referencing a constant.
Foo
^^^
2023-08-25 18:57:37 +03:00
- name : ConstantTargetNode
2023-09-05 20:53:37 +03:00
fields :
- name : name
type : constant
2023-08-25 18:57:37 +03:00
comment : |
2024-01-19 19:22:40 +03:00
Represents writing to a constant in a context that doesn't have an explicit value.
2023-08-25 18:57:37 +03:00
Foo, Bar = baz
^^^ ^^^
2023-08-18 00:39:04 +03:00
- name : ConstantWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-09-05 20:53:37 +03:00
- name : name
type : constant
2024-04-26 22:03:07 +03:00
comment : |
The name of the [constant](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#constants).
Foo = :bar # name `:Foo`
XYZ = 1 # name `:XYZ`
2023-08-18 00:39:04 +03:00
- name : name_loc
type : location
2024-04-26 22:03:07 +03:00
comment : |
The location of the constant name.
FOO = 1
^^^
2023-08-18 00:39:04 +03:00
- name : value
2023-08-25 20:03:16 +03:00
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-04-26 22:03:07 +03:00
comment : |
The value to write to the constant. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
FOO = :bar
^^^^
MyClass = Class.new
^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : operator_loc
2023-08-25 20:03:16 +03:00
type : location
2024-04-26 22:03:07 +03:00
comment : |
The location of the `=` operator.
FOO = :bar
^
2023-08-18 00:39:04 +03:00
comment : |
Represents writing to a constant.
Foo = 1
^^^^^^^
- name : DefNode
2023-08-30 23:09:51 +03:00
fields :
2023-09-06 18:27:00 +03:00
- name : name
type : constant
2023-08-18 00:39:04 +03:00
- name : name_loc
type : location
- name : receiver
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-18 00:39:04 +03:00
- name : parameters
type : node?
kind : ParametersNode
2023-08-19 03:47:58 +03:00
- name : body
2023-08-18 00:39:04 +03:00
type : node?
2024-08-28 23:32:30 +03:00
kind :
- StatementsNode
- BeginNode
2023-08-18 00:39:04 +03:00
- name : locals
type : constant[]
- name : def_keyword_loc
type : location
- name : operator_loc
type : location?
- name : lparen_loc
type : location?
- name : rparen_loc
type : location?
- name : equal_loc
type : location?
- name : end_keyword_loc
type : location?
comment : |
Represents a method definition.
def method
end
^^^^^^^^^^
- name : DefinedNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : lparen_loc
type : location?
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : Node # More than non-void expression as defined?(return) is allowed, yet defined?(BEGIN{}) is SyntaxError
2023-08-18 00:39:04 +03:00
- name : rparen_loc
type : location?
- name : keyword_loc
type : location
comment : |
Represents the use of the `defined?` keyword.
defined?(a)
^^^^^^^^^^^
- name : ElseNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : else_keyword_loc
type : location
- name : statements
type : node?
kind : StatementsNode
- name : end_keyword_loc
type : location?
comment : |
Represents an `else` clause in a `case`, `if`, or `unless` statement.
if a then b else c end
^^^^^^^^^^
- name : EmbeddedStatementsNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location
- name : statements
type : node?
kind : StatementsNode
- name : closing_loc
type : location
comment : |
Represents an interpolated set of statements.
"foo #{bar}"
^^^^^^
- name : EmbeddedVariableNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location
- name : variable
type : node
2024-08-28 23:32:30 +03:00
kind :
- InstanceVariableReadNode
- ClassVariableReadNode
- GlobalVariableReadNode
- BackReferenceReadNode
- NumberedReferenceReadNode
2023-08-18 00:39:04 +03:00
comment : |
Represents an interpolated variable.
"foo #@bar"
^^^^^
- name : EnsureNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : ensure_keyword_loc
type : location
- name : statements
type : node?
kind : StatementsNode
- name : end_keyword_loc
type : location
comment : |
Represents an `ensure` clause in a `begin` statement.
begin
foo
ensure
^^^^^^
bar
end
- name : FalseNode
comment : |
Represents the use of the literal `false` keyword.
false
^^^^^
- name : FindPatternNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : constant
type : node?
2024-08-28 23:32:30 +03:00
kind :
- ConstantReadNode
- ConstantPathNode
2023-08-18 00:39:04 +03:00
- name : left
type : node
2024-08-28 23:32:30 +03:00
kind : SplatNode
2023-08-18 00:39:04 +03:00
- name : requireds
type : node[]
2024-08-28 23:32:30 +03:00
kind : pattern expression
2023-08-18 00:39:04 +03:00
- name : right
type : node
2024-08-28 23:32:30 +03:00
kind :
- SplatNode
- on error : MissingNode
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location?
- name : closing_loc
type : location?
comment : |
Represents a find pattern in pattern matching.
foo in *bar, baz, *qux
2023-10-30 20:01:35 +03:00
^^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
foo in [*bar, baz, *qux]
2023-10-30 20:01:35 +03:00
^^^^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
foo in Foo(*bar, baz, *qux)
2023-10-30 20:01:35 +03:00
^^^^^^^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : FlipFlopNode
2024-07-02 22:43:01 +03:00
flags : RangeFlags
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : left
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-18 00:39:04 +03:00
- name : right
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location
comment : |
Represents the use of the `..` or `...` operators to create flip flops.
baz if foo .. bar
^^^^^^^^^^
- name : FloatNode
2024-02-22 23:53:28 +03:00
fields :
- name : value
type : double
comment : The value of the floating point number as a Float.
2023-08-18 00:39:04 +03:00
comment : |
Represents a floating point number literal.
1.0
^^^
- name : ForNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : index
type : node
2024-08-28 23:32:30 +03:00
kind :
- LocalVariableTargetNode
- InstanceVariableTargetNode
- ClassVariableTargetNode
- GlobalVariableTargetNode
- ConstantTargetNode
- ConstantPathTargetNode
- CallTargetNode
- IndexTargetNode
- MultiTargetNode
- on error : BackReferenceReadNode # for $& in a end
- on error : NumberedReferenceReadNode # for $1 in a end
- on error : MissingNode # for in 1..10; end
2024-05-29 16:36:06 +03:00
comment : |
The index expression for `for` loops.
for i in a end
^
2023-08-18 00:39:04 +03:00
- name : collection
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-05-29 16:36:06 +03:00
comment : |
The collection to iterate over.
for i in a end
^
2023-08-18 00:39:04 +03:00
- name : statements
type : node?
kind : StatementsNode
2024-05-29 16:36:06 +03:00
comment : |
Represents the body of statements to execute for each iteration of the loop.
for i in a
foo(i)
^^^^^^
end
2023-08-18 00:39:04 +03:00
- name : for_keyword_loc
type : location
2024-05-29 16:36:06 +03:00
comment : |
The location of the `for` keyword.
for i in a end
^^^
2023-08-18 00:39:04 +03:00
- name : in_keyword_loc
type : location
2024-05-29 16:36:06 +03:00
comment : |
The location of the `in` keyword.
for i in a end
^^
2023-08-18 00:39:04 +03:00
- name : do_keyword_loc
type : location?
2024-05-29 16:36:06 +03:00
comment : |
The location of the `do` keyword, if present.
for i in a do end
^^
2023-08-18 00:39:04 +03:00
- name : end_keyword_loc
type : location
2024-05-29 16:36:06 +03:00
comment : |
The location of the `end` keyword.
for i in a end
^^^
2023-08-18 00:39:04 +03:00
comment : |
Represents the use of the `for` keyword.
for i in a end
^^^^^^^^^^^^^^
- name : ForwardingArgumentsNode
comment : |
Represents forwarding all arguments to this method to another method.
def foo(...)
bar(...)
2023-10-30 20:01:35 +03:00
^^^
2023-08-18 00:39:04 +03:00
end
- name : ForwardingParameterNode
comment : |
Represents the use of the forwarding parameter in a method, block, or lambda declaration.
def foo(...)
^^^
end
- name : ForwardingSuperNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : block
type : node?
kind : BlockNode
comment : |
Represents the use of the `super` keyword without parentheses or arguments.
super
^^^^^
2023-08-25 17:49:00 +03:00
- name : GlobalVariableAndWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-09-01 16:40:08 +03:00
- name : name
type : constant
2023-08-25 17:49:00 +03:00
- name : name_loc
type : location
- name : operator_loc
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-25 17:49:00 +03:00
comment : |
Represents the use of the `&&=` operator for assignment to a global variable.
$target &&= value
^^^^^^^^^^^^^^^^^
- name : GlobalVariableOperatorWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-09-01 16:40:08 +03:00
- name : name
type : constant
2023-08-25 17:49:00 +03:00
- name : name_loc
type : location
2024-05-10 17:19:11 +03:00
- name : binary_operator_loc
2023-08-25 17:49:00 +03:00
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-05-10 17:19:11 +03:00
- name : binary_operator
2023-08-25 17:49:00 +03:00
type : constant
comment : |
Represents assigning to a global variable using an operator that isn't `=`.
$target += value
^^^^^^^^^^^^^^^^
- name : GlobalVariableOrWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-09-01 16:40:08 +03:00
- name : name
type : constant
2023-08-25 17:49:00 +03:00
- name : name_loc
type : location
- name : operator_loc
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-25 17:49:00 +03:00
comment : |
Represents the use of the `||=` operator for assignment to a global variable.
$target ||= value
^^^^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : GlobalVariableReadNode
2023-09-01 16:40:08 +03:00
fields :
- name : name
type : constant
2024-01-08 23:20:56 +03:00
comment : |
2024-01-19 19:22:40 +03:00
The name of the global variable, which is a `$` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifier). Alternatively, it can be one of the special global variables designated by a symbol.
2024-01-08 23:20:56 +03:00
$foo # name `:$foo`
$_Test # name `:$_Test`
2023-08-18 00:39:04 +03:00
comment : |
Represents referencing a global variable.
$foo
^^^^
2023-08-25 18:57:37 +03:00
- name : GlobalVariableTargetNode
2023-09-01 16:40:08 +03:00
fields :
- name : name
type : constant
2023-08-25 18:57:37 +03:00
comment : |
Represents writing to a global variable in a context that doesn't have an explicit value.
$foo, $bar = baz
^^^^ ^^^^
2023-08-18 00:39:04 +03:00
- name : GlobalVariableWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-09-01 16:40:08 +03:00
- name : name
type : constant
2024-04-26 22:03:07 +03:00
comment : |
The name of the global variable, which is a `$` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifier). Alternatively, it can be one of the special global variables designated by a symbol.
$foo = :bar # name `:$foo`
$_Test = 123 # name `:$_Test`
2023-08-18 00:39:04 +03:00
- name : name_loc
type : location
2024-04-26 22:03:07 +03:00
comment : |
The location of the global variable's name.
$foo = :bar
^^^^
2023-08-18 00:39:04 +03:00
- name : value
2023-08-25 20:03:16 +03:00
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-04-26 22:03:07 +03:00
comment : |
The value to write to the global variable. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
$foo = :bar
^^^^
$-xyz = 123
^^^
2023-08-30 23:43:40 +03:00
- name : operator_loc
type : location
2024-04-26 22:03:07 +03:00
comment : |
The location of the `=` operator.
$foo = :bar
^
2023-08-18 00:39:04 +03:00
comment : |
Represents writing to a global variable.
$foo = 1
^^^^^^^^
- name : HashNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location
2024-01-07 12:26:21 +03:00
comment : |
The location of the opening brace.
{ a => b }
^
2023-08-18 00:39:04 +03:00
- name : elements
type : node[]
2024-02-25 15:04:42 +03:00
kind :
- AssocNode
- AssocSplatNode
2024-01-07 12:26:21 +03:00
comment : |
The elements of the hash. These can be either `AssocNode`s or `AssocSplatNode`s.
{ a : b }
^^^^
{ **foo }
^^^^^
2023-08-18 00:39:04 +03:00
- name : closing_loc
type : location
2024-01-07 12:26:21 +03:00
comment : |
The location of the closing brace.
{ a => b }
^
2023-08-18 00:39:04 +03:00
comment : |
Represents a hash literal.
{ a => b }
^^^^^^^^^^
- name : HashPatternNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : constant
type : node?
2024-08-28 23:32:30 +03:00
kind :
- ConstantReadNode
- ConstantPathNode
2023-10-23 17:42:55 +03:00
- name : elements
2023-08-18 00:39:04 +03:00
type : node[]
2024-01-08 21:31:37 +03:00
kind : AssocNode
2023-10-23 17:42:55 +03:00
- name : rest
2023-08-18 00:39:04 +03:00
type : node?
2024-01-08 21:31:37 +03:00
kind :
- AssocSplatNode
- NoKeywordsParameterNode
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location?
- name : closing_loc
type : location?
comment : |
Represents a hash pattern in pattern matching.
foo => { a: 1, b: 2 }
^^^^^^^^^^^^^^
foo => { a: 1, b: 2, **c }
^^^^^^^^^^^^^^^^^^^
- name : IfNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : if_keyword_loc
type : location?
2024-01-15 02:40:32 +03:00
comment : |
The location of the `if` keyword if present.
bar if foo
^^
The `if_keyword_loc` field will be `nil` when the `IfNode` represents a ternary expression.
2023-08-18 00:39:04 +03:00
- name : predicate
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-01-15 02:40:32 +03:00
comment : |
The node for the condition the `IfNode` is testing.
if foo
^^^
bar
end
bar if foo
^^^
foo ? bar : baz
^^^
2023-11-16 01:55:16 +03:00
- name : then_keyword_loc
type : location?
2024-01-15 02:40:32 +03:00
comment : |
The location of the `then` keyword (if present) or the `?` in a ternary expression, `nil` otherwise.
if foo then bar end
^^^^
a ? b : c
^
2023-08-18 00:39:04 +03:00
- name : statements
type : node?
kind : StatementsNode
2024-01-15 02:40:32 +03:00
comment : |
Represents the body of statements that will be executed when the predicate is evaluated as truthy. Will be `nil` when no body is provided.
if foo
bar
^^^
baz
^^^
end
2024-08-28 21:11:41 +03:00
- name : subsequent
2023-08-18 00:39:04 +03:00
type : node?
2024-07-25 23:49:42 +03:00
kind :
- ElseNode
- IfNode
2024-01-15 02:40:32 +03:00
comment : |
Represents an `ElseNode` or an `IfNode` when there is an `else` or an `elsif` in the `if` statement.
if foo
bar
elsif baz
^^^^^^^^^
qux
^^^
end
^^^
if foo then bar else baz end
^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : end_keyword_loc
type : location?
2024-01-15 02:40:32 +03:00
comment : |
The location of the `end` keyword if present, `nil` otherwise.
if foo
bar
end
^^^
2023-08-18 00:39:04 +03:00
newline : predicate
comment : |
2024-01-15 02:40:32 +03:00
Represents the use of the `if` keyword, either in the block form or the modifier form, or a ternary expression.
2023-08-18 00:39:04 +03:00
bar if foo
^^^^^^^^^^
if foo then bar end
^^^^^^^^^^^^^^^^^^^
2024-01-15 02:40:32 +03:00
foo ? bar : baz
^^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : ImaginaryNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : numeric
type : node
2023-12-21 07:41:52 +03:00
kind :
- FloatNode
- IntegerNode
- RationalNode
2023-08-18 00:39:04 +03:00
comment : |
Represents an imaginary number literal.
1. 0i
^^^^
2023-09-13 16:39:20 +03:00
- name : ImplicitNode
fields :
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind :
- LocalVariableReadNode
- CallNode
- ConstantReadNode
- LocalVariableTargetNode
2023-09-13 16:39:20 +03:00
comment : |
2024-01-19 19:22:40 +03:00
Represents a node that is implicitly being added to the tree but doesn't correspond directly to a node in the source.
2023-09-13 16:39:20 +03:00
{ foo : }
^^^^
{ Foo : }
^^^^
2024-01-24 20:11:45 +03:00
foo in { bar: }
^^^^
[ruby/prism] Implicit rest nodes
Fundamentally, `foo { |bar,| }` is different from `foo { |bar, *| }`
because of arity checks. This PR introduces a new node to handle
that, `ImplicitRestNode`, which goes in the `rest` slot of parameter
nodes instead of `RestParameterNode` instances.
This is also used in a couple of other places, namely:
* pattern matching: `foo in [bar,]`
* multi target: `for foo, in bar do end`
* multi write: `foo, = bar`
Now the only splat nodes with a `NULL` value are when you're
forwarding, as in: `def foo(*) = bar(*)`.
https://github.com/ruby/prism/commit/dba2a3b652
2023-11-28 23:49:04 +03:00
- name : ImplicitRestNode
comment : |
Represents using a trailing comma to indicate an implicit rest parameter.
foo { |bar,| }
^
foo in [bar,]
^
for foo, in bar do end
^
foo, = bar
^
2023-08-18 00:39:04 +03:00
- name : InNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : pattern
type : node
2024-08-28 23:32:30 +03:00
kind : pattern expression
2023-08-18 00:39:04 +03:00
- name : statements
type : node?
kind : StatementsNode
- name : in_loc
type : location
- name : then_loc
type : location?
comment : |
Represents the use of the `in` keyword in a case statement.
case a; in b then c end
^^^^^^^^^^^
[ruby/prism] Index{Operator,And,Or}WriteNode
Right now, our Call{Operator,And,Or}WriteNode nodes represent two
different concepts:
```ruby
foo.bar += 1
foo[bar] += 1
```
These two statements are different in what they can support. The
former can never have arguments (or an opening_loc or closing_loc).
The former can also never have a block. Also, the former is a
variable method name.
The latter is always going to be []/[]=, it can have any number of
arguments including blocks (`foo[&bar] ||= 1`), and will always
have an opening_loc and closing_loc.
Furthermore, these statements end of having to take different paths
through the various compilers because with the latter you have to
consider the arguments and the block, whereas the former can
perform some additional peephole optimizations since there are
fewer values on the stack.
For these reasons, I'm introducing Index{Operator,And,Or}WriteNode.
These nodes never have a read_name or write_name on them because
they are always []/[]=. They also support blocks, which the previous
write nodes didn't. As a benefit of introducing these nodes, I've
removed the opening_loc, closing_loc, and arguments from the older
write nodes because they will always be null.
For the serialized format, both of these nodes end up being
smaller, and for in-memory we're storing fewer things in general,
so we have savings all around.
I don't love that we are introducing another node that is a call
node since we generally want consumers to only have to handle a
single call, but these nodes are so specific that they would have
to be handled separately anyway since in fact call 2 methods.
https://github.com/ruby/prism/commit/70155db9cd
2023-10-17 18:15:56 +03:00
- name : IndexAndWriteNode
2024-07-02 22:43:01 +03:00
flags : CallNodeFlags
[ruby/prism] Index{Operator,And,Or}WriteNode
Right now, our Call{Operator,And,Or}WriteNode nodes represent two
different concepts:
```ruby
foo.bar += 1
foo[bar] += 1
```
These two statements are different in what they can support. The
former can never have arguments (or an opening_loc or closing_loc).
The former can also never have a block. Also, the former is a
variable method name.
The latter is always going to be []/[]=, it can have any number of
arguments including blocks (`foo[&bar] ||= 1`), and will always
have an opening_loc and closing_loc.
Furthermore, these statements end of having to take different paths
through the various compilers because with the latter you have to
consider the arguments and the block, whereas the former can
perform some additional peephole optimizations since there are
fewer values on the stack.
For these reasons, I'm introducing Index{Operator,And,Or}WriteNode.
These nodes never have a read_name or write_name on them because
they are always []/[]=. They also support blocks, which the previous
write nodes didn't. As a benefit of introducing these nodes, I've
removed the opening_loc, closing_loc, and arguments from the older
write nodes because they will always be null.
For the serialized format, both of these nodes end up being
smaller, and for in-memory we're storing fewer things in general,
so we have savings all around.
I don't love that we are introducing another node that is a call
node since we generally want consumers to only have to handle a
single call, but these nodes are so specific that they would have
to be handled separately anyway since in fact call 2 methods.
https://github.com/ruby/prism/commit/70155db9cd
2023-10-17 18:15:56 +03:00
fields :
- name : receiver
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
[ruby/prism] Index{Operator,And,Or}WriteNode
Right now, our Call{Operator,And,Or}WriteNode nodes represent two
different concepts:
```ruby
foo.bar += 1
foo[bar] += 1
```
These two statements are different in what they can support. The
former can never have arguments (or an opening_loc or closing_loc).
The former can also never have a block. Also, the former is a
variable method name.
The latter is always going to be []/[]=, it can have any number of
arguments including blocks (`foo[&bar] ||= 1`), and will always
have an opening_loc and closing_loc.
Furthermore, these statements end of having to take different paths
through the various compilers because with the latter you have to
consider the arguments and the block, whereas the former can
perform some additional peephole optimizations since there are
fewer values on the stack.
For these reasons, I'm introducing Index{Operator,And,Or}WriteNode.
These nodes never have a read_name or write_name on them because
they are always []/[]=. They also support blocks, which the previous
write nodes didn't. As a benefit of introducing these nodes, I've
removed the opening_loc, closing_loc, and arguments from the older
write nodes because they will always be null.
For the serialized format, both of these nodes end up being
smaller, and for in-memory we're storing fewer things in general,
so we have savings all around.
I don't love that we are introducing another node that is a call
node since we generally want consumers to only have to handle a
single call, but these nodes are so specific that they would have
to be handled separately anyway since in fact call 2 methods.
https://github.com/ruby/prism/commit/70155db9cd
2023-10-17 18:15:56 +03:00
- name : call_operator_loc
type : location?
- name : opening_loc
type : location
- name : arguments
type : node?
kind : ArgumentsNode
- name : closing_loc
type : location
- name : block
type : node?
2024-08-28 23:32:30 +03:00
kind : BlockArgumentNode # foo[&b] &&= value, only valid on Ruby < 3.4
[ruby/prism] Index{Operator,And,Or}WriteNode
Right now, our Call{Operator,And,Or}WriteNode nodes represent two
different concepts:
```ruby
foo.bar += 1
foo[bar] += 1
```
These two statements are different in what they can support. The
former can never have arguments (or an opening_loc or closing_loc).
The former can also never have a block. Also, the former is a
variable method name.
The latter is always going to be []/[]=, it can have any number of
arguments including blocks (`foo[&bar] ||= 1`), and will always
have an opening_loc and closing_loc.
Furthermore, these statements end of having to take different paths
through the various compilers because with the latter you have to
consider the arguments and the block, whereas the former can
perform some additional peephole optimizations since there are
fewer values on the stack.
For these reasons, I'm introducing Index{Operator,And,Or}WriteNode.
These nodes never have a read_name or write_name on them because
they are always []/[]=. They also support blocks, which the previous
write nodes didn't. As a benefit of introducing these nodes, I've
removed the opening_loc, closing_loc, and arguments from the older
write nodes because they will always be null.
For the serialized format, both of these nodes end up being
smaller, and for in-memory we're storing fewer things in general,
so we have savings all around.
I don't love that we are introducing another node that is a call
node since we generally want consumers to only have to handle a
single call, but these nodes are so specific that they would have
to be handled separately anyway since in fact call 2 methods.
https://github.com/ruby/prism/commit/70155db9cd
2023-10-17 18:15:56 +03:00
- name : operator_loc
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
[ruby/prism] Index{Operator,And,Or}WriteNode
Right now, our Call{Operator,And,Or}WriteNode nodes represent two
different concepts:
```ruby
foo.bar += 1
foo[bar] += 1
```
These two statements are different in what they can support. The
former can never have arguments (or an opening_loc or closing_loc).
The former can also never have a block. Also, the former is a
variable method name.
The latter is always going to be []/[]=, it can have any number of
arguments including blocks (`foo[&bar] ||= 1`), and will always
have an opening_loc and closing_loc.
Furthermore, these statements end of having to take different paths
through the various compilers because with the latter you have to
consider the arguments and the block, whereas the former can
perform some additional peephole optimizations since there are
fewer values on the stack.
For these reasons, I'm introducing Index{Operator,And,Or}WriteNode.
These nodes never have a read_name or write_name on them because
they are always []/[]=. They also support blocks, which the previous
write nodes didn't. As a benefit of introducing these nodes, I've
removed the opening_loc, closing_loc, and arguments from the older
write nodes because they will always be null.
For the serialized format, both of these nodes end up being
smaller, and for in-memory we're storing fewer things in general,
so we have savings all around.
I don't love that we are introducing another node that is a call
node since we generally want consumers to only have to handle a
single call, but these nodes are so specific that they would have
to be handled separately anyway since in fact call 2 methods.
https://github.com/ruby/prism/commit/70155db9cd
2023-10-17 18:15:56 +03:00
comment : |
Represents the use of the `&&=` operator on a call to the `[]` method.
foo.bar[baz] &&= value
^^^^^^^^^^^^^^^^^^^^^^
- name : IndexOperatorWriteNode
2024-07-02 22:43:01 +03:00
flags : CallNodeFlags
[ruby/prism] Index{Operator,And,Or}WriteNode
Right now, our Call{Operator,And,Or}WriteNode nodes represent two
different concepts:
```ruby
foo.bar += 1
foo[bar] += 1
```
These two statements are different in what they can support. The
former can never have arguments (or an opening_loc or closing_loc).
The former can also never have a block. Also, the former is a
variable method name.
The latter is always going to be []/[]=, it can have any number of
arguments including blocks (`foo[&bar] ||= 1`), and will always
have an opening_loc and closing_loc.
Furthermore, these statements end of having to take different paths
through the various compilers because with the latter you have to
consider the arguments and the block, whereas the former can
perform some additional peephole optimizations since there are
fewer values on the stack.
For these reasons, I'm introducing Index{Operator,And,Or}WriteNode.
These nodes never have a read_name or write_name on them because
they are always []/[]=. They also support blocks, which the previous
write nodes didn't. As a benefit of introducing these nodes, I've
removed the opening_loc, closing_loc, and arguments from the older
write nodes because they will always be null.
For the serialized format, both of these nodes end up being
smaller, and for in-memory we're storing fewer things in general,
so we have savings all around.
I don't love that we are introducing another node that is a call
node since we generally want consumers to only have to handle a
single call, but these nodes are so specific that they would have
to be handled separately anyway since in fact call 2 methods.
https://github.com/ruby/prism/commit/70155db9cd
2023-10-17 18:15:56 +03:00
fields :
- name : receiver
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
[ruby/prism] Index{Operator,And,Or}WriteNode
Right now, our Call{Operator,And,Or}WriteNode nodes represent two
different concepts:
```ruby
foo.bar += 1
foo[bar] += 1
```
These two statements are different in what they can support. The
former can never have arguments (or an opening_loc or closing_loc).
The former can also never have a block. Also, the former is a
variable method name.
The latter is always going to be []/[]=, it can have any number of
arguments including blocks (`foo[&bar] ||= 1`), and will always
have an opening_loc and closing_loc.
Furthermore, these statements end of having to take different paths
through the various compilers because with the latter you have to
consider the arguments and the block, whereas the former can
perform some additional peephole optimizations since there are
fewer values on the stack.
For these reasons, I'm introducing Index{Operator,And,Or}WriteNode.
These nodes never have a read_name or write_name on them because
they are always []/[]=. They also support blocks, which the previous
write nodes didn't. As a benefit of introducing these nodes, I've
removed the opening_loc, closing_loc, and arguments from the older
write nodes because they will always be null.
For the serialized format, both of these nodes end up being
smaller, and for in-memory we're storing fewer things in general,
so we have savings all around.
I don't love that we are introducing another node that is a call
node since we generally want consumers to only have to handle a
single call, but these nodes are so specific that they would have
to be handled separately anyway since in fact call 2 methods.
https://github.com/ruby/prism/commit/70155db9cd
2023-10-17 18:15:56 +03:00
- name : call_operator_loc
type : location?
- name : opening_loc
type : location
- name : arguments
type : node?
kind : ArgumentsNode
- name : closing_loc
type : location
- name : block
type : node?
2024-08-28 23:32:30 +03:00
kind : BlockArgumentNode # foo[&b] += value, only valid on Ruby < 3.4
2024-05-10 17:19:11 +03:00
- name : binary_operator
[ruby/prism] Index{Operator,And,Or}WriteNode
Right now, our Call{Operator,And,Or}WriteNode nodes represent two
different concepts:
```ruby
foo.bar += 1
foo[bar] += 1
```
These two statements are different in what they can support. The
former can never have arguments (or an opening_loc or closing_loc).
The former can also never have a block. Also, the former is a
variable method name.
The latter is always going to be []/[]=, it can have any number of
arguments including blocks (`foo[&bar] ||= 1`), and will always
have an opening_loc and closing_loc.
Furthermore, these statements end of having to take different paths
through the various compilers because with the latter you have to
consider the arguments and the block, whereas the former can
perform some additional peephole optimizations since there are
fewer values on the stack.
For these reasons, I'm introducing Index{Operator,And,Or}WriteNode.
These nodes never have a read_name or write_name on them because
they are always []/[]=. They also support blocks, which the previous
write nodes didn't. As a benefit of introducing these nodes, I've
removed the opening_loc, closing_loc, and arguments from the older
write nodes because they will always be null.
For the serialized format, both of these nodes end up being
smaller, and for in-memory we're storing fewer things in general,
so we have savings all around.
I don't love that we are introducing another node that is a call
node since we generally want consumers to only have to handle a
single call, but these nodes are so specific that they would have
to be handled separately anyway since in fact call 2 methods.
https://github.com/ruby/prism/commit/70155db9cd
2023-10-17 18:15:56 +03:00
type : constant
2024-05-10 17:19:11 +03:00
- name : binary_operator_loc
[ruby/prism] Index{Operator,And,Or}WriteNode
Right now, our Call{Operator,And,Or}WriteNode nodes represent two
different concepts:
```ruby
foo.bar += 1
foo[bar] += 1
```
These two statements are different in what they can support. The
former can never have arguments (or an opening_loc or closing_loc).
The former can also never have a block. Also, the former is a
variable method name.
The latter is always going to be []/[]=, it can have any number of
arguments including blocks (`foo[&bar] ||= 1`), and will always
have an opening_loc and closing_loc.
Furthermore, these statements end of having to take different paths
through the various compilers because with the latter you have to
consider the arguments and the block, whereas the former can
perform some additional peephole optimizations since there are
fewer values on the stack.
For these reasons, I'm introducing Index{Operator,And,Or}WriteNode.
These nodes never have a read_name or write_name on them because
they are always []/[]=. They also support blocks, which the previous
write nodes didn't. As a benefit of introducing these nodes, I've
removed the opening_loc, closing_loc, and arguments from the older
write nodes because they will always be null.
For the serialized format, both of these nodes end up being
smaller, and for in-memory we're storing fewer things in general,
so we have savings all around.
I don't love that we are introducing another node that is a call
node since we generally want consumers to only have to handle a
single call, but these nodes are so specific that they would have
to be handled separately anyway since in fact call 2 methods.
https://github.com/ruby/prism/commit/70155db9cd
2023-10-17 18:15:56 +03:00
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
[ruby/prism] Index{Operator,And,Or}WriteNode
Right now, our Call{Operator,And,Or}WriteNode nodes represent two
different concepts:
```ruby
foo.bar += 1
foo[bar] += 1
```
These two statements are different in what they can support. The
former can never have arguments (or an opening_loc or closing_loc).
The former can also never have a block. Also, the former is a
variable method name.
The latter is always going to be []/[]=, it can have any number of
arguments including blocks (`foo[&bar] ||= 1`), and will always
have an opening_loc and closing_loc.
Furthermore, these statements end of having to take different paths
through the various compilers because with the latter you have to
consider the arguments and the block, whereas the former can
perform some additional peephole optimizations since there are
fewer values on the stack.
For these reasons, I'm introducing Index{Operator,And,Or}WriteNode.
These nodes never have a read_name or write_name on them because
they are always []/[]=. They also support blocks, which the previous
write nodes didn't. As a benefit of introducing these nodes, I've
removed the opening_loc, closing_loc, and arguments from the older
write nodes because they will always be null.
For the serialized format, both of these nodes end up being
smaller, and for in-memory we're storing fewer things in general,
so we have savings all around.
I don't love that we are introducing another node that is a call
node since we generally want consumers to only have to handle a
single call, but these nodes are so specific that they would have
to be handled separately anyway since in fact call 2 methods.
https://github.com/ruby/prism/commit/70155db9cd
2023-10-17 18:15:56 +03:00
comment : |
Represents the use of an assignment operator on a call to `[]`.
foo.bar[baz] += value
^^^^^^^^^^^^^^^^^^^^^
- name : IndexOrWriteNode
2024-07-02 22:43:01 +03:00
flags : CallNodeFlags
[ruby/prism] Index{Operator,And,Or}WriteNode
Right now, our Call{Operator,And,Or}WriteNode nodes represent two
different concepts:
```ruby
foo.bar += 1
foo[bar] += 1
```
These two statements are different in what they can support. The
former can never have arguments (or an opening_loc or closing_loc).
The former can also never have a block. Also, the former is a
variable method name.
The latter is always going to be []/[]=, it can have any number of
arguments including blocks (`foo[&bar] ||= 1`), and will always
have an opening_loc and closing_loc.
Furthermore, these statements end of having to take different paths
through the various compilers because with the latter you have to
consider the arguments and the block, whereas the former can
perform some additional peephole optimizations since there are
fewer values on the stack.
For these reasons, I'm introducing Index{Operator,And,Or}WriteNode.
These nodes never have a read_name or write_name on them because
they are always []/[]=. They also support blocks, which the previous
write nodes didn't. As a benefit of introducing these nodes, I've
removed the opening_loc, closing_loc, and arguments from the older
write nodes because they will always be null.
For the serialized format, both of these nodes end up being
smaller, and for in-memory we're storing fewer things in general,
so we have savings all around.
I don't love that we are introducing another node that is a call
node since we generally want consumers to only have to handle a
single call, but these nodes are so specific that they would have
to be handled separately anyway since in fact call 2 methods.
https://github.com/ruby/prism/commit/70155db9cd
2023-10-17 18:15:56 +03:00
fields :
- name : receiver
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
[ruby/prism] Index{Operator,And,Or}WriteNode
Right now, our Call{Operator,And,Or}WriteNode nodes represent two
different concepts:
```ruby
foo.bar += 1
foo[bar] += 1
```
These two statements are different in what they can support. The
former can never have arguments (or an opening_loc or closing_loc).
The former can also never have a block. Also, the former is a
variable method name.
The latter is always going to be []/[]=, it can have any number of
arguments including blocks (`foo[&bar] ||= 1`), and will always
have an opening_loc and closing_loc.
Furthermore, these statements end of having to take different paths
through the various compilers because with the latter you have to
consider the arguments and the block, whereas the former can
perform some additional peephole optimizations since there are
fewer values on the stack.
For these reasons, I'm introducing Index{Operator,And,Or}WriteNode.
These nodes never have a read_name or write_name on them because
they are always []/[]=. They also support blocks, which the previous
write nodes didn't. As a benefit of introducing these nodes, I've
removed the opening_loc, closing_loc, and arguments from the older
write nodes because they will always be null.
For the serialized format, both of these nodes end up being
smaller, and for in-memory we're storing fewer things in general,
so we have savings all around.
I don't love that we are introducing another node that is a call
node since we generally want consumers to only have to handle a
single call, but these nodes are so specific that they would have
to be handled separately anyway since in fact call 2 methods.
https://github.com/ruby/prism/commit/70155db9cd
2023-10-17 18:15:56 +03:00
- name : call_operator_loc
type : location?
- name : opening_loc
type : location
- name : arguments
type : node?
kind : ArgumentsNode
- name : closing_loc
type : location
- name : block
type : node?
2024-08-28 23:32:30 +03:00
kind : BlockArgumentNode # foo[&b] ||= value, only valid on Ruby < 3.4
[ruby/prism] Index{Operator,And,Or}WriteNode
Right now, our Call{Operator,And,Or}WriteNode nodes represent two
different concepts:
```ruby
foo.bar += 1
foo[bar] += 1
```
These two statements are different in what they can support. The
former can never have arguments (or an opening_loc or closing_loc).
The former can also never have a block. Also, the former is a
variable method name.
The latter is always going to be []/[]=, it can have any number of
arguments including blocks (`foo[&bar] ||= 1`), and will always
have an opening_loc and closing_loc.
Furthermore, these statements end of having to take different paths
through the various compilers because with the latter you have to
consider the arguments and the block, whereas the former can
perform some additional peephole optimizations since there are
fewer values on the stack.
For these reasons, I'm introducing Index{Operator,And,Or}WriteNode.
These nodes never have a read_name or write_name on them because
they are always []/[]=. They also support blocks, which the previous
write nodes didn't. As a benefit of introducing these nodes, I've
removed the opening_loc, closing_loc, and arguments from the older
write nodes because they will always be null.
For the serialized format, both of these nodes end up being
smaller, and for in-memory we're storing fewer things in general,
so we have savings all around.
I don't love that we are introducing another node that is a call
node since we generally want consumers to only have to handle a
single call, but these nodes are so specific that they would have
to be handled separately anyway since in fact call 2 methods.
https://github.com/ruby/prism/commit/70155db9cd
2023-10-17 18:15:56 +03:00
- name : operator_loc
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
[ruby/prism] Index{Operator,And,Or}WriteNode
Right now, our Call{Operator,And,Or}WriteNode nodes represent two
different concepts:
```ruby
foo.bar += 1
foo[bar] += 1
```
These two statements are different in what they can support. The
former can never have arguments (or an opening_loc or closing_loc).
The former can also never have a block. Also, the former is a
variable method name.
The latter is always going to be []/[]=, it can have any number of
arguments including blocks (`foo[&bar] ||= 1`), and will always
have an opening_loc and closing_loc.
Furthermore, these statements end of having to take different paths
through the various compilers because with the latter you have to
consider the arguments and the block, whereas the former can
perform some additional peephole optimizations since there are
fewer values on the stack.
For these reasons, I'm introducing Index{Operator,And,Or}WriteNode.
These nodes never have a read_name or write_name on them because
they are always []/[]=. They also support blocks, which the previous
write nodes didn't. As a benefit of introducing these nodes, I've
removed the opening_loc, closing_loc, and arguments from the older
write nodes because they will always be null.
For the serialized format, both of these nodes end up being
smaller, and for in-memory we're storing fewer things in general,
so we have savings all around.
I don't love that we are introducing another node that is a call
node since we generally want consumers to only have to handle a
single call, but these nodes are so specific that they would have
to be handled separately anyway since in fact call 2 methods.
https://github.com/ruby/prism/commit/70155db9cd
2023-10-17 18:15:56 +03:00
comment : |
Represents the use of the `||=` operator on a call to `[]`.
foo.bar[baz] ||= value
^^^^^^^^^^^^^^^^^^^^^^
[ruby/prism] Split up CallNode in target position
In this commit we're splitting up the call nodes that were in target
positions (that is, for loop indices, rescue error captures, and
multi assign targets).
Previously, we would simply leave the call nodes in place. This had
the benefit of keeping the AST relatively simple, but had the
downside of not being very explicit. If a static analysis tool wanted
to only look at call nodes, it could easily be confused because the
method would have 1 fewer argument than it would actually be called
with.
This also brings some consistency to the AST. All of the nodes in
a target position are now *TargetNode nodes. These should all be
treated the same, and the call nodes can now be treated the same.
Finally, there is benefit to memory. Because being in a target
position ensures we don't have some fields, we can strip down the
number of fields on these nodes.
So this commit introduces two new nodes: CallTargetNode and
IndexTargetNode. For CallTargetNode we get to drop the opening_loc,
closing_loc, arguments, and block. Those can never be present. We
also get to mark their fields as non-null, so they will always be
seen as present.
The IndexTargetNode keeps around most of its fields but gets to
drop both the name (because it will always be []=) and the
message_loc (which was always super confusing because it included
the arguments by virtue of being inside the []).
Overall, this adds complexity to the AST at the expense of memory
savings and explicitness. I believe this tradeoff is worth it in
this case, especially because these are very much not common nodes
in the first place.
https://github.com/ruby/prism/commit/3ef71cdb45
2023-12-08 17:57:31 +03:00
- name : IndexTargetNode
2024-07-02 22:43:01 +03:00
flags : CallNodeFlags
[ruby/prism] Split up CallNode in target position
In this commit we're splitting up the call nodes that were in target
positions (that is, for loop indices, rescue error captures, and
multi assign targets).
Previously, we would simply leave the call nodes in place. This had
the benefit of keeping the AST relatively simple, but had the
downside of not being very explicit. If a static analysis tool wanted
to only look at call nodes, it could easily be confused because the
method would have 1 fewer argument than it would actually be called
with.
This also brings some consistency to the AST. All of the nodes in
a target position are now *TargetNode nodes. These should all be
treated the same, and the call nodes can now be treated the same.
Finally, there is benefit to memory. Because being in a target
position ensures we don't have some fields, we can strip down the
number of fields on these nodes.
So this commit introduces two new nodes: CallTargetNode and
IndexTargetNode. For CallTargetNode we get to drop the opening_loc,
closing_loc, arguments, and block. Those can never be present. We
also get to mark their fields as non-null, so they will always be
seen as present.
The IndexTargetNode keeps around most of its fields but gets to
drop both the name (because it will always be []=) and the
message_loc (which was always super confusing because it included
the arguments by virtue of being inside the []).
Overall, this adds complexity to the AST at the expense of memory
savings and explicitness. I believe this tradeoff is worth it in
this case, especially because these are very much not common nodes
in the first place.
https://github.com/ruby/prism/commit/3ef71cdb45
2023-12-08 17:57:31 +03:00
fields :
- name : receiver
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
[ruby/prism] Split up CallNode in target position
In this commit we're splitting up the call nodes that were in target
positions (that is, for loop indices, rescue error captures, and
multi assign targets).
Previously, we would simply leave the call nodes in place. This had
the benefit of keeping the AST relatively simple, but had the
downside of not being very explicit. If a static analysis tool wanted
to only look at call nodes, it could easily be confused because the
method would have 1 fewer argument than it would actually be called
with.
This also brings some consistency to the AST. All of the nodes in
a target position are now *TargetNode nodes. These should all be
treated the same, and the call nodes can now be treated the same.
Finally, there is benefit to memory. Because being in a target
position ensures we don't have some fields, we can strip down the
number of fields on these nodes.
So this commit introduces two new nodes: CallTargetNode and
IndexTargetNode. For CallTargetNode we get to drop the opening_loc,
closing_loc, arguments, and block. Those can never be present. We
also get to mark their fields as non-null, so they will always be
seen as present.
The IndexTargetNode keeps around most of its fields but gets to
drop both the name (because it will always be []=) and the
message_loc (which was always super confusing because it included
the arguments by virtue of being inside the []).
Overall, this adds complexity to the AST at the expense of memory
savings and explicitness. I believe this tradeoff is worth it in
this case, especially because these are very much not common nodes
in the first place.
https://github.com/ruby/prism/commit/3ef71cdb45
2023-12-08 17:57:31 +03:00
- name : opening_loc
type : location
- name : arguments
type : node?
kind : ArgumentsNode
- name : closing_loc
type : location
- name : block
type : node?
2024-08-28 23:32:30 +03:00
kind : BlockArgumentNode # foo[&b], = 1, only valid on Ruby < 3.4
[ruby/prism] Split up CallNode in target position
In this commit we're splitting up the call nodes that were in target
positions (that is, for loop indices, rescue error captures, and
multi assign targets).
Previously, we would simply leave the call nodes in place. This had
the benefit of keeping the AST relatively simple, but had the
downside of not being very explicit. If a static analysis tool wanted
to only look at call nodes, it could easily be confused because the
method would have 1 fewer argument than it would actually be called
with.
This also brings some consistency to the AST. All of the nodes in
a target position are now *TargetNode nodes. These should all be
treated the same, and the call nodes can now be treated the same.
Finally, there is benefit to memory. Because being in a target
position ensures we don't have some fields, we can strip down the
number of fields on these nodes.
So this commit introduces two new nodes: CallTargetNode and
IndexTargetNode. For CallTargetNode we get to drop the opening_loc,
closing_loc, arguments, and block. Those can never be present. We
also get to mark their fields as non-null, so they will always be
seen as present.
The IndexTargetNode keeps around most of its fields but gets to
drop both the name (because it will always be []=) and the
message_loc (which was always super confusing because it included
the arguments by virtue of being inside the []).
Overall, this adds complexity to the AST at the expense of memory
savings and explicitness. I believe this tradeoff is worth it in
this case, especially because these are very much not common nodes
in the first place.
https://github.com/ruby/prism/commit/3ef71cdb45
2023-12-08 17:57:31 +03:00
comment : |
Represents assigning to an index.
foo[bar], = 1
^^^^^^^^
begin
rescue => foo[bar]
^^^^^^^^
end
for foo[bar] in baz do end
^^^^^^^^
2023-08-25 17:49:00 +03:00
- name : InstanceVariableAndWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-29 16:17:34 +03:00
- name : name
type : constant
2023-08-25 17:49:00 +03:00
- name : name_loc
type : location
- name : operator_loc
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-25 17:49:00 +03:00
comment : |
Represents the use of the `&&=` operator for assignment to an instance variable.
@target &&= value
^^^^^^^^^^^^^^^^^
- name : InstanceVariableOperatorWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-29 16:17:34 +03:00
- name : name
type : constant
2023-08-25 17:49:00 +03:00
- name : name_loc
type : location
2024-05-10 17:19:11 +03:00
- name : binary_operator_loc
2023-08-25 17:49:00 +03:00
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-05-10 17:19:11 +03:00
- name : binary_operator
2023-08-25 17:49:00 +03:00
type : constant
comment : |
Represents assigning to an instance variable using an operator that isn't `=`.
@target += value
^^^^^^^^^^^^^^^^
- name : InstanceVariableOrWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-29 16:17:34 +03:00
- name : name
type : constant
2023-08-25 17:49:00 +03:00
- name : name_loc
type : location
- name : operator_loc
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-25 17:49:00 +03:00
comment : |
Represents the use of the `||=` operator for assignment to an instance variable.
@target ||= value
^^^^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : InstanceVariableReadNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-29 16:17:34 +03:00
- name : name
type : constant
2024-01-08 22:55:07 +03:00
comment : |
2024-01-19 19:22:40 +03:00
The name of the instance variable, which is a `@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
2024-01-08 22:55:07 +03:00
@x # name `:@x`
@_test # name `:@_test`
2023-08-18 00:39:04 +03:00
comment : |
Represents referencing an instance variable.
@foo
^^^^
2023-08-25 18:57:37 +03:00
- name : InstanceVariableTargetNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-29 16:17:34 +03:00
- name : name
type : constant
2023-08-25 18:57:37 +03:00
comment : |
Represents writing to an instance variable in a context that doesn't have an explicit value.
@foo, @bar = baz
^^^^ ^^^^
2023-08-18 00:39:04 +03:00
- name : InstanceVariableWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-29 16:17:34 +03:00
- name : name
type : constant
2024-03-11 22:46:25 +03:00
comment : |
The name of the instance variable, which is a `@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
@x = :y # name `:@x`
@_foo = "bar" # name `@_foo`
2023-08-18 00:39:04 +03:00
- name : name_loc
type : location
2024-03-11 22:46:25 +03:00
comment : |
The location of the variable name.
@_x = 1
^^^
2023-08-18 00:39:04 +03:00
- name : value
2023-08-25 20:03:16 +03:00
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-03-11 22:46:25 +03:00
comment : |
2024-04-26 22:03:07 +03:00
The value to write to the instance variable. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
2024-03-11 22:46:25 +03:00
@foo = :bar
^^^^
@_x = 1234
^^^^
2023-08-18 00:39:04 +03:00
- name : operator_loc
2023-08-25 20:03:16 +03:00
type : location
2024-03-11 22:46:25 +03:00
comment : |
The location of the `=` operator.
@x = y
^
2023-08-18 00:39:04 +03:00
comment : |
Represents writing to an instance variable.
@foo = 1
^^^^^^^^
- name : IntegerNode
2024-07-02 22:43:01 +03:00
flags : IntegerBaseFlags
2023-09-11 19:05:14 +03:00
fields :
2024-02-22 18:55:29 +03:00
- name : value
type : integer
comment : The value of the integer literal as a number.
2023-08-18 00:39:04 +03:00
comment : |
Represents an integer number literal.
1
^
2023-09-11 19:32:25 +03:00
- name : InterpolatedMatchLastLineNode
2024-07-02 22:43:01 +03:00
flags : RegularExpressionFlags
2023-09-11 19:32:25 +03:00
fields :
- name : opening_loc
type : location
- name : parts
type : node[]
2024-02-25 15:04:42 +03:00
kind :
- StringNode
- EmbeddedStatementsNode
- EmbeddedVariableNode
2023-09-11 19:32:25 +03:00
- name : closing_loc
type : location
newline : parts
comment : |
2024-01-19 19:22:40 +03:00
Represents a regular expression literal that contains interpolation that is being used in the predicate of a conditional to implicitly match against the last line read by an IO object.
2023-09-11 19:32:25 +03:00
if /foo #{bar} baz/ then end
^^^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : InterpolatedRegularExpressionNode
2024-07-02 22:43:01 +03:00
flags : RegularExpressionFlags
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location
- name : parts
type : node[]
2024-02-25 15:04:42 +03:00
kind :
- StringNode
- EmbeddedStatementsNode
- EmbeddedVariableNode
2023-08-18 00:39:04 +03:00
- name : closing_loc
type : location
newline : parts
comment : |
Represents a regular expression literal that contains interpolation.
/foo #{bar} baz/
^^^^^^^^^^^^^^^^
- name : InterpolatedStringNode
2024-07-02 22:43:01 +03:00
flags : InterpolatedStringNodeFlags
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location?
- name : parts
type : node[]
2024-02-25 15:04:42 +03:00
kind :
- StringNode
- EmbeddedStatementsNode
- EmbeddedVariableNode
- InterpolatedStringNode # `"a" "#{b}"`
2023-08-18 00:39:04 +03:00
- name : closing_loc
type : location?
newline : parts
comment : |
Represents a string literal that contains interpolation.
"foo #{bar} baz"
^^^^^^^^^^^^^^^^
- name : InterpolatedSymbolNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location?
- name : parts
type : node[]
2024-02-25 15:04:42 +03:00
kind :
- StringNode
- EmbeddedStatementsNode
- EmbeddedVariableNode
2023-08-18 00:39:04 +03:00
- name : closing_loc
type : location?
newline : parts
comment : |
Represents a symbol literal that contains interpolation.
: "foo #{bar} baz"
^^^^^^^^^^^^^^^^^
- name : InterpolatedXStringNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location
- name : parts
type : node[]
2024-02-25 15:04:42 +03:00
kind :
- StringNode
- EmbeddedStatementsNode
- EmbeddedVariableNode
2023-08-18 00:39:04 +03:00
- name : closing_loc
type : location
newline : parts
comment : |
Represents an xstring literal that contains interpolation.
`foo #{bar} baz`
^^^^^^^^^^^^^^^^
2024-05-22 21:31:38 +03:00
- name : ItLocalVariableReadNode
comment : |
Represents reading from the implicit `it` local variable.
-> { it }
^^
2024-02-21 22:11:50 +03:00
- name : ItParametersNode
comment : |
Represents an implicit set of parameters through the use of the `it` keyword within a block or lambda.
-> { it + it }
^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : KeywordHashNode
2024-07-02 22:43:01 +03:00
flags : KeywordHashNodeFlags
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : elements
type : node[]
2024-02-25 15:04:42 +03:00
kind :
- AssocNode
- AssocSplatNode
2023-08-18 00:39:04 +03:00
comment : |
Represents a hash literal without opening and closing braces.
foo(a : b)
^^^^
- name : KeywordRestParameterNode
2024-07-02 22:43:01 +03:00
flags : ParameterFlags
2023-08-30 23:09:51 +03:00
fields :
2023-09-06 18:14:38 +03:00
- name : name
type : constant?
2023-08-18 00:39:04 +03:00
- name : name_loc
type : location?
2023-09-06 18:14:38 +03:00
- name : operator_loc
type : location
2023-08-18 00:39:04 +03:00
comment : |
Represents a keyword rest parameter to a method, block, or lambda definition.
def a(**b)
^^^
end
- name : LambdaNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : locals
type : constant[]
2023-08-22 04:12:52 +03:00
- name : operator_loc
type : location
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location
2023-08-22 04:12:52 +03:00
- name : closing_loc
type : location
2023-08-18 00:39:04 +03:00
- name : parameters
type : node?
2024-08-28 23:32:30 +03:00
kind :
- BlockParametersNode
- NumberedParametersNode
- ItParametersNode
2023-08-19 03:47:58 +03:00
- name : body
2023-08-18 00:39:04 +03:00
type : node?
2024-08-28 23:32:30 +03:00
kind :
- StatementsNode
- BeginNode
2023-08-18 00:39:04 +03:00
comment : |
Represents using a lambda literal (not the lambda method call).
->(value) { value * 2 }
^^^^^^^^^^^^^^^^^^^^^^^
2023-08-25 17:49:00 +03:00
- name : LocalVariableAndWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-25 17:49:00 +03:00
- name : name_loc
type : location
- name : operator_loc
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-27 18:56:53 +03:00
- name : name
2023-08-25 17:49:00 +03:00
type : constant
- name : depth
type : uint32
comment : |
Represents the use of the `&&=` operator for assignment to a local variable.
target &&= value
^^^^^^^^^^^^^^^^
- name : LocalVariableOperatorWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-25 17:49:00 +03:00
- name : name_loc
type : location
2024-05-10 17:19:11 +03:00
- name : binary_operator_loc
2023-08-25 17:49:00 +03:00
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-27 18:56:53 +03:00
- name : name
2023-08-25 17:49:00 +03:00
type : constant
2024-05-10 17:19:11 +03:00
- name : binary_operator
2023-08-25 17:49:00 +03:00
type : constant
- name : depth
type : uint32
comment : |
Represents assigning to a local variable using an operator that isn't `=`.
target += value
^^^^^^^^^^^^^^^
- name : LocalVariableOrWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-25 17:49:00 +03:00
- name : name_loc
type : location
- name : operator_loc
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-27 18:56:53 +03:00
- name : name
2023-08-25 17:49:00 +03:00
type : constant
- name : depth
type : uint32
comment : |
Represents the use of the `||=` operator for assignment to a local variable.
target ||= value
^^^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : LocalVariableReadNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-27 18:56:53 +03:00
- name : name
2023-08-18 00:39:04 +03:00
type : constant
2024-01-08 23:51:21 +03:00
comment : |
2024-01-19 19:22:40 +03:00
The name of the local variable, which is an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
2024-01-08 23:51:21 +03:00
x # name `:x`
_Test # name `:_Test`
2024-01-19 19:12:12 +03:00
2024-01-19 19:22:40 +03:00
Note that this can also be an underscore followed by a number for the default block parameters.
2024-01-19 19:12:34 +03:00
2024-01-19 19:12:12 +03:00
_1 # name `:_1`
2023-08-18 00:39:04 +03:00
- name : depth
type : uint32
2024-01-08 23:51:21 +03:00
comment : |
2024-01-19 19:22:40 +03:00
The number of visible scopes that should be searched to find the origin of this local variable.
2024-01-08 23:51:21 +03:00
foo = 1; foo # depth 0
bar = 2; tap { bar } # depth 1
2024-01-19 19:22:40 +03:00
The specific rules for calculating the depth may differ from individual Ruby implementations, as they are not specified by the language. For more information, see [the Prism documentation](https://github.com/ruby/prism/blob/main/docs/local_variable_depth.md).
2023-08-18 00:39:04 +03:00
comment : |
2024-01-19 19:22:40 +03:00
Represents reading a local variable. Note that this requires that a local variable of the same name has already been written to in the same scope, otherwise it is parsed as a method call.
2023-08-18 00:39:04 +03:00
foo
^^^
2023-08-25 18:57:37 +03:00
- name : LocalVariableTargetNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-27 18:56:53 +03:00
- name : name
2023-08-25 18:57:37 +03:00
type : constant
- name : depth
type : uint32
comment : |
Represents writing to a local variable in a context that doesn't have an explicit value.
foo, bar = baz
^^^ ^^^
2023-08-18 00:39:04 +03:00
- name : LocalVariableWriteNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-27 18:56:53 +03:00
- name : name
2023-08-18 00:39:04 +03:00
type : constant
2024-04-26 22:03:07 +03:00
comment : |
The name of the local variable, which is an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
foo = :bar # name `:foo`
abc = 123 # name `:abc`
2023-08-18 00:39:04 +03:00
- name : depth
type : uint32
2024-04-26 22:03:07 +03:00
comment : |
The number of semantic scopes we have to traverse to find the declaration of this variable.
foo = 1 # depth 0
tap { foo = 1 } # depth 1
The specific rules for calculating the depth may differ from individual Ruby implementations, as they are not specified by the language. For more information, see [the Prism documentation](https://github.com/ruby/prism/blob/main/docs/local_variable_depth.md).
2023-08-18 00:39:04 +03:00
- name : name_loc
type : location
2024-04-26 22:03:07 +03:00
comment : |
The location of the variable name.
foo = :bar
^^^
2023-08-30 23:48:17 +03:00
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-04-26 22:03:07 +03:00
comment : |
The value to write to the local variable. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
foo = :bar
^^^^
abc = 1234
^^^^
Note that since the name of a local variable is known before the value is parsed, it is valid for a local variable to appear within the value of its own write.
foo = foo
2023-08-18 00:39:04 +03:00
- name : operator_loc
2023-08-25 20:03:16 +03:00
type : location
2024-04-26 22:03:07 +03:00
comment : |
The location of the `=` operator.
x = :y
^
2023-08-18 00:39:04 +03:00
comment : |
Represents writing to a local variable.
foo = 1
^^^^^^^
2023-09-11 19:32:25 +03:00
- name : MatchLastLineNode
2024-07-02 22:43:01 +03:00
flags : RegularExpressionFlags
2023-09-11 19:32:25 +03:00
fields :
- name : opening_loc
type : location
- name : content_loc
type : location
- name : closing_loc
type : location
- name : unescaped
type : string
comment : |
2024-01-19 19:22:40 +03:00
Represents a regular expression literal used in the predicate of a conditional to implicitly match against the last line read by an IO object.
2023-09-11 19:32:25 +03:00
if /foo/i then end
^^^^^^
2023-08-18 00:39:04 +03:00
- name : MatchPredicateNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-18 00:39:04 +03:00
- name : pattern
type : node
2024-08-28 23:32:30 +03:00
kind : pattern expression
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location
comment : |
Represents the use of the modifier `in` operator.
foo in bar
^^^^^^^^^^
- name : MatchRequiredNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-18 00:39:04 +03:00
- name : pattern
type : node
2024-08-28 23:32:30 +03:00
kind : pattern expression
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location
comment : |
Represents the use of the `=>` operator.
foo => bar
^^^^^^^^^^
2023-09-14 16:01:20 +03:00
- name : MatchWriteNode
fields :
- name : call
type : node
kind : CallNode
2023-11-10 06:59:35 +03:00
- name : targets
type : node[]
2024-02-25 15:04:42 +03:00
kind : LocalVariableTargetNode
2023-09-14 16:01:20 +03:00
comment : |
2024-01-19 19:22:40 +03:00
Represents writing local variables using a regular expression match with named capture groups.
2023-09-14 16:01:20 +03:00
/(?<foo>bar)/ =~ baz
^^^^^^^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : MissingNode
comment : |
2024-01-19 19:22:40 +03:00
Represents a node that is missing from the source and results in a syntax error.
2023-08-18 00:39:04 +03:00
- name : ModuleNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : locals
type : constant[]
- name : module_keyword_loc
type : location
- name : constant_path
type : node
2024-08-28 23:32:30 +03:00
kind :
- ConstantReadNode
- ConstantPathNode
- on error : MissingNode # module Parent module end
2023-08-19 03:47:58 +03:00
- name : body
2023-08-18 00:39:04 +03:00
type : node?
2024-08-28 23:32:30 +03:00
kind :
- StatementsNode
- BeginNode
2023-08-18 00:39:04 +03:00
- name : end_keyword_loc
type : location
2023-08-25 04:22:20 +03:00
- name : name
2023-09-06 19:19:38 +03:00
type : constant
2023-08-18 00:39:04 +03:00
comment : |
Represents a module declaration involving the `module` keyword.
module Foo end
^^^^^^^^^^^^^^
2023-09-07 20:00:45 +03:00
- name : MultiTargetNode
2023-08-30 23:09:51 +03:00
fields :
2023-10-26 21:56:21 +03:00
- name : lefts
2023-10-23 19:06:21 +03:00
type : node[]
2024-02-25 15:04:42 +03:00
kind :
- LocalVariableTargetNode
- InstanceVariableTargetNode
- ClassVariableTargetNode
- GlobalVariableTargetNode
- ConstantTargetNode
- ConstantPathTargetNode
- CallTargetNode
- IndexTargetNode
- MultiTargetNode
2024-08-28 23:32:30 +03:00
- RequiredParameterNode # def m((a,b)); end
- on error : BackReferenceReadNode # a, (b, $&) = z
- on error : NumberedReferenceReadNode # a, (b, $1) = z
2024-06-15 13:21:58 +03:00
comment : |
Represents the targets expressions before a splat node.
a, (b, c, *) = 1, 2, 3, 4, 5
^^^^
The splat node can be absent, in that case all target expressions are in the left field.
a, (b, c) = 1, 2, 3, 4, 5
^^^^
2023-10-23 19:06:21 +03:00
- name : rest
type : node?
2024-06-15 13:21:58 +03:00
kind :
- ImplicitRestNode
- SplatNode
comment : |
Represents a splat node in the target expression.
a, (b, *c) = 1, 2, 3, 4
^^
The variable can be empty, this results in a `SplatNode` with a `nil` expression field.
a, (b, *) = 1, 2, 3, 4
^
2024-09-04 16:03:19 +03:00
If the `*` is omitted, this field will contain an `ImplicitRestNode`
2024-06-15 13:21:58 +03:00
a, (b,) = 1, 2, 3, 4
^
2023-10-26 21:56:21 +03:00
- name : rights
2023-08-18 00:39:04 +03:00
type : node[]
2024-02-25 15:04:42 +03:00
kind :
- LocalVariableTargetNode
- InstanceVariableTargetNode
- ClassVariableTargetNode
- GlobalVariableTargetNode
- ConstantTargetNode
- ConstantPathTargetNode
- CallTargetNode
- IndexTargetNode
- MultiTargetNode
2024-08-28 23:32:30 +03:00
- RequiredParameterNode # def m((*,b)); end
- on error : BackReferenceReadNode # a, (*, $&) = z
- on error : NumberedReferenceReadNode # a, (*, $1) = z
2024-06-15 13:21:58 +03:00
comment : |
Represents the targets expressions after a splat node.
a, (*, b, c) = 1, 2, 3, 4, 5
^^^^
2023-08-18 00:39:04 +03:00
- name : lparen_loc
type : location?
2024-06-15 13:21:58 +03:00
comment : |
The location of the opening parenthesis.
a, (b, c) = 1, 2, 3
^
2023-08-18 00:39:04 +03:00
- name : rparen_loc
type : location?
2024-06-15 13:21:58 +03:00
comment : |
The location of the closing parenthesis.
a, (b, c) = 1, 2, 3
^
2023-08-18 00:39:04 +03:00
comment : |
Represents a multi-target expression.
2023-10-26 21:02:27 +03:00
a, (b, c) = 1, 2, 3
^^^^^^
2024-06-15 13:21:58 +03:00
This can be a part of `MultiWriteNode` as above, or the target of a `for` loop
for a, b in [[1, 2], [3, 4]]
^^^^
2023-09-07 20:00:45 +03:00
- name : MultiWriteNode
fields :
2023-10-26 21:56:21 +03:00
- name : lefts
2023-10-23 19:06:21 +03:00
type : node[]
2024-02-25 15:04:42 +03:00
kind :
- LocalVariableTargetNode
- InstanceVariableTargetNode
- ClassVariableTargetNode
- GlobalVariableTargetNode
- ConstantTargetNode
- ConstantPathTargetNode
- CallTargetNode
- IndexTargetNode
- MultiTargetNode
2024-08-28 23:32:30 +03:00
- on error : BackReferenceReadNode # $&, = z
- on error : NumberedReferenceReadNode # $1, = z
2024-06-15 15:54:43 +03:00
comment : |
Represents the targets expressions before a splat node.
a, b, * = 1, 2, 3, 4, 5
^^^^
The splat node can be absent, in that case all target expressions are in the left field.
a, b, c = 1, 2, 3, 4, 5
^^^^^^^
2023-10-23 19:06:21 +03:00
- name : rest
type : node?
2024-06-15 15:54:43 +03:00
kind :
- ImplicitRestNode
- SplatNode
comment : |
Represents a splat node in the target expression.
a, b, *c = 1, 2, 3, 4
^^
The variable can be empty, this results in a `SplatNode` with a `nil` expression field.
a, b, * = 1, 2, 3, 4
^
2024-09-04 16:03:22 +03:00
If the `*` is omitted, this field will contain an `ImplicitRestNode`
2024-06-15 15:54:43 +03:00
a, b, = 1, 2, 3, 4
^
2023-10-26 21:56:21 +03:00
- name : rights
2023-09-07 21:20:18 +03:00
type : node[]
2024-02-25 15:04:42 +03:00
kind :
- LocalVariableTargetNode
- InstanceVariableTargetNode
- ClassVariableTargetNode
- GlobalVariableTargetNode
- ConstantTargetNode
- ConstantPathTargetNode
- CallTargetNode
- IndexTargetNode
- MultiTargetNode
2024-08-28 23:32:30 +03:00
- on error : BackReferenceReadNode # *, $& = z
- on error : NumberedReferenceReadNode # *, $1 = z
2024-06-15 15:54:43 +03:00
comment : |
Represents the targets expressions after a splat node.
a, *, b, c = 1, 2, 3, 4, 5
^^^^
2023-09-07 21:20:18 +03:00
- name : lparen_loc
type : location?
2024-06-15 15:54:43 +03:00
comment : |
The location of the opening parenthesis.
(a, b, c) = 1, 2, 3
^
2023-09-07 21:20:18 +03:00
- name : rparen_loc
type : location?
2024-06-15 15:54:43 +03:00
comment : |
The location of the closing parenthesis.
(a, b, c) = 1, 2, 3
^
2023-09-07 20:00:45 +03:00
- name : operator_loc
type : location
2024-06-15 15:54:43 +03:00
comment : |
The location of the operator.
a, b, c = 1, 2, 3
^
2023-09-07 20:00:45 +03:00
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-06-15 15:54:43 +03:00
comment : |
The value to write to the targets. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
a, b, c = 1, 2, 3
^^^^^^^
2023-09-07 20:00:45 +03:00
comment : |
Represents a write to a multi-target expression.
2023-08-18 00:39:04 +03:00
a, b, c = 1, 2, 3
^^^^^^^^^^^^^^^^^
- name : NextNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : arguments
type : node?
kind : ArgumentsNode
- name : keyword_loc
type : location
comment : |
Represents the use of the `next` keyword.
next 1
^^^^^^
- name : NilNode
comment : |
Represents the use of the `nil` keyword.
nil
^^^
- name : NoKeywordsParameterNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location
- name : keyword_loc
type : location
comment : |
Represents the use of `**nil` inside method arguments.
def a(**nil)
^^^^^
end
2023-12-01 04:47:08 +03:00
- name : NumberedParametersNode
fields :
- name : maximum
type : uint8
comment : |
2024-01-19 19:22:40 +03:00
Represents an implicit set of parameters through the use of numbered parameters within a block or lambda.
2023-12-01 04:47:08 +03:00
-> { _1 + _2 }
^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : NumberedReferenceReadNode
2023-08-31 00:21:50 +03:00
fields :
- name : number
type : uint32
2024-01-08 23:34:11 +03:00
comment : |
2024-03-13 21:22:31 +03:00
The (1-indexed, from the left) number of the capture group. Numbered references that are too large result in this value being `0`.
2024-01-08 23:34:11 +03:00
$1 # number `1`
$5432 # number `5432`
2024-03-13 21:22:31 +03:00
$4294967296 # number `0`
2023-08-18 00:39:04 +03:00
comment : |
Represents reading a numbered reference to a capture in the previous match.
$1
^^
2023-10-31 23:00:28 +03:00
- name : OptionalKeywordParameterNode
2024-07-02 22:43:01 +03:00
flags : ParameterFlags
2023-10-31 23:00:28 +03:00
fields :
- name : name
type : constant
- name : name_loc
type : location
2023-11-01 15:36:15 +03:00
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-10-31 23:00:28 +03:00
comment : |
Represents an optional keyword parameter to a method, block, or lambda definition.
2023-11-01 15:36:15 +03:00
def a(b : 1 )
^^^^
2023-10-31 23:00:28 +03:00
end
2023-08-18 00:39:04 +03:00
- name : OptionalParameterNode
2024-07-02 22:43:01 +03:00
flags : ParameterFlags
2023-08-30 23:09:51 +03:00
fields :
2023-08-27 18:56:53 +03:00
- name : name
2023-08-18 00:39:04 +03:00
type : constant
- name : name_loc
type : location
- name : operator_loc
type : location
- name : value
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-18 00:39:04 +03:00
comment : |
Represents an optional parameter to a method, block, or lambda definition.
def a(b = 1)
^^^^^
end
- name : OrNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : left
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-01-14 11:58:30 +03:00
comment : |
2024-01-19 19:22:40 +03:00
Represents the left side of the expression. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
2024-01-14 11:58:30 +03:00
2024-01-17 20:42:44 +03:00
left or right
^^^^
1 || 2
^
2023-08-18 00:39:04 +03:00
- name : right
type : node
2024-08-28 23:32:30 +03:00
kind : Node
2024-01-14 11:58:30 +03:00
comment : |
2024-08-28 23:32:30 +03:00
Represents the right side of the expression.
2024-01-14 11:58:30 +03:00
2024-01-17 20:42:44 +03:00
left || right
^^^^^
1 or 2
^
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location
2024-01-14 11:58:30 +03:00
comment : |
2024-01-17 20:42:44 +03:00
The location of the `or` keyword or the `||` operator.
2024-01-14 11:58:30 +03:00
2024-01-17 20:42:44 +03:00
left or right
^^
2023-08-18 00:39:04 +03:00
comment : |
Represents the use of the `||` operator or the `or` keyword.
left or right
^^^^^^^^^^^^^
- name : ParametersNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : requireds
type : node[]
2023-12-21 07:41:52 +03:00
kind :
- RequiredParameterNode
- MultiTargetNode
2023-08-18 00:39:04 +03:00
- name : optionals
type : node[]
2023-12-21 07:41:52 +03:00
kind : OptionalParameterNode
2023-08-18 00:39:04 +03:00
- name : rest
type : node?
2023-12-21 07:41:52 +03:00
kind :
- RestParameterNode
- ImplicitRestNode # Only in block parameters
2023-09-12 13:36:12 +03:00
- name : posts
type : node[]
2023-12-21 07:41:52 +03:00
kind :
- RequiredParameterNode
- MultiTargetNode
# On parsing error of `f(**kwargs, ...)` or `f(**nil, ...)`, the keyword_rest value is moved here:
2024-08-28 23:32:30 +03:00
- on error : KeywordRestParameterNode
- on error : NoKeywordsParameterNode
2024-05-10 18:39:51 +03:00
# On parsing error of `f(..., ...)`, the first forwarding parameter is moved here:
2024-08-28 23:32:30 +03:00
- on error : ForwardingParameterNode
2023-08-18 00:39:04 +03:00
- name : keywords
type : node[]
2023-12-21 07:41:52 +03:00
kind :
- RequiredKeywordParameterNode
- OptionalKeywordParameterNode
2023-08-18 00:39:04 +03:00
- name : keyword_rest
type : node?
2023-12-21 07:41:52 +03:00
kind :
- KeywordRestParameterNode
- ForwardingParameterNode
- NoKeywordsParameterNode
2023-08-18 00:39:04 +03:00
- name : block
type : node?
kind : BlockParameterNode
comment : |
Represents the list of parameters on a method, block, or lambda definition.
def a(b, c, d)
^^^^^^^
end
- name : ParenthesesNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-19 03:47:58 +03:00
- name : body
2023-08-18 00:39:04 +03:00
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression # Usually a StatementsNode but not always e.g. `1 in (..10)`
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location
- name : closing_loc
type : location
newline : false
comment : |
Represents a parenthesized expression
(10 + 34)
^^^^^^^^^
- name : PinnedExpressionNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : expression
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location
- name : lparen_loc
type : location
- name : rparen_loc
type : location
comment : |
2024-01-19 19:22:40 +03:00
Represents the use of the `^` operator for pinning an expression in a pattern matching expression.
2023-08-18 00:39:04 +03:00
foo in ^(bar)
^^^^^^
- name : PinnedVariableNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : variable
type : node
2024-08-28 23:32:30 +03:00
kind :
- LocalVariableReadNode
- InstanceVariableReadNode
- ClassVariableReadNode
- GlobalVariableReadNode # foo in ^$a
- BackReferenceReadNode # foo in ^$&
- NumberedReferenceReadNode # foo in ^$1
- ItLocalVariableReadNode # proc { 1 in ^it }
- on error : MissingNode # foo in ^Bar
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location
comment : |
2024-01-19 19:22:40 +03:00
Represents the use of the `^` operator for pinning a variable in a pattern matching expression.
2023-08-18 00:39:04 +03:00
foo in ^bar
^^^^
- name : PostExecutionNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : statements
type : node?
kind : StatementsNode
- name : keyword_loc
type : location
- name : opening_loc
type : location
- name : closing_loc
type : location
comment : |
Represents the use of the `END` keyword.
END { foo }
^^^^^^^^^^^
- name : PreExecutionNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : statements
type : node?
kind : StatementsNode
- name : keyword_loc
type : location
- name : opening_loc
type : location
- name : closing_loc
type : location
comment : |
Represents the use of the `BEGIN` keyword.
BEGIN { foo }
^^^^^^^^^^^^^
- name : ProgramNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : locals
type : constant[]
- name : statements
type : node
kind : StatementsNode
comment : The top level node of any parse tree.
- name : RangeNode
2024-07-02 22:43:01 +03:00
flags : RangeFlags
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : left
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-01-07 15:54:43 +03:00
comment : |
2024-01-19 19:22:40 +03:00
The left-hand side of the range, if present. It can be either `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
2024-01-08 17:52:58 +03:00
2024-01-07 15:54:43 +03:00
1 ...
^
hello...goodbye
^^^^^
2023-08-18 00:39:04 +03:00
- name : right
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-01-08 18:01:01 +03:00
comment : |
2024-01-19 19:22:40 +03:00
The right-hand side of the range, if present. It can be either `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
2024-01-07 15:54:43 +03:00
..5
^
1 ...foo
^^^
2024-01-19 19:22:40 +03:00
If neither right-hand or left-hand side was included, this will be a MissingNode.
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location
2024-01-07 15:54:43 +03:00
comment : |
The location of the `..` or `...` operator.
2023-08-18 00:39:04 +03:00
comment : |
Represents the use of the `..` or `...` operators.
1 ..2
^^^^
c if a =~ /left/ ... b =~ /right/
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- name : RationalNode
2024-07-02 22:43:01 +03:00
flags : IntegerBaseFlags
2023-08-30 23:09:51 +03:00
fields :
2024-05-08 22:32:24 +03:00
- name : numerator
type : integer
comment : |
The numerator of the rational number.
1. 5r # numerator 3
- name : denominator
type : integer
comment : |
The denominator of the rational number.
1. 5r # denominator 2
2023-08-18 00:39:04 +03:00
comment : |
Represents a rational number literal.
1. 0r
^^^^
- name : RedoNode
comment : |
Represents the use of the `redo` keyword.
redo
^^^^
- name : RegularExpressionNode
2024-07-02 22:43:01 +03:00
flags : RegularExpressionFlags
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location
- name : content_loc
type : location
- name : closing_loc
type : location
- name : unescaped
type : string
comment : |
Represents a regular expression literal with no interpolation.
/foo/i
^^^^^^
2023-10-31 23:00:28 +03:00
- name : RequiredKeywordParameterNode
2024-07-02 22:43:01 +03:00
flags : ParameterFlags
2023-10-31 23:00:28 +03:00
fields :
- name : name
type : constant
- name : name_loc
type : location
comment : |
Represents a required keyword parameter to a method, block, or lambda definition.
2023-11-01 15:36:15 +03:00
def a(b : )
^^
2023-10-31 23:00:28 +03:00
end
2023-08-18 00:39:04 +03:00
- name : RequiredParameterNode
2024-07-02 22:43:01 +03:00
flags : ParameterFlags
2023-08-30 23:09:51 +03:00
fields :
2023-08-27 18:56:53 +03:00
- name : name
2023-08-18 00:39:04 +03:00
type : constant
comment : |
Represents a required parameter to a method, block, or lambda definition.
def a(b)
^
end
- name : RescueModifierNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : expression
type : node
2024-08-28 23:32:30 +03:00
kind : Node
2023-08-18 00:39:04 +03:00
- name : keyword_loc
type : location
- name : rescue_expression
type : node
2024-08-28 23:32:30 +03:00
kind : Node
2023-08-18 00:39:04 +03:00
newline : expression
comment : |
Represents an expression modified with a rescue.
2023-11-01 20:02:04 +03:00
foo rescue nil
^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : RescueNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : keyword_loc
type : location
- name : exceptions
type : node[]
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location?
- name : reference
type : node?
2024-08-28 23:32:30 +03:00
kind :
- LocalVariableTargetNode
- InstanceVariableTargetNode
- ClassVariableTargetNode
- GlobalVariableTargetNode
- ConstantTargetNode
- ConstantPathTargetNode
- CallTargetNode
- IndexTargetNode
- on error : BackReferenceReadNode # => begin; rescue => $&; end
- on error : NumberedReferenceReadNode # => begin; rescue => $1; end
- on error : MissingNode # begin; rescue =>; end
2023-08-18 00:39:04 +03:00
- name : statements
type : node?
kind : StatementsNode
2024-08-28 21:11:41 +03:00
- name : subsequent
2023-08-18 00:39:04 +03:00
type : node?
kind : RescueNode
comment : |
Represents a rescue statement.
begin
rescue Foo, *splat, Bar => ex
foo
2023-10-30 20:01:35 +03:00
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
end
2024-10-09 23:12:14 +03:00
`Foo, *splat, Bar` are in the `exceptions` field. `ex` is in the `reference` field.
2023-08-18 00:39:04 +03:00
- name : RestParameterNode
2024-07-02 22:43:01 +03:00
flags : ParameterFlags
2023-08-30 23:09:51 +03:00
fields :
2023-09-06 18:22:27 +03:00
- name : name
type : constant?
2023-08-18 00:39:04 +03:00
- name : name_loc
type : location?
2023-09-06 18:22:27 +03:00
- name : operator_loc
type : location
2023-08-18 00:39:04 +03:00
comment : |
Represents a rest parameter to a method, block, or lambda definition.
def a(*b)
^^
end
- name : RetryNode
comment : |
Represents the use of the `retry` keyword.
retry
^^^^^
- name : ReturnNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : keyword_loc
type : location
- name : arguments
type : node?
kind : ArgumentsNode
comment : |
Represents the use of the `return` keyword.
return 1
^^^^^^^^
- name : SelfNode
comment : |
Represents the `self` keyword.
self
^^^^
2024-03-15 04:37:16 +03:00
- name : ShareableConstantNode
2024-07-02 22:43:01 +03:00
flags : ShareableConstantNodeFlags
2024-03-15 04:37:16 +03:00
fields :
- name : write
type : node
kind :
- ConstantWriteNode
- ConstantAndWriteNode
- ConstantOrWriteNode
- ConstantOperatorWriteNode
- ConstantPathWriteNode
- ConstantPathAndWriteNode
- ConstantPathOrWriteNode
- ConstantPathOperatorWriteNode
comment : The constant write that should be modified with the shareability state.
comment : |
This node wraps a constant write to indicate that when the value is written, it should have its shareability state modified.
# shareable_constant_value: literal
C = { a: 1 }
^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : SingletonClassNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : locals
type : constant[]
- name : class_keyword_loc
type : location
- name : operator_loc
type : location
- name : expression
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-19 03:47:58 +03:00
- name : body
2023-08-18 00:39:04 +03:00
type : node?
2024-08-28 23:32:30 +03:00
kind :
- StatementsNode
- BeginNode
2023-08-18 00:39:04 +03:00
- name : end_keyword_loc
type : location
comment : |
Represents a singleton class declaration involving the `class` keyword.
class << self end
^^^^^^^^^^^^^^^^^
- name : SourceEncodingNode
comment : |
Represents the use of the `__ENCODING__` keyword.
__ENCODING__
^^^^^^^^^^^^
- name : SourceFileNode
2024-07-02 22:43:01 +03:00
flags : StringFlags
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : filepath
type : string
2024-01-04 03:52:10 +03:00
comment : Represents the file path being parsed. This corresponds directly to the `filepath` option given to the various `Prism::parse*` APIs.
2023-08-18 00:39:04 +03:00
comment : |
Represents the use of the `__FILE__` keyword.
__FILE__
^^^^^^^^
- name : SourceLineNode
comment : |
Represents the use of the `__LINE__` keyword.
__LINE__
^^^^^^^^
- name : SplatNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location
- name : expression
type : node?
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-18 00:39:04 +03:00
comment : |
Represents the use of the splat operator.
[ *a]
^^
- name : StatementsNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : body
type : node[]
2024-08-28 23:32:30 +03:00
kind : Node
2023-08-18 00:39:04 +03:00
comment : |
Represents a set of statements contained within some scope.
foo; bar; baz
^^^^^^^^^^^^^
- name : StringNode
2024-07-02 22:43:01 +03:00
flags : StringFlags
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location?
- name : content_loc
type : location
- name : closing_loc
type : location?
- name : unescaped
type : string
comment : |
2024-01-19 19:22:40 +03:00
Represents a string literal, a string contained within a `%w` list, or plain string content within an interpolated string.
2023-08-18 00:39:04 +03:00
"foo"
^^^^^
%w[foo]
^^^
"foo #{bar} baz"
^^^^ ^^^^
- name : SuperNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : keyword_loc
type : location
- name : lparen_loc
type : location?
- name : arguments
type : node?
kind : ArgumentsNode
- name : rparen_loc
type : location?
- name : block
type : node?
2024-08-28 23:32:30 +03:00
kind :
- BlockNode
- BlockArgumentNode
2023-08-18 00:39:04 +03:00
comment : |
Represents the use of the `super` keyword with parentheses or arguments.
super()
^^^^^^^
super foo, bar
^^^^^^^^^^^^^^
- name : SymbolNode
2024-07-02 22:43:01 +03:00
flags : SymbolFlags
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location?
- name : value_loc
2023-08-22 04:00:00 +03:00
type : location?
2023-08-18 00:39:04 +03:00
- name : closing_loc
type : location?
- name : unescaped
type : string
comment : |
Represents a symbol literal or a symbol contained within a `%i` list.
: foo
^^^^
%i[foo]
^^^
- name : TrueNode
comment : |
Represents the use of the literal `true` keyword.
true
^^^^
- name : UndefNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : names
type : node[]
2024-02-25 15:04:42 +03:00
kind :
- SymbolNode
- InterpolatedSymbolNode
2023-08-18 00:39:04 +03:00
- name : keyword_loc
type : location
comment : |
Represents the use of the `undef` keyword.
undef :foo, :bar, :baz
^^^^^^^^^^^^^^^^^^^^^^
- name : UnlessNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : keyword_loc
type : location
2024-01-19 17:19:28 +03:00
comment : |
The location of the `unless` keyword.
unless cond then bar end
^^^^^^
bar unless cond
^^^^^^
2023-08-18 00:39:04 +03:00
- name : predicate
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-01-19 17:19:28 +03:00
comment : |
2024-04-26 22:03:07 +03:00
The condition to be evaluated for the unless expression. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
2024-01-19 17:19:28 +03:00
unless cond then bar end
^^^^
bar unless cond
^^^^
2023-11-16 01:55:16 +03:00
- name : then_keyword_loc
type : location?
2024-05-29 16:36:06 +03:00
comment : |
2024-01-19 17:19:28 +03:00
The location of the `then` keyword, if present.
unless cond then bar end
^^^^
2023-08-18 00:39:04 +03:00
- name : statements
type : node?
kind : StatementsNode
2024-01-19 17:19:28 +03:00
comment : |
The body of statements that will executed if the unless condition is
falsey. Will be `nil` if no body is provided.
unless cond then bar end
^^^
2024-08-28 21:11:41 +03:00
- name : else_clause
2023-08-18 00:39:04 +03:00
type : node?
kind : ElseNode
2024-01-19 17:19:28 +03:00
comment : |
The else clause of the unless expression, if present.
unless cond then bar else baz end
^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : end_keyword_loc
type : location?
2024-01-19 17:19:28 +03:00
comment : |
The location of the `end` keyword, if present.
unless cond then bar end
^^^
2023-08-18 00:39:04 +03:00
newline : predicate
comment : |
Represents the use of the `unless` keyword, either in the block form or the modifier form.
bar unless foo
^^^^^^^^^^^^^^
unless foo then bar end
^^^^^^^^^^^^^^^^^^^^^^^
- name : UntilNode
2024-07-02 22:43:01 +03:00
flags : LoopFlags
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : keyword_loc
type : location
2023-08-22 01:07:32 +03:00
- name : closing_loc
type : location?
2023-08-18 00:39:04 +03:00
- name : predicate
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-18 00:39:04 +03:00
- name : statements
type : node?
kind : StatementsNode
newline : predicate
comment : |
Represents the use of the `until` keyword, either in the block form or the modifier form.
bar until foo
^^^^^^^^^^^^^
until foo do bar end
^^^^^^^^^^^^^^^^^^^^
- name : WhenNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : keyword_loc
type : location
- name : conditions
type : node[]
2024-08-28 23:32:30 +03:00
kind : non-void expression
2024-03-04 17:39:33 +03:00
- name : then_keyword_loc
type : location?
2023-08-18 00:39:04 +03:00
- name : statements
type : node?
kind : StatementsNode
comment : |
Represents the use of the `when` keyword within a case statement.
case true
when true
^^^^^^^^^
end
- name : WhileNode
2024-07-02 22:43:01 +03:00
flags : LoopFlags
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : keyword_loc
type : location
2023-08-22 01:10:47 +03:00
- name : closing_loc
type : location?
2023-08-18 00:39:04 +03:00
- name : predicate
type : node
2024-08-28 23:32:30 +03:00
kind : non-void expression
2023-08-18 00:39:04 +03:00
- name : statements
type : node?
kind : StatementsNode
newline : predicate
comment : |
Represents the use of the `while` keyword, either in the block form or the modifier form.
bar while foo
^^^^^^^^^^^^^
while foo do bar end
^^^^^^^^^^^^^^^^^^^^
- name : XStringNode
2024-07-02 22:43:01 +03:00
flags : EncodingFlags
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : opening_loc
type : location
- name : content_loc
type : location
- name : closing_loc
type : location
- name : unescaped
type : string
comment : |
Represents an xstring literal with no interpolation.
`foo`
^^^^^
- name : YieldNode
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : keyword_loc
type : location
- name : lparen_loc
type : location?
- name : arguments
type : node?
kind : ArgumentsNode
- name : rparen_loc
type : location?
comment : |
Represents the use of the `yield` keyword.
yield 1
^^^^^^^