Skip to content

Commit

Permalink
Add PredefinedLabel::Missing to represent nodes that could not be r…
Browse files Browse the repository at this point in the history
…esolved.
  • Loading branch information
mjoerussell committed Jan 14, 2025
1 parent 756deb9 commit 0eca315
Show file tree
Hide file tree
Showing 52 changed files with 110 additions and 156 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/codegen/language/definition/src/model/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ pub struct Topic {
pub enum PredefinedLabel {
Root,
Unrecognized,
Missing,
Item,
Variant,
Separator,
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,10 @@ where
}
}
let input = &input[start.utf8..];
let kind = if input.is_empty() {
TerminalKind::MISSING
let (kind, label) = if input.is_empty() {
(TerminalKind::MISSING, EdgeLabel::Missing)
} else {
TerminalKind::UNRECOGNIZED
};

let label = if kind == TerminalKind::UNRECOGNIZED {
EdgeLabel::Unrecognized
} else {
EdgeLabel::default()
(TerminalKind::UNRECOGNIZED, EdgeLabel::Unrecognized)
};

let node = Node::terminal(kind, input.to_string());
Expand Down Expand Up @@ -146,16 +140,10 @@ where
} else {
start
};
let kind = if input[start..].is_empty() {
TerminalKind::MISSING
} else {
TerminalKind::UNRECOGNIZED
};

