forked from argotorg/fe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlit.rs
More file actions
24 lines (19 loc) · 658 Bytes
/
Copy pathlit.rs
File metadata and controls
24 lines (19 loc) · 658 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use std::convert::Infallible;
use crate::SyntaxKind;
use super::{Parser, define_scope, token_stream::TokenStream};
define_scope! { pub(crate) LitScope, Lit }
impl super::Parse for LitScope {
type Error = Infallible;
/// Caller is expected to verify that the next token is a literal.
fn parse<S: TokenStream>(&mut self, parser: &mut Parser<S>) -> Result<(), Self::Error> {
assert!(is_lit(parser.current_kind().unwrap()));
parser.bump();
Ok(())
}
}
pub fn is_lit(kind: SyntaxKind) -> bool {
matches!(
kind,
SyntaxKind::Int | SyntaxKind::TrueKw | SyntaxKind::FalseKw | SyntaxKind::String
)
}