Last active
December 22, 2015 06:11
-
-
Save mdg/1097315f61511d2e17ac to your computer and use it in GitHub Desktop.
The different of the output for the example parser in lemon-diff given the changes in pull request #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/origin.rs b/token-ids.rs | |
index 736580d..b849a41 100644 | |
--- a/origin.rs | |
+++ b/token-ids.rs | |
@@ -48,23 +48,40 @@ const YYERRORSYMBOL: i32 = 0; | |
pub enum Token { | |
EOI, //0 | |
VALUE( i32 ), //1 | |
PLUS, //2 | |
MINUS, //3 | |
TIMES, //4 | |
DIV, //5 | |
LPAREN, //6 | |
RPAREN, //7 | |
} | |
+const TOKEN_EOI: i32 = 0; | |
+const TOKEN_VALUE: i32 = 1; | |
+const TOKEN_PLUS: i32 = 2; | |
+const TOKEN_MINUS: i32 = 3; | |
+const TOKEN_TIMES: i32 = 4; | |
+const TOKEN_DIV: i32 = 5; | |
+const TOKEN_LPAREN: i32 = 6; | |
+const TOKEN_RPAREN: i32 = 7; | |
#[inline] | |
fn token_major(t: &Token) -> i32 { | |
- unsafe { ::std::intrinsics::discriminant_value(t) as i32} | |
+ match t { | |
+ &Token::EOI => 0, | |
+ &Token::VALUE(_) => TOKEN_VALUE, | |
+ &Token::PLUS => TOKEN_PLUS, | |
+ &Token::MINUS => TOKEN_MINUS, | |
+ &Token::TIMES => TOKEN_TIMES, | |
+ &Token::DIV => TOKEN_DIV, | |
+ &Token::LPAREN => TOKEN_LPAREN, | |
+ &Token::RPAREN => TOKEN_RPAREN, | |
+ } | |
} | |
#[inline] | |
fn token_minor(t: Token) -> YYMinorType { | |
match t { | |
Token::VALUE(x) => YYMinorType::YY17(x), | |
_ => YYMinorType::YY0 | |
} | |
} | |
const YY_ACTTAB_COUNT: i32 = 22; | |
const YY_ACTION: [YYACTIONTYPE; 22] = [ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment