diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-01-30 12:09:26 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-01-30 12:09:26 +0100 |
| commit | 89eb8bae49edb71d9a9279a2210bb1ccaf4dd707 (patch) | |
| tree | 160b1a2ff41b5bba8a58f882df9d10c9eb036cf2 /src/parse/parser.rs | |
| parent | ac24075469f171fe83a976b9a97b9b1ea078a7e3 (diff) | |
New syntax 💎
- Everything everywhere!
- Blocks with curly braces: {}
- Templates with brackets: []
- Function templates with hashtag: `#[f]`
- Headings with equals sign: `= Introduction`
Diffstat (limited to 'src/parse/parser.rs')
| -rw-r--r-- | src/parse/parser.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/parse/parser.rs b/src/parse/parser.rs index 906d9e62..2ca8eb10 100644 --- a/src/parse/parser.rs +++ b/src/parse/parser.rs @@ -105,9 +105,9 @@ impl<'s> Parser<'s> { self.repeek(); match group { - Group::Paren => self.assert(Token::LeftParen), - Group::Bracket => self.assert(Token::LeftBracket), - Group::Brace => self.assert(Token::LeftBrace), + Group::Paren => self.assert(&[Token::LeftParen]), + Group::Bracket => self.assert(&[Token::HashBracket, Token::LeftBracket]), + Group::Brace => self.assert(&[Token::LeftBrace]), Group::Subheader => {} Group::Stmt => {} Group::Expr => {} @@ -210,10 +210,10 @@ impl<'s> Parser<'s> { eaten } - /// Consume the next token, debug-asserting that it is the given one. - pub fn assert(&mut self, t: Token) { + /// Consume the next token, debug-asserting that it is one of the given ones. + pub fn assert(&mut self, ts: &[Token]) { let next = self.eat(); - debug_assert_eq!(next, Some(t)); + debug_assert!(next.map_or(false, |n| ts.contains(&n))); } /// Skip whitespace and comment tokens. |
