-
-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(parser,css_parser): implement checkpoint rewinding (#1417)
- Loading branch information
1 parent
d869a33
commit 9f46988
Showing
11 changed files
with
254 additions
and
80 deletions.
There are no files selected for viewing
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,22 @@ | ||
pub(crate) struct CssParserState { | ||
/// Indicates that the parser is speculatively parsing a syntax. Speculative parsing means that the | ||
/// parser tries to parse a syntax as one kind and determines at the end if the assumption was right | ||
/// by testing if the parser is at a specific token (or has no errors). For this approach to work, | ||
/// the parser isn't allowed to skip any tokens while doing error recovery because it may then successfully | ||
/// skip over all invalid tokens, so that it appears as if it was able to parse the syntax correctly. | ||
/// | ||
/// Speculative parsing is useful if a syntax is ambiguous and no amount of lookahead (except parsing the whole syntax) | ||
/// is sufficient to determine what syntax it is. For example, the syntax `(a, b) ...` | ||
/// in JavaScript is either a parenthesized expression or an arrow expression if `...` is a `=>`. | ||
/// The challenge is, that it isn't possible to tell which of the two kinds it is until the parser | ||
/// processed all of `(a, b)`. | ||
pub(crate) speculative_parsing: bool, | ||
} | ||
|
||
impl CssParserState { | ||
pub fn new() -> Self { | ||
Self { | ||
speculative_parsing: false, | ||
} | ||
} | ||
} |
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
Oops, something went wrong.