Skip to content

Commit

Permalink
Rename Edge::anonymous() to Edge::root()
Browse files Browse the repository at this point in the history
  • Loading branch information
mjoerussell committed Jan 3, 2025
1 parent 26729fa commit 790f5d5
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@ pub(crate) trait Lexer {
let end = input.position();

ParserResult::r#match(
vec![Edge::anonymous(Node::terminal(
kind,
input.content(start..end),
))],
vec![Edge::root(Node::terminal(kind, input.content(start..end)))],
vec![],
)
}
Expand Down Expand Up @@ -132,10 +129,7 @@ pub(crate) trait Lexer {
return ParserResult::no_match(None, vec![kind]);
}
let end = input.position();
children.push(Edge::anonymous(Node::terminal(
kind,
input.content(start..end),
)));
children.push(Edge::root(Node::terminal(kind, input.content(start..end))));

let restore = input.position();
if let ParserResult::Match(r#match) = self.trailing_trivia(input) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ where
let tree = if no_match.kind.is_none() || start.utf8 == 0 {
node
} else {
trivia_nodes.push(Edge::anonymous(node));
trivia_nodes.push(Edge::root(node));
Node::nonterminal(no_match.kind.unwrap(), trivia_nodes)
};
ParseOutput {
Expand Down Expand Up @@ -146,7 +146,7 @@ where
};
let skipped_node = Node::terminal(kind, input[start..].to_string());
let mut new_children = topmost_node.children.clone();
new_children.push(Edge::anonymous(skipped_node));
new_children.push(Edge::root(skipped_node));

let start_index = stream.text_index_at(start);
let mut errors = stream.into_errors();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ impl ParserResult {
pub fn with_kind(self, new_kind: NonterminalKind) -> ParserResult {
match self {
ParserResult::Match(r#match) => ParserResult::r#match(
vec![Edge::anonymous(Node::nonterminal(new_kind, r#match.nodes))],
vec![Edge::root(Node::nonterminal(new_kind, r#match.nodes))],
r#match.expected_terminals,
),
ParserResult::IncompleteMatch(incomplete_match) => ParserResult::incomplete_match(
vec![Edge::anonymous(Node::nonterminal(
vec![Edge::root(Node::nonterminal(
new_kind,
incomplete_match.nodes,
))],
incomplete_match.expected_terminals,
),
ParserResult::SkippedUntil(skipped) => ParserResult::SkippedUntil(SkippedUntil {
nodes: vec![Edge::anonymous(Node::nonterminal(new_kind, skipped.nodes))],
nodes: vec![Edge::root(Node::nonterminal(new_kind, skipped.nodes))],
..skipped
}),
ParserResult::NoMatch(no_match) => {
Expand Down Expand Up @@ -176,7 +176,7 @@ impl PrattElement {
Self::Binary { kind, nodes, .. }
| Self::Prefix { kind, nodes, .. }
| Self::Postfix { kind, nodes, .. } => {
vec![Edge::anonymous(Node::nonterminal(kind, nodes))]
vec![Edge::root(Node::nonterminal(kind, nodes))]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl SeparatedHelper {
} else {
TerminalKind::UNRECOGNIZED
};
accum.push(Edge::anonymous(Node::terminal(
accum.push(Edge::root(Node::terminal(
kind,
input.content(skipped_range.utf8()),
)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl SequenceHelper {
} else {
TerminalKind::UNRECOGNIZED
};
running.nodes.push(Edge::anonymous(Node::terminal(
running.nodes.push(Edge::root(Node::terminal(
kind,
std::mem::take(&mut running.skipped),
)));
Expand Down
2 changes: 1 addition & 1 deletion crates/metaslang/cst/generated/public_api.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/metaslang/cst/src/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ pub struct Edge<T: KindTypes> {
}

impl<T: KindTypes> Edge<T> {
/// Creates an anonymous node (without a label).
pub fn anonymous(node: Node<T>) -> Self {
/// Creates an edge to a root node (using the default label).
pub fn root(node: Node<T>) -> Self {
Self {
label: T::EdgeLabel::default(),
node,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 790f5d5

Please sign in to comment.