let label = if kind == TerminalKind::UNRECOGNIZED {
EdgeLabel::Unrecognized
let (kind, label) = if input[start..].is_empty() {
(TerminalKind::MISSING, EdgeLabel::Missing)
} else {
EdgeLabel::default()
(TerminalKind::UNRECOGNIZED, EdgeLabel::Unrecognized)
};

let skipped_node = Node::terminal(kind, input[start..].to_string());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,10 @@ impl SeparatedHelper {
match skip_until_with_nested_delims::<_, LexCtx>(input, lexer, separator) {
// A separator was found, so we can recover the incomplete match
Some((found, skipped_range)) if found == separator => {
let kind = if skipped_range.is_empty() {
TerminalKind::MISSING
let (kind, label) = if skipped_range.is_empty() {
(TerminalKind::MISSING, EdgeLabel::Missing)
} else {
TerminalKind::UNRECOGNIZED
};

let label = if kind == TerminalKind::UNRECOGNIZED {
EdgeLabel::Unrecognized
} else {
EdgeLabel::default()
(TerminalKind::UNRECOGNIZED, EdgeLabel::Unrecognized)
};

accum.push(Edge {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,10 @@ impl SequenceHelper {
});
debug_assert_eq!(next_terminal, Ok(Some(running.found)));

let kind = if running.skipped.is_empty() {
TerminalKind::MISSING
let (kind, label) = if running.skipped.is_empty() {
(TerminalKind::MISSING, EdgeLabel::Missing)
} else {
TerminalKind::UNRECOGNIZED
};

let label = if kind == TerminalKind::UNRECOGNIZED {
EdgeLabel::Unrecognized
} else {
EdgeLabel::default()
(TerminalKind::UNRECOGNIZED, EdgeLabel::Unrecognized)
};

running.nodes.push(Edge{label, node: Node::terminal(
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.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Tree:
- (leading_trivia꞉ Whitespace): " " # (16..18)
- (item꞉ Identifier): "field" # (18..23)
- (attributes꞉ StateVariableAttributes): [] # (23..23)
- (root꞉ MISSING): "" # (23..23)
- (missing꞉ MISSING): "" # (23..23)
- (semicolon꞉ Semicolon): ";" # (23..24)
- (trailing_trivia꞉ EndOfLine): "\n" # (24..25)
- (close_brace꞉ CloseBrace): "}" # (25..26)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Tree:
- (leading_trivia꞉ Whitespace): " " # (16..18)
- (item꞉ Identifier): "field" # (18..23)
- (attributes꞉ StateVariableAttributes): [] # (23..23)
- (root꞉ MISSING): "" # (23..23)
- (missing꞉ MISSING): "" # (23..23)
- (semicolon꞉ Semicolon): ";" # (23..24)
- (trailing_trivia꞉ EndOfLine): "\n" # (24..25)
- (close_brace꞉ CloseBrace): "}" # (25..26)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Tree:
- (leading_trivia꞉ Whitespace): " " # (16..18)
- (item꞉ Identifier): "field" # (18..23)
- (attributes꞉ StateVariableAttributes): [] # (23..23)
- (root꞉ MISSING): "" # (23..23)
- (missing꞉ MISSING): "" # (23..23)
- (semicolon꞉ Semicolon): ";" # (23..24)
- (trailing_trivia꞉ EndOfLine): "\n" # (24..25)
- (close_brace꞉ CloseBrace): "}" # (25..26)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Tree:
- (leading_trivia꞉ Whitespace): " " # (16..18)
- (item꞉ Identifier): "field" # (18..23)
- (attributes꞉ StateVariableAttributes): [] # (23..23)
- (root꞉ MISSING): "" # (23..23)
- (missing꞉ MISSING): "" # (23..23)
- (semicolon꞉ Semicolon): ";" # (23..24)
- (trailing_trivia꞉ EndOfLine): "\n" # (24..25)
- (close_brace꞉ CloseBrace): "}" # (25..26)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Tree:
- (leading_trivia꞉ Whitespace): " " # (195..196)
- (name꞉ Identifier): "sequence" # (196..204)
- (leading_trivia꞉ Whitespace): " " # (204..205)
- (root꞉ MISSING): "" # (205..205)
- (missing꞉ MISSING): "" # (205..205)
- (close_brace꞉ CloseBrace): "}" # (205..206)
- (trailing_trivia꞉ EndOfLine): "\n" # (206..207)
- (leading_trivia꞉ Whitespace): "\t" # (207..208)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ Tree:
- (leading_trivia꞉ Whitespace): " " # (15..16)
- (open_brace꞉ OpenBrace): "{" # (16..17)
- (members꞉ ContractMembers): [] # (17..17)
- (root꞉ MISSING): "" # (17..17)
- (missing꞉ MISSING): "" # (17..17)
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ Tree:
- (leading_trivia꞉ Whitespace): " " # (15..16)
- (open_brace꞉ OpenBrace): "{" # (16..17)
- (members꞉ ContractMembers): [] # (17..17)
- (root꞉ MISSING): "" # (17..17)
- (missing꞉ MISSING): "" # (17..17)
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ Tree:
- (leading_trivia꞉ Whitespace): " " # (15..16)
- (open_brace꞉ OpenBrace): "{" # (16..17)
- (members꞉ ContractMembers): [] # (17..17)
- (root꞉ MISSING): "" # (17..17)
- (missing꞉ MISSING): "" # (17..17)
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ Tree:
- (leading_trivia꞉ Whitespace): " " # (15..16)
- (open_brace꞉ OpenBrace): "{" # (16..17)
- (members꞉ ContractMembers): [] # (17..17)
- (root꞉ MISSING): "" # (17..17)
- (missing꞉ MISSING): "" # (17..17)
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ Tree:
- (leading_trivia꞉ Whitespace): " " # (15..16)
- (open_brace꞉ OpenBrace): "{" # (16..17)
- (members꞉ ContractMembers): [] # (17..17)
- (root꞉ MISSING): "" # (17..17)
- (missing꞉ MISSING): "" # (17..17)
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ Tree:
- (leading_trivia꞉ Whitespace): " " # (15..16)
- (open_brace꞉ OpenBrace): "{" # (16..17)
- (members꞉ ContractMembers): [] # (17..17)
- (root꞉ MISSING): "" # (17..17)
- (missing꞉ MISSING): "" # (17..17)
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ Tree:
- (item꞉ Expression): # "some." (522..527)
- (variant꞉ Identifier): "some" # (522..526)
- (period꞉ Period): "." # (526..527)
- (root꞉ MISSING): "" # (527..527)
- (missing꞉ MISSING): "" # (527..527)
- (root꞉ Comma): "," # (527..528)
- (item꞉ Expression) ► (variant꞉ MemberAccessExpression): # " next.arg" (528..537)
- (operand꞉ Expression): # " next" (528..533)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ Tree:
- (item꞉ IdentifierPath): # "some." (522..527)
- (item꞉ Identifier): "some" # (522..526)
- (separator꞉ Period): "." # (526..527)
- (root꞉ MISSING): "" # (527..527)
- (missing꞉ MISSING): "" # (527..527)
- (root꞉ Comma): "," # (527..528)
- (item꞉ IdentifierPath): # " next.arg" (528..537)
- (leading_trivia꞉ Whitespace): " " # (528..529)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Tree:
- (item꞉ NamedArgument): # " no_semicolon" (208..221)
- (leading_trivia꞉ Whitespace): " " # (208..209)
- (name꞉ Identifier): "no_semicolon" # (209..221)
- (root꞉ MISSING): "" # (221..221)
- (missing꞉ MISSING): "" # (221..221)
- (root꞉ Comma): "," # (221..222)
- (leading_trivia꞉ Whitespace): " " # (222..223)
- (unrecognized꞉ UNRECOGNIZED): ", " # (223..225)
Expand Down Expand Up @@ -334,7 +334,7 @@ Tree:
- (item꞉ IdentifierPath): # "some." (522..527)
- (item꞉ Identifier): "some" # (522..526)
- (separator꞉ Period): "." # (526..527)
- (root꞉ MISSING): "" # (527..527)
- (missing꞉ MISSING): "" # (527..527)
- (root꞉ Comma): "," # (527..528)
- (item꞉ IdentifierPath): # " next.arg" (528..537)
- (leading_trivia꞉ Whitespace): " " # (528..529)
Expand Down
Loading

0 comments on commit 0eca315

Please sign in to comment.