wagon_parser/parser/
ident.rs1
2use crate::parser::Tokens;
3
4use super::{WagParseError, Spannable};
5use wagon_macros::match_error;
6
7use crate::either_token;
8
9use super::{Parse, Ident, ResultPeek};
10
11impl Parse for Ident {
12 fn parse(lexer: &mut wagon_lexer::LexerBridge) -> super::ParseResult<Self> {
13 let next: Tokens = lexer.peek_result()?.to_owned();
14 match_error!(
15 match next {
16 #[expect("identifier")]
17 either_token!(Identifier(_)) => {
18 let real = lexer.next();
19 match real {
20 Some(Ok(x)) => {
21 match_error!(
22 match x {
23 #[expect("identifier")]
24 either_token!(Identifier(y)) => Ok(y),
25 }
26 )
27 },
28 _ => Err(WagParseError::Fatal((lexer.span(), "Unable to properly unwrap identifier".to_string()))),
29 }
30 }
31 }
32 )
33 }
34}