use nash_region::{Located, Position};
use nash_source::Expr;
use crate::Parser;
use crate::error;
impl<'a> Parser<'a> {
pub(crate) fn number(
&mut self,
start: Position,
) -> Result<&'a Located<Expr<'a>>, error::Expr<'a>> {
let n = self.number_literal(error::Expr::Start, error::Expr::Number)?;
Ok(self.add_end(start, Expr::Int(n)))
}
}
#[cfg(test)]
mod tests {
use crate::expression::assert_expr_snapshot;
#[test]
fn int_simple() {
assert_expr_snapshot!("42");
}
#[test]
fn int_zero() {
assert_expr_snapshot!("0");
}
#[test]
fn int_hex() {
assert_expr_snapshot!("0xFF");
}
}