Skip to content

Commit

Permalink
fix!: don't parse NaN, inf, and infinity as floats
Browse files Browse the repository at this point in the history
We could have resolved this the other way, by marking these keywords as
reserved, but the Quil spec doesn't allow for `NaN` or `Infinity` and I think
this is more useful for our purposes.
  • Loading branch information
antalsz committed Jan 9, 2025
1 parent ec9ca5e commit 6d682d7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion quil-rs/src/parser/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,12 @@ fn lex_token(input: LexInput) -> InternalLexResult<TokenWithLocation> {
token_with_location(lex_string),
// Operator must come before number (or it may be parsed as a prefix)
token_with_location(lex_operator),
token_with_location(lex_number),
token_with_location(lex_variable),
// Identifiers must come before numbers so that `NaN`, `Inf`, and `Infinity` aren't
// parsed as floats; Nom, as of version 7.1.1, will parse those strings,
// case-insensitively, as floats
token_with_location(lex_keyword_or_identifier),
token_with_location(lex_number),
),
)(input)
}
Expand Down

0 comments on commit 6d682d7

Please sign in to comment.