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
- ARGUMENT_FORMAL_CLASS
- ARGUMENT_FORMAL_CONSTANT
- ARGUMENT_FORMAL_GLOBAL
- ARGUMENT_FORMAL_IVAR
- ARGUMENT_FORWARDING_UNBOUND
- ARGUMENT_IN
- ARGUMENT_NO_FORWARDING_AMP
- 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
- ESCAPE_INVALID_UNICODE_LITERAL
- ESCAPE_INVALID_UNICODE_LONG
- 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
- EXPECT_IDENT_REQ_PARAMETER
- 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
- 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
- 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
- HEREDOC_TERM
- INCOMPLETE_QUESTION_MARK
- INCOMPLETE_VARIABLE_CLASS
2024-02-16 05:27:46 +03:00
- INCOMPLETE_VARIABLE_CLASS_3_3_0
2024-03-06 21:18:55 +03:00
- INCOMPLETE_VARIABLE_INSTANCE
2024-02-16 05:27:46 +03:00
- INCOMPLETE_VARIABLE_INSTANCE_3_3_0
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-03-06 21:18:55 +03:00
- INVALID_ENCODING_MAGIC_COMMENT
- 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
- INVALID_NUMBER_HEXADECIMAL
- INVALID_NUMBER_OCTAL
- INVALID_NUMBER_UNDERSCORE
- INVALID_PERCENT
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-04-02 19:19:39 +03:00
- INVALID_VARIABLE_GLOBAL
- INVALID_VARIABLE_GLOBAL_3_3_0
- 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
- NO_LOCAL_VARIABLE
2024-02-16 05:27:46 +03:00
- NOT_EXPRESSION
2024-03-06 21:18:55 +03:00
- NUMBER_LITERAL_UNDERSCORE
- NUMBERED_PARAMETER_IT
- NUMBERED_PARAMETER_ORDINARY
- NUMBERED_PARAMETER_OUTER_SCOPE
- OPERATOR_MULTI_ASSIGN
- OPERATOR_WRITE_ARGUMENTS
- OPERATOR_WRITE_BLOCK
- PARAMETER_ASSOC_SPLAT_MULTI
- PARAMETER_BLOCK_MULTI
- PARAMETER_CIRCULAR
- 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
- PARAMETER_WILD_LOOSE_COMMA
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
- PATTERN_HASH_KEY
2024-04-01 20:33:16 +03:00
- PATTERN_HASH_KEY_DUPLICATE
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-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
- UNARY_RECEIVER
2024-02-16 05:27:46 +03:00
- UNDEF_ARGUMENT
2024-04-12 20:18:47 +03:00
- UNEXPECTED_BLOCK_ARGUMENT
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 :
- 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-03-12 18:42:07 +03:00
- EQUAL_IN_CONDITIONAL_3_3_0
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-03-06 21:18:55 +03:00
- INTEGER_IN_FLIP_FLOP
2024-03-12 21:01:30 +03:00
- INVALID_CHARACTER
2024-03-13 21:22:31 +03:00
- INVALID_NUMBERED_REFERENCE
2024-03-15 04:37:16 +03:00
- INVALID_SHAREABLE_CONSTANT_VALUE
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-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 :
2023-11-21 23:46:48 +03:00
- name : CONTAINS_KEYWORD_SPLAT
2023-10-26 21:02:27 +03:00
comment : "if arguments contain keyword splat"
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-01-04 06:08:59 +03:00
comment : |
Represents the new name of the global variable that can be used after aliasing. This can be either a global variable, a back reference, or a numbered reference.
alias $foo $bar
^^^^
2023-08-18 00:39:04 +03:00
- name : old_name
type : node
2024-01-04 06:08:59 +03:00
comment : |
Represents the old name of the global variable that could be used before aliasing. This can be either a global variable, a back reference, or a numbered reference.
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
- name : old_name
type : node
- 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
- name : right
type : node
- name : operator_loc
type : location
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-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-01-14 11:58:30 +03:00
comment : |
2024-01-19 19:22:40 +03:00
Represents the right 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 && 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
2023-08-30 23:09:51 +03:00
fields :
2023-10-26 21:02:27 +03:00
- name : flags
type : flags
kind : ArgumentsNodeFlags
2023-12-06 23:32:53 +03:00
- name : arguments
type : node[]
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
2023-08-30 23:09:51 +03:00
fields :
2023-12-06 23:32:53 +03:00
- name : flags
type : flags
kind : ArrayNodeFlags
2023-08-18 00:39:04 +03:00
- name : elements
type : node[]
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?
- name : requireds
type : node[]
- name : rest
type : node?
- name : posts
type : node[]
- 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-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-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-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?
- name : operator_loc
type : location
comment : |
Represents block method arguments.
bar(&args)
^^^^^^^^^^
2023-09-05 19:34:16 +03:00
- name : BlockLocalVariableNode
fields :
2024-01-09 21:12:03 +03:00
- name : flags
type : flags
kind : ParameterFlags
2023-09-05 19:34:16 +03:00
- 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?
2023-08-19 03:47:58 +03:00
- name : body
2023-08-18 00:39:04 +03:00
type : node?
- 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
2023-08-30 23:09:51 +03:00
fields :
2024-01-09 21:12:03 +03:00
- name : flags
type : flags
kind : ParameterFlags
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 : |
Represents a block parameter to a method, block, or lambda definition.
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
fields :
2023-12-06 23:32:53 +03:00
- name : flags
type : flags
kind : CallNodeFlags
2023-09-05 21:16:33 +03:00
- name : receiver
type : node?
- 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
comment : |
Represents the use of the `&&=` operator on a call.
foo.bar &&= value
^^^^^^^^^^^^^^^^^
2023-08-18 00:39:04 +03:00
- name : CallNode
2023-08-30 23:09:51 +03:00
fields :
2023-12-06 23:32:53 +03:00
- name : flags
type : flags
kind : CallNodeFlags
2023-08-18 00:39:04 +03:00
- name : receiver
type : node?
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?
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
2023-08-30 23:09:51 +03:00
fields :
2023-12-06 23:32:53 +03:00
- name : flags
type : flags
kind : CallNodeFlags
2023-09-05 21:16:33 +03:00
- name : receiver
type : node?
- 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
type : constant
2023-08-18 00:39:04 +03:00
- name : operator_loc
type : location
- name : value
type : node
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
2023-08-30 23:09:51 +03:00
fields :
2023-12-06 23:32:53 +03:00
- name : flags
type : flags
kind : CallNodeFlags
2023-09-05 21:16:33 +03:00
- name : receiver
type : node?
- 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
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
fields :
- name : flags
type : flags
kind : CallNodeFlags
- name : receiver
type : node
- 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
- name : target
type : node
- 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?
- name : conditions
type : node[]
- name : consequent
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?
- name : conditions
type : node[]
- name : consequent
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
- name : inheritance_operator_loc
type : location?
- name : superclass
type : node?
2023-08-19 03:47:58 +03:00
- name : body
2023-08-18 00:39:04 +03:00
type : node?
- 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
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
- name : operator_loc
type : location
- name : value
type : node
- name : operator
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
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-03-11 22:45:54 +03:00
comment : |
The value to assign to the class variable. Can be any node that
represents a non-void expression.
@@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
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
- name : operator_loc
type : location
- name : value
type : node
- name : operator
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
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
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?
- name : child
type : node
2023-12-21 07:41:52 +03:00
kind :
- ConstantReadNode
- MissingNode
2023-08-18 00:39:04 +03:00
- name : delimiter_loc
type : location
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
- name : operator_loc
type : location
- name : value
type : node
- name : operator
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
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?
- name : child
type : node
2023-12-21 07:41:52 +03:00
kind :
- ConstantReadNode
- MissingNode
2023-08-25 18:57:37 +03:00
- name : delimiter_loc
type : location
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
- name : operator_loc
2023-08-25 20:03:16 +03:00
type : location
2023-08-18 00:39:04 +03:00
- name : value
2023-08-25 20:03:16 +03:00
type : node
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
2023-08-18 00:39:04 +03:00
- name : name_loc
type : location
- name : value
2023-08-25 20:03:16 +03:00
type : node
2023-08-18 00:39:04 +03:00
- name : operator_loc
2023-08-25 20:03:16 +03:00
type : location
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?
- 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?
- 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
- 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
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?
- name : left
type : node
- name : requireds
type : node[]
- name : right
type : node
- 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
2023-08-30 23:09:51 +03:00
fields :
2023-12-06 23:32:53 +03:00
- name : flags
type : flags
kind : RangeFlags
2023-08-18 00:39:04 +03:00
- name : left
type : node?
- name : right
type : node?
- 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
- name : collection
type : node
- name : statements
type : node?
kind : StatementsNode
- name : for_keyword_loc
type : location
- name : in_keyword_loc
type : location
- name : do_keyword_loc
type : location?
- name : end_keyword_loc
type : location
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
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
- name : operator_loc
type : location
- name : value
type : node
- name : operator
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
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
2023-08-18 00:39:04 +03:00
- name : name_loc
type : location
- name : value
2023-08-25 20:03:16 +03:00
type : node
2023-08-30 23:43:40 +03:00
- name : operator_loc
type : location
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?
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-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
2023-08-18 00:39:04 +03:00
- name : consequent
type : node?
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
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
- 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
fields :
2023-12-06 23:32:53 +03:00
- name : flags
type : flags
kind : 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
- name : receiver
type : node?
- 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?
- name : operator_loc
type : location
- name : value
type : node
comment : |
Represents the use of the `&&=` operator on a call to the `[]` method.
foo.bar[baz] &&= value
^^^^^^^^^^^^^^^^^^^^^^
- name : IndexOperatorWriteNode
fields :
2023-12-06 23:32:53 +03:00
- name : flags
type : flags
kind : 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
- name : receiver
type : node?
- 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?
- name : operator
type : constant
- name : operator_loc
type : location
- name : value
type : node
comment : |
Represents the use of an assignment operator on a call to `[]`.
foo.bar[baz] += value
^^^^^^^^^^^^^^^^^^^^^
- name : IndexOrWriteNode
fields :
2023-12-06 23:32:53 +03:00
- name : flags
type : flags
kind : 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
- name : receiver
type : node?
- 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?
- name : operator_loc
type : location
- name : value
type : node
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
fields :
- name : flags
type : flags
kind : CallNodeFlags
- name : receiver
type : node
- name : opening_loc
type : location
- name : arguments
type : node?
kind : ArgumentsNode
- name : closing_loc
type : location
- name : block
type : node?
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
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
- name : operator_loc
type : location
- name : value
type : node
- name : operator
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
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-03-11 22:46:25 +03:00
comment : |
The value to assign to the instance variable. Can be any node that
represents a non-void expression.
@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
2023-09-11 19:05:14 +03:00
fields :
- name : flags
type : flags
kind : IntegerBaseFlags
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
fields :
2023-12-06 23:32:53 +03:00
- name : flags
type : flags
kind : RegularExpressionFlags
2023-09-11 19:32:25 +03:00
- 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
2023-08-30 23:09:51 +03:00
fields :
2023-12-06 23:32:53 +03:00
- name : flags
type : flags
kind : RegularExpressionFlags
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
2023-08-30 23:09:51 +03:00
fields :
2024-03-25 22:32:54 +03:00
- name : flags
type : flags
kind : InterpolatedStringNodeFlags
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-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
2023-08-30 23:09:51 +03:00
fields :
2023-12-11 23:26:06 +03:00
- name : flags
type : flags
kind : KeywordHashNodeFlags
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
2023-08-30 23:09:51 +03:00
fields :
2024-01-09 21:12:03 +03:00
- name : flags
type : flags
kind : ParameterFlags
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?
2023-08-19 03:47:58 +03:00
- name : body
2023-08-18 00:39:04 +03:00
type : node?
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
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
- name : operator_loc
type : location
- name : value
type : node
2023-08-27 18:56:53 +03:00
- name : name
2023-08-25 17:49:00 +03:00
type : constant
2023-08-27 18:56:53 +03:00
- name : 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
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`
2024-01-19 19:22:40 +03:00
Finally, for the default `it` block parameter, the name is `0it`. This is to distinguish it from an `it` local variable that is explicitly declared.
2024-01-19 19:12:12 +03:00
it # name `:0it`
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
- name : depth
type : uint32
- name : name_loc
type : location
2023-08-30 23:48:17 +03:00
- name : value
type : node
2023-08-18 00:39:04 +03:00
- name : operator_loc
2023-08-25 20:03:16 +03:00
type : location
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
fields :
2023-12-06 23:32:53 +03:00
- name : flags
type : flags
kind : RegularExpressionFlags
2023-09-11 19:32:25 +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 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
- name : pattern
type : node
- 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
- name : pattern
type : node
- 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
2023-08-19 03:47:58 +03:00
- name : body
2023-08-18 00:39:04 +03:00
type : node?
- 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
- RequiredParameterNode
- BackReferenceReadNode # On parsing error of `$',`
- NumberedReferenceReadNode # On parsing error of `$1,`
2023-10-23 19:06:21 +03:00
- name : rest
type : node?
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
- RequiredParameterNode
- BackReferenceReadNode # On parsing error of `*,$'`
2023-08-18 00:39:04 +03:00
- name : lparen_loc
type : location?
- name : rparen_loc
type : location?
comment : |
Represents a multi-target expression.
2023-10-26 21:02:27 +03:00
a, (b, c) = 1, 2, 3
^^^^^^
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
2023-10-23 19:06:21 +03:00
- name : rest
type : node?
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
2023-09-07 21:20:18 +03:00
- name : lparen_loc
type : location?
- name : rparen_loc
type : location?
2023-09-07 20:00:45 +03:00
- name : operator_loc
type : location
- name : value
type : node
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
fields :
2024-01-09 21:12:03 +03:00
- name : flags
type : flags
kind : ParameterFlags
2023-10-31 23:00:28 +03:00
- name : name
type : constant
- name : name_loc
type : location
2023-11-01 15:36:15 +03:00
- name : value
type : node
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
2023-08-30 23:09:51 +03:00
fields :
2024-01-09 21:12:03 +03:00
- name : flags
type : flags
kind : ParameterFlags
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
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-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-01-14 11:58:30 +03:00
comment : |
2024-01-19 19:22:40 +03:00
Represents the right 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 || 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:
- KeywordRestParameterNode
- NoKeywordsParameterNode
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?
- 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
- 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
- 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
2023-08-30 23:09:51 +03:00
fields :
2023-12-06 23:32:53 +03:00
- name : flags
type : flags
kind : RangeFlags
2023-08-18 00:39:04 +03:00
- name : left
type : node?
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-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
2023-08-30 23:09:51 +03:00
fields :
2023-08-18 00:39:04 +03:00
- name : numeric
type : node
comment : |
Represents a rational number literal.
1. 0r
^^^^
- name : RedoNode
comment : |
Represents the use of the `redo` keyword.
redo
^^^^
- name : RegularExpressionNode
2023-08-30 23:09:51 +03:00
fields :
2023-12-06 23:32:53 +03:00
- name : flags
type : flags
kind : RegularExpressionFlags
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
fields :
2024-01-09 21:12:03 +03:00
- name : flags
type : flags
kind : ParameterFlags
2023-10-31 23:00:28 +03:00
- 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
2023-08-30 23:09:51 +03:00
fields :
2024-01-09 21:12:03 +03:00
- name : flags
type : flags
kind : ParameterFlags
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
- name : keyword_loc
type : location
- name : rescue_expression
type : node
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[]
- name : operator_loc
type : location?
- name : reference
type : node?
- name : statements
type : node?
kind : StatementsNode
- name : consequent
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-01-19 19:22:40 +03:00
`Foo, *splat, Bar` are in the `exceptions` field. `ex` is in the `exception` field.
2023-08-18 00:39:04 +03:00
- name : RestParameterNode
2023-08-30 23:09:51 +03:00
fields :
2024-01-09 21:12:03 +03:00
- name : flags
type : flags
kind : ParameterFlags
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
fields :
- name : flags
type : flags
kind : ShareableConstantNodeFlags
- 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
2023-08-19 03:47:58 +03:00
- name : body
2023-08-18 00:39:04 +03:00
type : node?
- 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
2023-08-30 23:09:51 +03:00
fields :
2024-03-15 15:24:23 +03:00
- name : flags
type : flags
kind : StringFlags
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?
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[]
comment : |
Represents a set of statements contained within some scope.
foo; bar; baz
^^^^^^^^^^^^^
- name : StringNode
2023-08-30 23:09:51 +03:00
fields :
2023-09-12 20:06:41 +03:00
- name : flags
type : flags
kind : StringFlags
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?
comment : |
Represents the use of the `super` keyword with parentheses or arguments.
super()
^^^^^^^
super foo, bar
^^^^^^^^^^^^^^
- name : SymbolNode
2023-08-30 23:09:51 +03:00
fields :
2023-12-08 18:10:43 +03:00
- name : flags
type : flags
kind : SymbolFlags
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-01-19 17:19:28 +03:00
comment : |
The condition to be evaluated for the unless expression. Can be any
kind of node that represents a non-void expression.
unless cond then bar end
^^^^
bar unless cond
^^^^
2023-11-16 01:55:16 +03:00
- name : then_keyword_loc
type : location?
2024-01-19 17:19:28 +03:00
comment :
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
^^^
2023-08-18 00:39:04 +03:00
- name : consequent
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
2023-08-30 23:09:51 +03:00
fields :
2023-12-06 23:32:53 +03:00
- name : flags
type : flags
kind : LoopFlags
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
- 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-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
2023-08-30 23:09:51 +03:00
fields :
2023-12-06 23:32:53 +03:00
- name : flags
type : flags
kind : LoopFlags
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
- 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
2023-08-30 23:09:51 +03:00
fields :
2023-12-04 20:51:22 +03:00
- name : flags
type : flags
kind : EncodingFlags
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
^^^^^^^