lalrpop/test/sub/sub.lr
Niko Matsakis 4379b13c9d Make type inference smarter, based on the idea that all constraints must
have the same type; so if we see errors or cases where we cannot infer a
type, let's just take it from one of the successful alternatives. This
lets us remote the type annotation on `E` (or `T`, depending).
2015-06-22 14:14:03 -04:00

22 lines
290 B
Plaintext

grammar {
use util::tok::Tok;
token Tok where {
"(" => "LParen";
")" => "RParen";
"-" => "Minus";
};
pub S = E;
E = {
~l:E "-" ~r:T => l-r;
T;
};
T: i32 = {
~n:"Num" => n.as_num();
"(" ~E ")";
};
}