mylang_lexer/transition/
i32.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use mylang_token::{Pos, Token};

use crate::state::i32::I32State;

pub enum I32LexResult {
    Continued(I32State),
    Interrupted(Token),
}

pub fn i32_lex(i32_state: &I32State, (pos, c): (Pos, char)) -> I32LexResult {
    match c {
        '_' => I32LexResult::Continued(i32_state.clone()),

        c if c.is_ascii_digit() => I32LexResult::Continued(i32_state.append_digit_char(pos, c)),

        _ => I32LexResult::Interrupted(i32_state.tokenize()),
    }
}