From 1e8d8896b36c581121c7ba5c501c45bedce084e2 Mon Sep 17 00:00:00 2001
From: David Li
Date: Sat, 4 Nov 2017 19:58:32 -0400
Subject: Parse identifiers
---
src/taiga.lalrpop | 12 ++++++++++++
1 file changed, 12 insertions(+)
(limited to 'src/taiga.lalrpop')
diff --git a/src/taiga.lalrpop b/src/taiga.lalrpop
index ffee4ee..be47147 100644
--- a/src/taiga.lalrpop
+++ b/src/taiga.lalrpop
@@ -85,10 +85,12 @@ ExpressionSign: Box> = {
ExpressionBase: Box> = {
Num => Box::new(<>.map(|v| ast::Expression::Number(v))),
String => Box::new(<>.map(|v| ast::Expression::String(v))),
+ Name => Box::new(<>.map(|v| ast::Expression::Name(v))),
Spanned => Box::new(<>.map(|v| ast::Expression::Nil)),
"(" ")" => <>,
};
+Name: WithLocation = > => e.map(|v| v.to_owned());
Num: WithLocation = > => e.map(|v| u64::from_str(v).unwrap());
String: WithLocation = => {
WithLocation::new(v[1..v.len() - 1].to_owned(), l, r)
@@ -97,3 +99,13 @@ String: WithLocation = =>
Spanned: WithLocation = {
=> WithLocation::new(v, l, r)
};
+
+match {
+ "nil",
+}
+else {
+ r"[[:alpha:]_][[:alpha:]_0-9]*",
+}
+else {
+ _,
+}
--
cgit v1.2.3