11use std:: { iter:: Peekable , str:: Chars } ;
22
33use error:: LexerResult ;
4- use tokens:: { LexerLiteral , LexerToken , LexerTokenKind , LexerTokenList } ;
4+ use tokens:: { LexerTokenValue , LexerToken , LexerTokenKind , LexerTokenList } ;
55
66use crate :: {
77 component:: { ComponentErrors , ComponentIter } , constants:: { MAX_I32_LEN , MAX_I64_LEN } , cursor:: Cursor , error:: { EngineErrorKind , ErrorList } , parser:: expr:: ShellCommand
@@ -93,7 +93,7 @@ impl<'a> Lexer<'a> {
9393 fn scan_char (
9494 & mut self ,
9595 char : & char ,
96- ) -> LexerResult < Option < ( LexerTokenKind , Option < Box < LexerLiteral > > ) > > {
96+ ) -> LexerResult < Option < ( LexerTokenKind , Option < Box < LexerTokenValue > > ) > > {
9797 macro_rules! check_double {
9898 ( $single_type: expr, $double: tt, $double_type: expr) => {
9999 if self . next_if_eq( & $double) . is_some( ) {
@@ -142,7 +142,7 @@ impl<'a> Lexer<'a> {
142142 return Ok ( None ) ;
143143 } ;
144144
145- return Ok ( Some ( ( Integer , Some ( Box :: from ( LexerLiteral :: Integer ( -self . eat_number ( char) ?) ) ) ) ) ) ;
145+ return Ok ( Some ( ( Integer , Some ( Box :: from ( LexerTokenValue :: Integer ( -self . eat_number ( char) ?) ) ) ) ) ) ;
146146 }
147147 _ => Minus ,
148148 } ,
@@ -187,7 +187,7 @@ impl<'a> Lexer<'a> {
187187 '0' ..='9' => {
188188 return Ok ( Some ( (
189189 Integer ,
190- Some ( Box :: from ( LexerLiteral :: Integer ( self . eat_number ( * char) ?) ) ) ,
190+ Some ( Box :: from ( LexerTokenValue :: Integer ( self . eat_number ( * char) ?) ) ) ,
191191 ) ) )
192192 }
193193 '"' => return Ok ( Some ( self . consume_string ( ) ?) ) ,
@@ -219,10 +219,10 @@ impl<'a> Lexer<'a> {
219219 "and" => And ,
220220 "or" => Or ,
221221
222- "true" => return Ok ( Some ( ( Boolean , Some ( Box :: from ( LexerLiteral :: Boolean ( true ) ) ) ) ) ) ,
223- "false" => return Ok ( Some ( ( Boolean , Some ( Box :: from ( LexerLiteral :: Boolean ( false ) ) ) ) ) ) ,
222+ "true" => return Ok ( Some ( ( Boolean , Some ( Box :: from ( LexerTokenValue :: Boolean ( true ) ) ) ) ) ) ,
223+ "false" => return Ok ( Some ( ( Boolean , Some ( Box :: from ( LexerTokenValue :: Boolean ( false ) ) ) ) ) ) ,
224224
225- _ if Self :: is_valid_identifier ( char) => return Ok ( Some ( ( Identifier , Some ( Box :: from ( LexerLiteral :: Identifier ( Box :: from ( word) ) ) ) ) ) ) ,
225+ _ if Self :: is_valid_identifier ( char) => return Ok ( Some ( ( Identifier , Some ( Box :: from ( LexerTokenValue :: Identifier ( Box :: from ( word) ) ) ) ) ) ) ,
226226 _ => return Err ( LexerErrorKind :: UnknownToken ) ,
227227 }
228228 }
@@ -234,7 +234,7 @@ impl<'a> Lexer<'a> {
234234 fn add_token (
235235 & mut self ,
236236 token_type : LexerTokenKind ,
237- value : Option < Box < LexerLiteral > > ,
237+ value : Option < Box < LexerTokenValue > > ,
238238 start : Cursor ,
239239 ) {
240240 self . tokens . push ( LexerToken {
@@ -279,7 +279,7 @@ impl<'a> Lexer<'a> {
279279 }
280280
281281 /// Attempts to return a [`TokenType::String`]
282- fn consume_string ( & mut self ) -> LexerResult < ( LexerTokenKind , Option < Box < LexerLiteral > > ) > {
282+ fn consume_string ( & mut self ) -> LexerResult < ( LexerTokenKind , Option < Box < LexerTokenValue > > ) > {
283283 let string = self . eat_until ( & [ '"' , '\n' ] , true ) . unwrap_or_default ( ) ;
284284
285285 if let Err ( err) = self . expect_char ( & '"' ) {
@@ -292,14 +292,14 @@ impl<'a> Lexer<'a> {
292292
293293 Ok ( (
294294 LexerTokenKind :: String ,
295- Some ( Box :: from ( LexerLiteral :: String ( Box :: from ( string) ) ) ) ,
295+ Some ( Box :: from ( LexerTokenValue :: String ( Box :: from ( string) ) ) ) ,
296296 ) )
297297 }
298298
299299 /// Attempts to return a [`TokenType::ShellCommand`]
300300 fn consume_shell_command (
301301 & mut self ,
302- ) -> LexerResult < ( LexerTokenKind , Option < Box < LexerLiteral > > ) > {
302+ ) -> LexerResult < ( LexerTokenKind , Option < Box < LexerTokenValue > > ) > {
303303 let cmd_name = self
304304 . eat_until ( & [ ' ' , '\t' , '\n' , '(' ] , false )
305305 . ok_or ( LexerErrorKind :: UnexpectedEnd ) ?;
@@ -323,7 +323,7 @@ impl<'a> Lexer<'a> {
323323
324324 Ok ( (
325325 LexerTokenKind :: ShellCommand ,
326- Some ( Box :: from ( LexerLiteral :: ShellCommand ( Box :: from ( ShellCommand ( cmd_name, cmd_args) ) ) ) ) ,
326+ Some ( Box :: from ( LexerTokenValue :: ShellCommand ( Box :: from ( ShellCommand ( cmd_name, cmd_args) ) ) ) ) ,
327327 ) )
328328 }
329329
0 commit comments