Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 9 additions & 37 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,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.

Expand Down Expand Up @@ -853,8 +851,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.

Expand Down Expand Up @@ -1867,7 +1863,6 @@ nodes:
kind:
- ConstantReadNode
- ConstantPathNode
- on error: CallNode # class 0.X end
- name: inheritance_operator_loc
type: location?
comment: |
Expand Down Expand Up @@ -2422,6 +2417,13 @@ nodes:
^^^^^^
bar
end
- name: ErrorRecoveryNode
fields:
- name: child
type: node?
kind: Node
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.
Expand Down Expand Up @@ -2464,9 +2466,7 @@ nodes:
^^^^^^
- name: right
type: node
kind:
- SplatNode
- on error: MissingNode
kind: SplatNode
comment: |
Represents the second wildcard node in the pattern.

Expand Down Expand Up @@ -2549,9 +2549,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.

Expand Down Expand Up @@ -3305,10 +3302,6 @@ nodes:
- EmbeddedStatementsNode
- EmbeddedVariableNode
- InterpolatedStringNode # `"a" "#{b}"`
- on error: XStringNode # `<<`FOO` "bar"
- on error: InterpolatedXStringNode
- on error: SymbolNode
- on error: InterpolatedSymbolNode
- name: closing_loc
type: location?
newline: parts
Expand Down Expand Up @@ -3686,9 +3679,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
Expand All @@ -3700,7 +3690,6 @@ nodes:
kind:
- ConstantReadNode
- ConstantPathNode
- on error: MissingNode # module Parent module end
- name: body
type: node?
kind:
Expand Down Expand Up @@ -3730,8 +3719,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.

Expand Down Expand Up @@ -3775,8 +3762,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.

Expand Down Expand Up @@ -3820,8 +3805,6 @@ nodes:
- CallTargetNode
- IndexTargetNode
- MultiTargetNode
- on error: BackReferenceReadNode # $&, = z
- on error: NumberedReferenceReadNode # $1, = z
comment: |
Represents the targets expressions before a splat node.

Expand Down Expand Up @@ -3864,8 +3847,6 @@ nodes:
- CallTargetNode
- IndexTargetNode
- MultiTargetNode
- on error: BackReferenceReadNode # *, $& = z
- on error: NumberedReferenceReadNode # *, $1 = z
comment: |
Represents the targets expressions after a splat node.

Expand Down Expand Up @@ -4051,11 +4032,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:
Expand Down Expand Up @@ -4140,7 +4116,6 @@ 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

Expand Down Expand Up @@ -4223,7 +4198,7 @@ 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: |
Expand Down Expand Up @@ -4338,9 +4313,6 @@ 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
Expand Down
4 changes: 2 additions & 2 deletions lib/prism/node_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def child
if name
ConstantReadNode.new(source, -1, name_loc, 0, name)
else
MissingNode.new(source, -1, location, 0)
ErrorRecoveryNode.new(source, -1, location, 0, nil)
end
end
end
Expand Down Expand Up @@ -249,7 +249,7 @@ def child
if name
ConstantReadNode.new(source, -1, name_loc, 0, name)
else
MissingNode.new(source, -1, location, 0)
ErrorRecoveryNode.new(source, -1, location, 0, nil)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion rakelib/lint.rake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ task :lint do
exit(1)
end

if (uncommented = nodes.select { |node| !%w[MissingNode ProgramNode].include?(node.fetch("name")) && !node.fetch("comment").match?(/^\s{4}/) }).any?
if (uncommented = nodes.select { |node| !%w[ErrorRecoveryNode ProgramNode].include?(node.fetch("name")) && !node.fetch("comment").match?(/^\s{4}/) }).any?
names = uncommented.map { |node| node.fetch("name") }
warn("Expected all nodes to have an example, missing comments for #{names.join(", ")}")
exit(1)
Expand Down
17 changes: 1 addition & 16 deletions rust/ruby-prism/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,12 @@ enum NodeFieldType {
Double,
}

#[derive(Debug, Deserialize)]
#[allow(dead_code)]
struct OnErrorType {
#[serde(rename = "on error")]
kind: String,
}

#[derive(Debug, Deserialize)]
#[serde(untagged)]
#[allow(dead_code)]
enum UnionKind {
OnSuccess(String),
OnError(OnErrorType),
}

#[derive(Debug, Deserialize)]
#[serde(untagged)]
#[allow(dead_code)]
enum NodeFieldKind {
Concrete(String),
Union(Vec<UnionKind>),
Union(Vec<String>),
}

#[derive(Debug, Deserialize)]
Expand Down
6 changes: 3 additions & 3 deletions sig/prism/node_ext.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@ module Prism
class DynamicPartsInConstantPathError < StandardError
end

class MissingNodesInConstantPathError < StandardError
class ErrorRecoveryNodesInConstantPathError < StandardError
end

def full_name_parts: () -> Array[Symbol]
def full_name: () -> String
def child: () -> (ConstantReadNode | MissingNode)
def child: () -> (ConstantReadNode | ErrorRecoveryNode)
end

class ConstantPathTargetNode < Node
def full_name_parts: () -> Array[Symbol]
def full_name: () -> String
def child: () -> (ConstantReadNode | MissingNode)
def child: () -> (ConstantReadNode | ErrorRecoveryNode)
end

class ConstantTargetNode < Node
Expand Down
Loading
Loading