You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.
Right now (master @ 5fd1e32), the huff_lexer incorrectly parses bytes / hex number tokens.
Failing Test
#[test]fnparses_bytes(){let source = "0xDDF252AD1BE2C89B69C2B068FC378DAA952BA7F163C4A11628F55A4DF523B3EF";letmut lexer = Lexer::new(source);assert_eq!(lexer.source, source);// Try to parse the bytes token (assuming that it is a single token)let tok = lexer.next();let unwrapped = tok.unwrap().unwrap();let bytes_span = Span::new(0..source.len());assert_eq!(unwrapped, Token::new(TokenKind::Ident(source), bytes_span));assert_eq!(lexer.span, bytes_span);// We covered the whole sourceassert_eq!(lexer.span.end, source.len());assert!(lexer.eof);assert!(lexer.next().is_none());}
The lexer dyn_consumes all valid ascii digits when it comes across what it thinks is a TokenKind::Num. When dyn_consume hits the second character of a bytes / hex number token, x, it completes, splitting the bytes / hex number token into two parts: The TokenKind::Num(0) and the TokenKind::Ident("xDDF252AD1BE2C89B69C2B068FC378DAA952BA7F163C4A11628F55A4DF523B3EF"). Some extra logic needs to be added to this match arm in order to correctly lex these tokens.
The text was updated successfully, but these errors were encountered:
Overview
Right now (master @ 5fd1e32), the
huff_lexer
incorrectly parses bytes / hex number tokens.Failing Test
Expected Result
tok = Token { kind: Ident("0xDDF252AD1BE2C89B69C2B068FC378DAA952BA7F163C4A11628F55A4DF523B3EF"), span: Span { start: 0, end: 66 } }
Or a dedicated
TokenKind
variant for bytes / hex tokens.Actual Result
tok = Token { kind: Num(0), span: Span { start: 0, end: 1 } }
Suspected Reason for Issue
The lexer
dyn_consume
s all valid ascii digits when it comes across what it thinks is aTokenKind::Num
. Whendyn_consume
hits the second character of a bytes / hex number token,x
, it completes, splitting the bytes / hex number token into two parts: TheTokenKind::Num(0)
and theTokenKind::Ident("xDDF252AD1BE2C89B69C2B068FC378DAA952BA7F163C4A11628F55A4DF523B3EF")
. Some extra logic needs to be added to this match arm in order to correctly lex these tokens.The text was updated successfully, but these errors were encountered: