throw syntax error after parsing infinite floats (#2998)
This commit is contained in:
@@ -432,6 +432,7 @@ pub enum ParserError {
|
||||
BackQuotedString(usize, usize),
|
||||
IO(IOError),
|
||||
IncompleteReduction(usize, usize),
|
||||
InfiniteFloat(usize, usize),
|
||||
InvalidSingleQuotedCharacter(char),
|
||||
LexicalError(lexical::Error),
|
||||
MissingQuote(usize, usize),
|
||||
@@ -447,6 +448,7 @@ impl ParserError {
|
||||
match self {
|
||||
&ParserError::BackQuotedString(line_num, col_num)
|
||||
| &ParserError::IncompleteReduction(line_num, col_num)
|
||||
| &ParserError::InfiniteFloat(line_num, col_num)
|
||||
| &ParserError::MissingQuote(line_num, col_num)
|
||||
| &ParserError::NonPrologChar(line_num, col_num)
|
||||
| &ParserError::ParseBigInt(line_num, col_num)
|
||||
@@ -463,6 +465,9 @@ impl ParserError {
|
||||
ParserError::InvalidSingleQuotedCharacter(..) => {
|
||||
atom!("invalid_single_quoted_character")
|
||||
}
|
||||
ParserError::InfiniteFloat(..) => {
|
||||
atom!("infinite_float")
|
||||
}
|
||||
ParserError::IO(e) if e.kind() == ErrorKind::UnexpectedEof => {
|
||||
atom!("unexpected_end_of_file")
|
||||
}
|
||||
|
||||
@@ -976,11 +976,17 @@ impl<'a, R: CharRead> Parser<'a, R> {
|
||||
Token::Literal(Literal::Rational(n)) => {
|
||||
self.negate_number(n, negate_rat_rc, |r, _| Literal::Rational(r))
|
||||
}
|
||||
Token::Literal(Literal::Float(n)) => self.negate_number(
|
||||
Token::Literal(Literal::Float(n)) if F64Ptr::from_offset(n).is_infinite() => {
|
||||
return Err(ParserError::InfiniteFloat(
|
||||
self.lexer.line_num,
|
||||
self.lexer.col_num,
|
||||
));
|
||||
}
|
||||
Token::Literal(Literal::Float(n)) => self.negate_number(
|
||||
**n.as_ptr(),
|
||||
|n, _| -n,
|
||||
|n, arena| Literal::from(float_alloc!(n, arena)),
|
||||
),
|
||||
),
|
||||
Token::Literal(c) => {
|
||||
let atomized = atomize_constant(&self.lexer.machine_st.atom_tbl, c);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user