From e47e739e02df08b9bf94bab3a8063d2727469234 Mon Sep 17 00:00:00 2001 From: Erin Date: Mon, 4 Oct 2021 23:03:23 +0200 Subject: [PATCH] Generalised some lexer functions --- ablescript/src/lexer.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ablescript/src/lexer.rs b/ablescript/src/lexer.rs index 24ee265b..a6c5940b 100644 --- a/ablescript/src/lexer.rs +++ b/ablescript/src/lexer.rs @@ -117,7 +117,7 @@ pub enum Token { // Literals /// True, False - #[regex("true|false", get_bool)] + #[regex("true|false", get_value)] Bool(bool), /// Always, Sometimes, Never @@ -133,7 +133,7 @@ pub enum Token { String(String), /// Integer - #[regex(r"-?[0-9]+", get_int)] + #[regex(r"-?[0-9]+", get_value)] Integer(i32), /// A C-complaint identifier @@ -151,11 +151,7 @@ pub enum Token { Error, } -fn get_bool(lexer: &mut Lexer) -> Option { - lexer.slice().parse().ok() -} - -fn get_int(lexer: &mut Lexer) -> Option { +fn get_value(lexer: &mut Lexer) -> Option { lexer.slice().parse().ok() }