Files
fudge2/src/literals.lalrpop

13 lines
352 B
Plaintext
Raw Normal View History

2025-10-20 19:29:49 +02:00
use std::str::FromStr;
grammar;
pub Atom: f64 = {
<n:Int> => n as f64,
Float,
"(" <Atom> ")",
};
pub Int: i64 = <s:r"[0-9]|[1-9][0-9]*"> => i64::from_str(s).unwrap();
pub Float: f64 = <s:r"[+-]?([0-9]*[.][0-9]+|[0-9]*([.][0-9]+)?[Ee][+-]?[1-9][0-9]*)"> => f64::from_str(s).unwrap();
pub StringLiteral: &'input str = <s:"\"[^\"]\""> => s;