summaryrefslogtreecommitdiff
path: root/prism/config.yml
diff options
context:
space:
mode:
Diffstat (limited to 'prism/config.yml')
-rw-r--r--prism/config.yml595
1 files changed, 429 insertions, 166 deletions
diff --git a/prism/config.yml b/prism/config.yml
index cfa3f62f2a..bbbc5f3d33 100644
--- a/prism/config.yml
+++ b/prism/config.yml
@@ -17,6 +17,8 @@ errors:
- ARGUMENT_FORWARDING_UNBOUND
- ARGUMENT_NO_FORWARDING_AMPERSAND
- ARGUMENT_NO_FORWARDING_ELLIPSES
+ - ARGUMENT_NO_FORWARDING_ELLIPSES_LAMBDA
+ - ARGUMENT_NO_FORWARDING_ELLIPSES_BLOCK
- ARGUMENT_NO_FORWARDING_STAR
- ARGUMENT_NO_FORWARDING_STAR_STAR
- ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT
@@ -60,7 +62,9 @@ errors:
- CONDITIONAL_WHILE_PREDICATE
- CONSTANT_PATH_COLON_COLON_CONSTANT
- DEF_ENDLESS
+ - DEF_ENDLESS_PARAMETERS
- DEF_ENDLESS_SETTER
+ - DEF_ENDLESS_DO_BLOCK
- DEF_NAME
- DEF_PARAMS_TERM
- DEF_PARAMS_TERM_PAREN
@@ -101,6 +105,8 @@ errors:
- EXPECT_FOR_DELIMITER
- EXPECT_IDENT_REQ_PARAMETER
- EXPECT_IN_DELIMITER
+ - EXPECT_LPAREN_AFTER_NOT_LPAREN
+ - EXPECT_LPAREN_AFTER_NOT_OTHER
- EXPECT_LPAREN_REQ_PARAMETER
- EXPECT_MESSAGE
- EXPECT_RBRACKET
@@ -216,6 +222,7 @@ errors:
- PARAMETER_WILD_LOOSE_COMMA
- PATTERN_ARRAY_MULTIPLE_RESTS
- PATTERN_CAPTURE_DUPLICATE
+ - PATTERN_CAPTURE_IN_ALTERNATIVE
- PATTERN_EXPRESSION_AFTER_BRACKET
- PATTERN_EXPRESSION_AFTER_COMMA
- PATTERN_EXPRESSION_AFTER_HROCKET
@@ -241,7 +248,9 @@ errors:
- PATTERN_TERM_PAREN
- PIPEPIPEEQ_MULTI_ASSIGN
- REGEXP_ENCODING_OPTION_MISMATCH
+ - REGEXP_ESCAPED_NON_ASCII_IN_UTF8
- REGEXP_INCOMPAT_CHAR_ENCODING
+ - REGEXP_INVALID_CHAR_PROPERTY
- REGEXP_INVALID_UNICODE_RANGE
- REGEXP_NON_ESCAPED_MBC
- REGEXP_PARSE_ERROR
@@ -277,6 +286,7 @@ errors:
- UNEXPECTED_INDEX_KEYWORDS
- UNEXPECTED_LABEL
- UNEXPECTED_MULTI_WRITE
+ - UNEXPECTED_PARAMETER_DEFAULT_VALUE
- UNEXPECTED_RANGE_OPERATOR
- UNEXPECTED_SAFE_NAVIGATION
- UNEXPECTED_TOKEN_CLOSE_CONTEXT
@@ -320,13 +330,44 @@ warnings:
- UNUSED_LOCAL_VARIABLE
- VOID_STATEMENT
tokens:
+ # The order of the tokens at the beginning is important, because we use them
+ # for a lookup table.
- 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: BRACE_RIGHT
+ comment: "}"
+ - name: COMMA
+ comment: ","
+ - name: EMBEXPR_END
+ comment: "}"
+ - name: KEYWORD_DO
+ comment: "do"
+ - name: KEYWORD_ELSE
+ comment: "else"
+ - name: KEYWORD_ELSIF
+ comment: "elsif"
+ - name: KEYWORD_END
+ comment: "end"
+ - name: KEYWORD_ENSURE
+ comment: "ensure"
+ - name: KEYWORD_IN
+ comment: "in"
+ - name: KEYWORD_RESCUE
+ comment: "rescue"
+ - name: KEYWORD_THEN
+ comment: "then"
+ - name: KEYWORD_WHEN
+ comment: "when"
+ - name: NEWLINE
+ comment: "a newline character outside of other tokens"
+ - name: PARENTHESIS_RIGHT
+ comment: ")"
+ - name: PIPE
+ comment: "|"
+ - name: SEMICOLON
+ comment: ";"
+ # Tokens from here on are not used for lookup, and can be in any order.
- name: AMPERSAND
comment: "&"
- name: AMPERSAND_AMPERSAND
@@ -349,8 +390,6 @@ tokens:
comment: "!~"
- name: BRACE_LEFT
comment: "{"
- - name: BRACE_RIGHT
- comment: "}"
- name: BRACKET_LEFT
comment: "["
- name: BRACKET_LEFT_ARRAY
@@ -373,8 +412,6 @@ tokens:
comment: ":"
- name: COLON_COLON
comment: "::"
- - name: COMMA
- comment: ","
- name: COMMENT
comment: "a comment"
- name: CONSTANT
@@ -393,8 +430,6 @@ tokens:
comment: "a line inside of embedded documentation"
- name: EMBEXPR_BEGIN
comment: "#{"
- - name: EMBEXPR_END
- comment: "}"
- name: EMBVAR
comment: "#"
- name: EQUAL
@@ -461,20 +496,12 @@ tokens:
comment: "def"
- name: KEYWORD_DEFINED
comment: "defined?"
- - name: KEYWORD_DO
- comment: "do"
+ - name: KEYWORD_DO_BLOCK
+ comment: "do keyword for a block attached to a command"
- 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
@@ -483,8 +510,6 @@ tokens:
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
@@ -497,8 +522,6 @@ tokens:
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
@@ -509,8 +532,6 @@ tokens:
comment: "self"
- name: KEYWORD_SUPER
comment: "super"
- - name: KEYWORD_THEN
- comment: "then"
- name: KEYWORD_TRUE
comment: "true"
- name: KEYWORD_UNDEF
@@ -523,8 +544,6 @@ tokens:
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
@@ -561,16 +580,12 @@ tokens:
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
@@ -585,8 +600,6 @@ tokens:
comment: "%I"
- name: PERCENT_UPPER_W
comment: "%W"
- - name: PIPE
- comment: "|"
- name: PIPE_EQUAL
comment: "|="
- name: PIPE_PIPE
@@ -603,8 +616,6 @@ tokens:
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
@@ -719,6 +730,11 @@ flags:
- name: REPEATED_PARAMETER
comment: "a parameter name that has been repeated in the method signature"
comment: Flags for parameter nodes.
+ - name: ParenthesesNodeFlags
+ values:
+ - name: MULTIPLE_STATEMENTS
+ comment: "parentheses that contain multiple potentially void statements"
+ comment: Flags for parentheses nodes.
- name: RangeFlags
values:
- name: EXCLUDE_END
@@ -798,8 +814,6 @@ nodes:
- GlobalVariableReadNode
- BackReferenceReadNode
- NumberedReferenceReadNode
- - on error: SymbolNode # alias $a b
- - on error: MissingNode # alias $a 42
comment: |
Represents the old name of the global variable that can be used before aliasing.
@@ -808,7 +822,7 @@ nodes:
- name: keyword_loc
type: location
comment: |
- The location of the `alias` keyword.
+ The Location of the `alias` keyword.
alias $foo $bar
^^^^^
@@ -840,8 +854,6 @@ nodes:
kind:
- SymbolNode
- InterpolatedSymbolNode
- - on error: GlobalVariableReadNode # alias a $b
- - on error: MissingNode # alias a 42
comment: |
Represents the old name of the method that will be aliased.
@@ -856,7 +868,7 @@ nodes:
- name: keyword_loc
type: location
comment: |
- Represents the location of the `alias` keyword.
+ Represents the Location of the `alias` keyword.
alias foo bar
^^^^^
@@ -886,7 +898,7 @@ nodes:
- name: operator_loc
type: location
comment: |
- Represents the alternation operator location.
+ Represents the alternation operator Location.
foo => bar | baz
^
@@ -922,7 +934,7 @@ nodes:
- name: operator_loc
type: location
comment: |
- The location of the `and` keyword or the `&&` operator.
+ The Location of the `and` keyword or the `&&` operator.
left and right
^^^
@@ -957,7 +969,7 @@ nodes:
- name: opening_loc
type: location?
comment: |
- Represents the optional source location for the opening token.
+ Represents the optional source Location for the opening token.
[1,2,3] # "["
%w[foo bar baz] # "%w["
@@ -966,7 +978,7 @@ nodes:
- name: closing_loc
type: location?
comment: |
- Represents the optional source location for the closing token.
+ Represents the optional source Location for the closing token.
[1,2,3] # "]"
%w[foo bar baz] # "]"
@@ -982,8 +994,19 @@ nodes:
- name: constant
type: node?
kind:
- - ConstantReadNode
- ConstantPathNode
+ - ConstantReadNode
+ comment: |
+ Represents the optional constant preceding the Array
+
+ foo in Bar[]
+ ^^^
+
+ foo in Bar[1, 2, 3]
+ ^^^
+
+ foo in Bar::Baz[1, 2, 3]
+ ^^^^^^^^
- name: requireds
type: node[]
kind: pattern expression
@@ -994,7 +1017,9 @@ nodes:
^ ^
- name: rest
type: node?
- kind: pattern expression
+ kind:
+ - ImplicitRestNode
+ - SplatNode
comment: |
Represents the rest element of the array pattern.
@@ -1011,14 +1036,14 @@ nodes:
- name: opening_loc
type: location?
comment: |
- Represents the opening location of the array pattern.
+ Represents the opening Location of the array pattern.
foo in [1, 2]
^
- name: closing_loc
type: location?
comment: |
- Represents the closing location of the array pattern.
+ Represents the closing Location of the array pattern.
foo in [1, 2]
^
@@ -1026,19 +1051,19 @@ nodes:
Represents an array pattern in pattern matching.
foo in 1, 2
- ^^^^^^^^^^^
+ ^^^^
foo in [1, 2]
- ^^^^^^^^^^^^^
+ ^^^^^^
foo in *bar
- ^^^^^^^^^^^
+ ^^^^
foo in Bar[]
- ^^^^^^^^^^^^
+ ^^^^^
foo in Bar[1, 2, 3]
- ^^^^^^^^^^^^^^^^^^^
+ ^^^^^^^^^^^^
- name: AssocNode
fields:
- name: key
@@ -1069,7 +1094,7 @@ nodes:
- name: operator_loc
type: location?
comment: |
- The location of the `=>` operator, if present.
+ The Location of the `=>` operator, if present.
{ foo => bar }
^^
@@ -1091,7 +1116,7 @@ nodes:
- name: operator_loc
type: location
comment: |
- The location of the `**` operator.
+ The Location of the `**` operator.
{ **x }
^^
@@ -1120,7 +1145,7 @@ nodes:
- name: begin_keyword_loc
type: location?
comment: |
- Represents the location of the `begin` keyword.
+ Represents the Location of the `begin` keyword.
begin x end
^^^^^
@@ -1147,7 +1172,7 @@ nodes:
Represents the else clause within the begin block.
begin x; rescue y; else z; end
- ^^^^^^
+ ^^^^^^^^^^^
- name: ensure_clause
type: node?
kind: EnsureNode
@@ -1159,7 +1184,7 @@ nodes:
- name: end_keyword_loc
type: location?
comment: |
- Represents the location of the `end` keyword.
+ Represents the Location of the `end` keyword.
begin x end
^^^
@@ -1180,11 +1205,11 @@ nodes:
The expression that is being passed as a block argument. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
foo(&args)
- ^^^^^
+ ^^^^
- name: operator_loc
type: location
comment: |
- Represents the location of the `&` operator.
+ Represents the Location of the `&` operator.
foo(&args)
^
@@ -1192,7 +1217,7 @@ nodes:
Represents a block argument using `&`.
bar(&args)
- ^^^^^^^^^^
+ ^^^^^
- name: BlockLocalVariableNode
flags: ParameterFlags
fields:
@@ -1245,17 +1270,17 @@ nodes:
- name: opening_loc
type: location
comment: |
- Represents the location of the opening `|`.
+ Represents the Location of the opening `{` or `do`.
[1, 2, 3].each { |i| puts x }
- ^
+ ^
- name: closing_loc
type: location
comment: |
- Represents the location of the closing `|`.
+ Represents the Location of the closing `}` or `end`.
[1, 2, 3].each { |i| puts x }
- ^
+ ^
comment: |
Represents a block of ruby code.
@@ -1275,14 +1300,14 @@ nodes:
- name: name_loc
type: location?
comment: |
- Represents the location of the block parameter name.
+ Represents the Location of the block parameter name.
def a(&b)
^
- name: operator_loc
type: location
comment: |
- Represents the location of the `&` operator.
+ Represents the Location of the `&` operator.
def a(&b)
^
@@ -1322,7 +1347,7 @@ nodes:
- name: opening_loc
type: location?
comment: |
- Represents the opening location of the block parameters.
+ Represents the opening Location of the block parameters.
-> (a, b = 1; local) { }
^
@@ -1333,7 +1358,7 @@ nodes:
- name: closing_loc
type: location?
comment: |
- Represents the closing location of the block parameters.
+ Represents the closing Location of the block parameters.
-> (a, b = 1; local) { }
^
@@ -1363,7 +1388,7 @@ nodes:
- name: keyword_loc
type: location
comment: |
- The location of the `break` keyword.
+ The Location of the `break` keyword.
break foo
^^^^^
@@ -1386,14 +1411,14 @@ nodes:
- name: call_operator_loc
type: location?
comment: |
- Represents the location of the call operator.
+ Represents the Location of the call operator.
foo.bar &&= value
^
- name: message_loc
type: location?
comment: |
- Represents the location of the message.
+ Represents the Location of the message.
foo.bar &&= value
^^^
@@ -1414,7 +1439,7 @@ nodes:
- name: operator_loc
type: location
comment: |
- Represents the location of the operator.
+ Represents the Location of the operator.
foo.bar &&= value
^^^
@@ -1451,7 +1476,7 @@ nodes:
- name: call_operator_loc
type: location?
comment: |
- Represents the location of the call operator.
+ Represents the Location of the call operator.
foo.bar
^
@@ -1468,14 +1493,15 @@ nodes:
- name: message_loc
type: location?
comment: |
- Represents the location of the message.
+ Represents the Location of the message.
foo.bar
^^^
- name: opening_loc
type: location?
comment: |
- Represents the location of the left parenthesis.
+ Represents the Location of the left parenthesis.
+
foo(bar)
^
- name: arguments
@@ -1489,10 +1515,20 @@ nodes:
- name: closing_loc
type: location?
comment: |
- Represents the location of the right parenthesis.
+ Represents the Location of the right parenthesis.
foo(bar)
^
+ - name: equal_loc
+ type: location?
+ comment: |
+ Represents the Location of the equal sign, in the case that this is an attribute write.
+
+ foo.bar = value
+ ^
+
+ foo[bar] = value
+ ^
- name: block
type: node?
kind:
@@ -1537,14 +1573,14 @@ nodes:
- name: call_operator_loc
type: location?
comment: |
- Represents the location of the call operator.
+ Represents the Location of the call operator.
foo.bar += value
^
- name: message_loc
type: location?
comment: |
- Represents the location of the message.
+ Represents the Location of the message.
foo.bar += value
^^^
@@ -1572,7 +1608,7 @@ nodes:
- name: binary_operator_loc
type: location
comment: |
- Represents the location of the binary operator.
+ Represents the Location of the binary operator.
foo.bar += value
^^
@@ -1603,14 +1639,14 @@ nodes:
- name: call_operator_loc
type: location?
comment: |
- Represents the location of the call operator.
+ Represents the Location of the call operator.
foo.bar ||= value
^
- name: message_loc
type: location?
comment: |
- Represents the location of the message.
+ Represents the Location of the message.
foo.bar ||= value
^^^
@@ -1631,7 +1667,7 @@ nodes:
- name: operator_loc
type: location
comment: |
- Represents the location of the operator.
+ Represents the Location of the operator.
foo.bar ||= value
^^^
@@ -1662,7 +1698,7 @@ nodes:
- name: call_operator_loc
type: location
comment: |
- Represents the location of the call operator.
+ Represents the Location of the call operator.
foo.bar = 1
^
@@ -1676,7 +1712,7 @@ nodes:
- name: message_loc
type: location
comment: |
- Represents the location of the message.
+ Represents the Location of the message.
foo.bar = 1
^^^
@@ -1714,7 +1750,7 @@ nodes:
- name: operator_loc
type: location
comment: |
- Represents the location of the `=>` operator.
+ Represents the Location of the `=>` operator.
foo => bar
^^
@@ -1722,7 +1758,7 @@ nodes:
Represents assigning to a local variable in pattern matching.
foo => [bar => baz]
- ^^^^^^^^^^^^
+ ^^^^^^^^^^
- name: CaseMatchNode
fields:
- name: predicate
@@ -1732,7 +1768,7 @@ nodes:
Represents the predicate of the case match. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
case true; in false; end
- ^^^^
+ ^^^^
- name: conditions
type: node[]
kind: InNode
@@ -1748,18 +1784,18 @@ nodes:
Represents the else clause of the case match.
case true; in false; else; end
- ^^^^
+ ^^^^^^^^^
- name: case_keyword_loc
type: location
comment: |
- Represents the location of the `case` keyword.
+ Represents the Location of the `case` keyword.
case true; in false; end
^^^^
- name: end_keyword_loc
type: location
comment: |
- Represents the location of the `end` keyword.
+ Represents the Location of the `end` keyword.
case true; in false; end
^^^
@@ -1779,7 +1815,7 @@ nodes:
Represents the predicate of the case statement. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
case true; when false; end
- ^^^^
+ ^^^^
- name: conditions
type: node[]
kind: WhenNode
@@ -1795,18 +1831,18 @@ nodes:
Represents the else clause of the case statement.
case true; when false; else; end
- ^^^^
+ ^^^^^^^^^
- name: case_keyword_loc
type: location
comment: |
- Represents the location of the `case` keyword.
+ Represents the Location of the `case` keyword.
case true; when false; end
^^^^
- name: end_keyword_loc
type: location
comment: |
- Represents the location of the `end` keyword.
+ Represents the Location of the `end` keyword.
case true; when false; end
^^^
@@ -1823,26 +1859,54 @@ nodes:
type: constant[]
- name: class_keyword_loc
type: location
+ comment: |
+ Represents the Location of the `class` keyword.
+
+ class Foo end
+ ^^^^^
- name: constant_path
type: node
kind:
- ConstantReadNode
- ConstantPathNode
- - on error: CallNode # class 0.X end
- name: inheritance_operator_loc
type: location?
+ comment: |
+ Represents the Location of the `<` operator.
+
+ class Foo < Bar
+ ^
- name: superclass
type: node?
kind: non-void expression
+ comment: |
+ Represents the superclass of the class.
+
+ class Foo < Bar
+ ^^^
- name: body
type: node?
kind:
- StatementsNode
- BeginNode
+ comment: |
+ Represents the body of the class.
+
+ class Foo; bar; end
+ ^^^
- name: end_keyword_loc
type: location
+ comment: |
+ Represents the Location of the `end` keyword.
+
+ class Foo end
+ ^^^
- name: name
type: constant
+ comment: |
+ The name of the class.
+
+ class Foo end # name `:Foo`
comment: |
Represents a class declaration involving the `class` keyword.
@@ -1860,14 +1924,14 @@ nodes:
- name: name_loc
type: location
comment: |
- Represents the location of the variable name.
+ Represents the Location of the variable name.
@@target &&= value
^^^^^^^^
- name: operator_loc
type: location
comment: |
- Represents the location of the `&&=` operator.
+ Represents the Location of the `&&=` operator.
@@target &&= value
^^^
@@ -1955,7 +2019,7 @@ nodes:
- name: name_loc
type: location
comment: |
- The location of the variable name.
+ The Location of the variable name.
@@foo = :bar
^^^^^
@@ -1973,7 +2037,7 @@ nodes:
- name: operator_loc
type: location
comment: |
- The location of the `=` operator.
+ The Location of the `=` operator.
@@foo = :bar
^
@@ -2069,7 +2133,7 @@ nodes:
- name: delimiter_loc
type: location
comment: |
- The location of the `::` delimiter.
+ The Location of the `::` delimiter.
::Foo
^^
@@ -2079,7 +2143,7 @@ nodes:
- name: name_loc
type: location
comment: |
- The location of the name of the constant.
+ The Location of the name of the constant.
::Foo
^^^
@@ -2155,7 +2219,7 @@ nodes:
- name: operator_loc
type: location
comment: |
- The location of the `=` operator.
+ The Location of the `=` operator.
::ABC = 123
^
@@ -2215,7 +2279,7 @@ nodes:
- name: name_loc
type: location
comment: |
- The location of the constant name.
+ The Location of the constant name.
FOO = 1
^^^
@@ -2233,7 +2297,7 @@ nodes:
- name: operator_loc
type: location
comment: |
- The location of the `=` operator.
+ The Location of the `=` operator.
FOO = :bar
^
@@ -2358,6 +2422,15 @@ nodes:
^^^^^^
bar
end
+ - name: ErrorRecoveryNode
+ fields:
+ - name: unexpected
+ type: node?
+ kind: Node
+ comment: |
+ The unexpected node that was found in the tree, if there was one.
+ comment: |
+ Represents a node that is either missing or unexpected and results in a syntax error.
- name: FalseNode
comment: |
Represents the use of the literal `false` keyword.
@@ -2369,23 +2442,66 @@ nodes:
- name: constant
type: node?
kind:
- - ConstantReadNode
- ConstantPathNode
+ - ConstantReadNode
+ comment: |
+ Represents the optional constant preceding the pattern
+
+ foo in Foo(*bar, baz, *qux)
+ ^^^
- name: left
type: node
kind: SplatNode
+ comment: |
+ Represents the first wildcard node in the pattern.
+
+ foo in *bar, baz, *qux
+ ^^^^
+
+ foo in Foo(*bar, baz, *qux)
+ ^^^^
- name: requireds
type: node[]
kind: pattern expression
+ comment: |
+ Represents the nodes in between the wildcards.
+
+ foo in *bar, baz, *qux
+ ^^^
+
+ foo in Foo(*bar, baz, 1, *qux)
+ ^^^^^^
- name: right
type: node
- kind:
- - SplatNode
- - on error: MissingNode
+ kind: SplatNode
+ comment: |
+ Represents the second wildcard node in the pattern.
+
+ foo in *bar, baz, *qux
+ ^^^^
+
+ foo in Foo(*bar, baz, *qux)
+ ^^^^
- name: opening_loc
type: location?
+ comment: |
+ The Location of the opening brace.
+
+ foo in [*bar, baz, *qux]
+ ^
+
+ foo in Foo(*bar, baz, *qux)
+ ^
- name: closing_loc
type: location?
+ comment: |
+ The Location of the closing brace.
+
+ foo in [*bar, baz, *qux]
+ ^
+
+ foo in Foo(*bar, baz, *qux)
+ ^
comment: |
Represents a find pattern in pattern matching.
@@ -2397,6 +2513,9 @@ nodes:
foo in Foo(*bar, baz, *qux)
^^^^^^^^^^^^^^^^^^^^
+
+ foo => *bar, baz, *qux
+ ^^^^^^^^^^^^^^^
- name: FlipFlopNode
flags: RangeFlags
fields:
@@ -2437,9 +2556,6 @@ nodes:
- CallTargetNode
- IndexTargetNode
- MultiTargetNode
- - on error: BackReferenceReadNode # for $& in a end
- - on error: NumberedReferenceReadNode # for $1 in a end
- - on error: MissingNode # for in 1..10; end
comment: |
The index expression for `for` loops.
@@ -2466,28 +2582,28 @@ nodes:
- name: for_keyword_loc
type: location
comment: |
- The location of the `for` keyword.
+ The Location of the `for` keyword.
for i in a end
^^^
- name: in_keyword_loc
type: location
comment: |
- The location of the `in` keyword.
+ The Location of the `in` keyword.
for i in a end
^^
- name: do_keyword_loc
type: location?
comment: |
- The location of the `do` keyword, if present.
+ The Location of the `do` keyword, if present.
for i in a do end
^^
- name: end_keyword_loc
type: location
comment: |
- The location of the `end` keyword.
+ The Location of the `end` keyword.
for i in a end
^^^
@@ -2513,14 +2629,29 @@ nodes:
end
- name: ForwardingSuperNode
fields:
+ - name: keyword_loc
+ type: location
+ comment: |
+ super
+ ^^^^^
+
+ super { 123 }
+ ^^^^^
- name: block
type: node?
kind: BlockNode
+ comment: |
+ All other arguments are forwarded as normal, except the original block is replaced with the new block.
comment: |
- Represents the use of the `super` keyword without parentheses or arguments.
+ Represents the use of the `super` keyword without parentheses or arguments, but which might have a block.
super
^^^^^
+
+ super { 123 }
+ ^^^^^^^^^^^^^
+
+ If it has any other arguments, it would be a `SuperNode` instead.
- name: GlobalVariableAndWriteNode
fields:
- name: name
@@ -2608,7 +2739,7 @@ nodes:
- name: name_loc
type: location
comment: |
- The location of the global variable's name.
+ The Location of the global variable's name.
$foo = :bar
^^^^
@@ -2626,7 +2757,7 @@ nodes:
- name: operator_loc
type: location
comment: |
- The location of the `=` operator.
+ The Location of the `=` operator.
$foo = :bar
^
@@ -2640,7 +2771,7 @@ nodes:
- name: opening_loc
type: location
comment: |
- The location of the opening brace.
+ The Location of the opening brace.
{ a => b }
^
@@ -2660,7 +2791,7 @@ nodes:
- name: closing_loc
type: location
comment: |
- The location of the closing brace.
+ The Location of the closing brace.
{ a => b }
^
@@ -2674,20 +2805,60 @@ nodes:
- name: constant
type: node?
kind:
- - ConstantReadNode
- ConstantPathNode
+ - ConstantReadNode
+ comment: |
+ Represents the optional constant preceding the Hash.
+
+ foo => Bar[a: 1, b: 2]
+ ^^^
+
+ foo => Bar::Baz[a: 1, b: 2]
+ ^^^^^^^^
- name: elements
type: node[]
kind: AssocNode
+ comment: |
+ Represents the explicit named hash keys and values.
+
+ foo => { a: 1, b:, ** }
+ ^^^^^^^^
- name: rest
type: node?
kind:
- AssocSplatNode
- NoKeywordsParameterNode
+ comment: |
+ Represents the rest of the Hash keys and values. This can be named, unnamed, or explicitly forbidden via `**nil`, this last one results in a `NoKeywordsParameterNode`.
+
+ foo => { a: 1, b:, **c }
+ ^^^
+
+ foo => { a: 1, b:, ** }
+ ^^
+
+ foo => { a: 1, b:, **nil }
+ ^^^^^
- name: opening_loc
type: location?
+ comment: |
+ The Location of the opening brace.
+
+ foo => { a: 1 }
+ ^
+
+ foo => Bar[a: 1]
+ ^
- name: closing_loc
type: location?
+ comment: |
+ The Location of the closing brace.
+
+ foo => { a: 1 }
+ ^
+
+ foo => Bar[a: 1]
+ ^
comment: |
Represents a hash pattern in pattern matching.
@@ -2696,12 +2867,18 @@ nodes:
foo => { a: 1, b: 2, **c }
^^^^^^^^^^^^^^^^^^^
+
+ foo => Bar[a: 1, b: 2]
+ ^^^^^^^^^^^^^^^
+
+ foo in { a: 1, b: 2 }
+ ^^^^^^^^^^^^^^
- name: IfNode
fields:
- name: if_keyword_loc
type: location?
comment: |
- The location of the `if` keyword if present.
+ The Location of the `if` keyword if present.
bar if foo
^^
@@ -2726,7 +2903,7 @@ nodes:
- name: then_keyword_loc
type: location?
comment: |
- The location of the `then` keyword (if present) or the `?` in a ternary expression, `nil` otherwise.
+ The Location of the `then` keyword (if present) or the `?` in a ternary expression, `nil` otherwise.
if foo then bar end
^^^^
@@ -2767,7 +2944,7 @@ nodes:
- name: end_keyword_loc
type: location?
comment: |
- The location of the `end` keyword if present, `nil` otherwise.
+ The Location of the `end` keyword if present, `nil` otherwise.
if foo
bar
@@ -3052,7 +3229,7 @@ nodes:
- name: name_loc
type: location
comment: |
- The location of the variable name.
+ The Location of the variable name.
@_x = 1
^^^
@@ -3070,7 +3247,7 @@ nodes:
- name: operator_loc
type: location
comment: |
- The location of the `=` operator.
+ The Location of the `=` operator.
@x = y
^
@@ -3347,6 +3524,9 @@ nodes:
foo, bar = baz
^^^ ^^^
+
+ foo => baz
+ ^^^
- name: LocalVariableWriteNode
fields:
- name: name
@@ -3370,7 +3550,7 @@ nodes:
- name: name_loc
type: location
comment: |
- The location of the variable name.
+ The Location of the variable name.
foo = :bar
^^^
@@ -3392,7 +3572,7 @@ nodes:
- name: operator_loc
type: location
comment: |
- The location of the `=` operator.
+ The Location of the `=` operator.
x = :y
^
@@ -3437,11 +3617,65 @@ nodes:
- name: value
type: node
kind: non-void expression
+ comment: |
+ Represents the left-hand side of the operator.
+
+ foo => bar
+ ^^^
- name: pattern
type: node
kind: pattern expression
+ comment: |
+ Represents the right-hand side of the operator. The type of the node depends on the expression.
+
+ Anything that looks like a local variable name (including `_`) will result in a `LocalVariableTargetNode`.
+
+ foo => a # This is equivalent to writing `a = foo`
+ ^
+
+ Using an explicit `Array` or combining expressions with `,` will result in a `ArrayPatternNode`. This can be preceded by a constant.
+
+ foo => [a]
+ ^^^
+
+ foo => a, b
+ ^^^^
+
+ foo => Bar[a, b]
+ ^^^^^^^^^
+
+ If the array pattern contains at least two wildcard matches, a `FindPatternNode` is created instead.
+
+ foo => *, 1, *a
+ ^^^^^
+
+ Using an explicit `Hash` or a constant with square brackets and hash keys in the square brackets will result in a `HashPatternNode`.
+
+ foo => { a: 1, b: }
+
+ foo => Bar[a: 1, b:]
+
+ foo => Bar[**]
+
+ To use any variable that needs run time evaluation, pinning is required. This results in a `PinnedVariableNode`
+
+ foo => ^a
+ ^^
+
+ Similar, any expression can be used with pinning. This results in a `PinnedExpressionNode`.
+
+ foo => ^(a + 1)
+
+ Anything else will result in the regular node for that expression, for example a `ConstantReadNode`.
+
+ foo => CONST
- name: operator_loc
type: location
+ comment: |
+ The Location of the operator.
+
+ foo => bar
+ ^^
comment: |
Represents the use of the `=>` operator.
@@ -3460,9 +3694,6 @@ nodes:
/(?<foo>bar)/ =~ baz
^^^^^^^^^^^^^^^^^^^^
- - name: MissingNode
- comment: |
- Represents a node that is missing from the source and results in a syntax error.
- name: ModuleNode
fields:
- name: locals
@@ -3474,7 +3705,6 @@ nodes:
kind:
- ConstantReadNode
- ConstantPathNode
- - on error: MissingNode # module Parent module end
- name: body
type: node?
kind:
@@ -3504,8 +3734,6 @@ nodes:
- IndexTargetNode
- MultiTargetNode
- RequiredParameterNode # def m((a,b)); end
- - on error: BackReferenceReadNode # a, (b, $&) = z
- - on error: NumberedReferenceReadNode # a, (b, $1) = z
comment: |
Represents the targets expressions before a splat node.
@@ -3549,8 +3777,6 @@ nodes:
- IndexTargetNode
- MultiTargetNode
- RequiredParameterNode # def m((*,b)); end
- - on error: BackReferenceReadNode # a, (*, $&) = z
- - on error: NumberedReferenceReadNode # a, (*, $1) = z
comment: |
Represents the targets expressions after a splat node.
@@ -3559,14 +3785,14 @@ nodes:
- name: lparen_loc
type: location?
comment: |
- The location of the opening parenthesis.
+ The Location of the opening parenthesis.
a, (b, c) = 1, 2, 3
^
- name: rparen_loc
type: location?
comment: |
- The location of the closing parenthesis.
+ The Location of the closing parenthesis.
a, (b, c) = 1, 2, 3
^
@@ -3594,8 +3820,6 @@ nodes:
- CallTargetNode
- IndexTargetNode
- MultiTargetNode
- - on error: BackReferenceReadNode # $&, = z
- - on error: NumberedReferenceReadNode # $1, = z
comment: |
Represents the targets expressions before a splat node.
@@ -3638,8 +3862,6 @@ nodes:
- CallTargetNode
- IndexTargetNode
- MultiTargetNode
- - on error: BackReferenceReadNode # *, $& = z
- - on error: NumberedReferenceReadNode # *, $1 = z
comment: |
Represents the targets expressions after a splat node.
@@ -3648,21 +3870,21 @@ nodes:
- name: lparen_loc
type: location?
comment: |
- The location of the opening parenthesis.
+ The Location of the opening parenthesis.
(a, b, c) = 1, 2, 3
^
- name: rparen_loc
type: location?
comment: |
- The location of the closing parenthesis.
+ The Location of the closing parenthesis.
(a, b, c) = 1, 2, 3
^
- name: operator_loc
type: location
comment: |
- The location of the operator.
+ The Location of the operator.
a, b, c = 1, 2, 3
^
@@ -3697,6 +3919,18 @@ nodes:
nil
^^^
+ - name: NoBlockParameterNode
+ fields:
+ - name: operator_loc
+ type: location
+ - name: keyword_loc
+ type: location
+ comment: |
+ Represents the use of `&nil` inside method arguments.
+
+ def a(&nil)
+ ^^^^
+ end
- name: NoKeywordsParameterNode
fields:
- name: operator_loc
@@ -3796,7 +4030,7 @@ nodes:
- name: operator_loc
type: location
comment: |
- The location of the `or` keyword or the `||` operator.
+ The Location of the `or` keyword or the `||` operator.
left or right
^^
@@ -3825,11 +4059,6 @@ nodes:
kind:
- RequiredParameterNode
- MultiTargetNode
- # On parsing error of `f(**kwargs, ...)` or `f(**nil, ...)`, the keyword_rest value is moved here:
- - on error: KeywordRestParameterNode
- - on error: NoKeywordsParameterNode
- # On parsing error of `f(..., ...)`, the first forwarding parameter is moved here:
- - on error: ForwardingParameterNode
- name: keywords
type: node[]
kind:
@@ -3843,7 +4072,9 @@ nodes:
- NoKeywordsParameterNode
- name: block
type: node?
- kind: BlockParameterNode
+ kind:
+ - BlockParameterNode
+ - NoBlockParameterNode
comment: |
Represents the list of parameters on a method, block, or lambda definition.
@@ -3851,6 +4082,7 @@ nodes:
^^^^^^^
end
- name: ParenthesesNode
+ flags: ParenthesesNodeFlags
fields:
- name: body
type: node?
@@ -3870,12 +4102,32 @@ nodes:
- name: expression
type: node
kind: non-void expression
+ comment: |
+ The expression used in the pinned expression
+
+ foo in ^(bar)
+ ^^^
- name: operator_loc
type: location
+ comment: |
+ The Location of the `^` operator
+
+ foo in ^(bar)
+ ^
- name: lparen_loc
type: location
+ comment: |
+ The Location of the opening parenthesis.
+
+ foo in ^(bar)
+ ^
- name: rparen_loc
type: location
+ comment: |
+ The Location of the closing parenthesis.
+
+ foo in ^(bar)
+ ^
comment: |
Represents the use of the `^` operator for pinning an expression in a pattern matching expression.
@@ -3893,9 +4145,18 @@ nodes:
- BackReferenceReadNode # foo in ^$&
- NumberedReferenceReadNode # foo in ^$1
- ItLocalVariableReadNode # proc { 1 in ^it }
- - on error: MissingNode # foo in ^Bar
+ comment: |
+ The variable used in the pinned expression
+
+ foo in ^bar
+ ^^^
- name: operator_loc
type: location
+ comment: |
+ The Location of the `^` operator
+
+ foo in ^bar
+ ^
comment: |
Represents the use of the `^` operator for pinning a variable in a pattern matching expression.
@@ -3966,11 +4227,11 @@ nodes:
1...foo
^^^
- If neither right-hand or left-hand side was included, this will be a MissingNode.
+ If neither right-hand or left-hand side was included, this will be an ErrorRecoveryNode.
- name: operator_loc
type: location
comment: |
- The location of the `..` or `...` operator.
+ The Location of the `..` or `...` operator.
comment: |
Represents the use of the `..` or `...` operators.
@@ -4081,9 +4342,8 @@ nodes:
- ConstantPathTargetNode
- CallTargetNode
- IndexTargetNode
- - on error: BackReferenceReadNode # => begin; rescue => $&; end
- - on error: NumberedReferenceReadNode # => begin; rescue => $1; end
- - on error: MissingNode # begin; rescue =>; end
+ - name: then_keyword_loc
+ type: location?
- name: statements
type: node?
kind: StatementsNode
@@ -4194,7 +4454,7 @@ nodes:
fields:
- name: filepath
type: string
- comment: Represents the file path being parsed. This corresponds directly to the `filepath` option given to the various `Prism::parse*` APIs.
+ comment: Represents the file path being parsed. This corresponds directly to the `filepath` option given to the various `Prism.parse*` APIs.
comment: |
Represents the use of the `__FILE__` keyword.
@@ -4259,6 +4519,7 @@ nodes:
- name: arguments
type: node?
kind: ArgumentsNode
+ comment: "Can be only `nil` when there are empty parentheses, like `super()`."
- name: rparen_loc
type: location?
- name: block
@@ -4274,6 +4535,8 @@ nodes:
super foo, bar
^^^^^^^^^^^^^^
+
+ If no arguments are provided (except for a block), it would be a `ForwardingSuperNode` instead.
- name: SymbolNode
flags: SymbolFlags
fields:
@@ -4318,7 +4581,7 @@ nodes:
- name: keyword_loc
type: location
comment: |
- The location of the `unless` keyword.
+ The Location of the `unless` keyword.
unless cond then bar end
^^^^^^
@@ -4339,7 +4602,7 @@ nodes:
- name: then_keyword_loc
type: location?
comment: |
- The location of the `then` keyword, if present.
+ The Location of the `then` keyword, if present.
unless cond then bar end
^^^^
@@ -4359,11 +4622,11 @@ nodes:
The else clause of the unless expression, if present.
unless cond then bar else baz end
- ^^^^^^^^
+ ^^^^^^^^^^^^
- name: end_keyword_loc
type: location?
comment: |
- The location of the `end` keyword, if present.
+ The Location of the `end` keyword, if present.
unless cond then bar end
^^^