-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(parser): Parser error optimisation (#1292)
* chore(parser): optimize errors by: - switching labels to enums - Using LateAllocSet in place of BTreeSet * chore(parser): wrap LateAllocSet enum in struct * chore(parser): fix comment table formatting * chore(parser): ParserError to use SmallOrdSet * chore(parser): ParserLabel -> ParsingRuleLabel * chore(parser): tidy iter usage * chore(parser): tweak SmallOrdSet sizes
- Loading branch information
1 parent
fa1af50
commit e123aa7
Showing
10 changed files
with
132 additions
and
50 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use std::fmt; | ||
|
||
use crate::token::TokenKind; | ||
|
||
/// Used to annotate parsing rules with extra context that can be presented to the user later in | ||
/// the case of an error. | ||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] | ||
pub enum ParsingRuleLabel { | ||
Atom, | ||
BinaryOperator, | ||
Cast, | ||
Expression, | ||
FieldAccess, | ||
Global, | ||
IntegerType, | ||
Parameter, | ||
Pattern, | ||
Statement, | ||
Term, | ||
TypeExpression, | ||
TokenKind(TokenKind), | ||
} | ||
|
||
impl fmt::Display for ParsingRuleLabel { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
match self { | ||
ParsingRuleLabel::Atom => write!(f, "atom"), | ||
ParsingRuleLabel::BinaryOperator => write!(f, "binary operator"), | ||
ParsingRuleLabel::Cast => write!(f, "cast"), | ||
ParsingRuleLabel::Expression => write!(f, "expression"), | ||
ParsingRuleLabel::FieldAccess => write!(f, "field access"), | ||
ParsingRuleLabel::Global => write!(f, "global"), | ||
ParsingRuleLabel::IntegerType => write!(f, "integer type"), | ||
ParsingRuleLabel::Parameter => write!(f, "parameter"), | ||
ParsingRuleLabel::Pattern => write!(f, "pattern"), | ||
ParsingRuleLabel::Statement => write!(f, "statement"), | ||
ParsingRuleLabel::Term => write!(f, "term"), | ||
ParsingRuleLabel::TypeExpression => write!(f, "type expression"), | ||
ParsingRuleLabel::TokenKind(token_kind) => write!(f, "{:?}", token_kind), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.