mirror of
https://github.com/fluencelabs/lalrpop
synced 2025-03-27 05:31:04 +00:00
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).
22 lines
290 B
Plaintext
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 ")";
|
|
};
|
|
}
|