blob: 08c3cd3986e88468413f26d2a832567168ed1bbf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
use std::str::FromStr;
use ast::{self, WithLocation};
grammar;
pub Program: ast::Program = {
Expression => ast::Program(<>),
};
Expression: Box<ast::WithLocation<ast::Expression>> = {
Num => Box::new(<>.map(|v| ast::Expression::Number(v))),
};
Num: WithLocation<u64> = <e: Spanned<r"[0-9]+">> => e.map(|v| u64::from_str(v).unwrap());
Spanned<T>: WithLocation<T> = {
<l: @L> <v: T> <r: @R> => WithLocation::new(v, l, r)
};
|