From 9cbe12458d9b3e3dc55e30fff1e396e1b7cf0d9a Mon Sep 17 00:00:00 2001 From: David Li Date: Sat, 4 Nov 2017 19:53:47 -0400 Subject: Parse strings without escapes --- src/taiga.lalrpop | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/taiga.lalrpop') diff --git a/src/taiga.lalrpop b/src/taiga.lalrpop index 68238eb..ffee4ee 100644 --- a/src/taiga.lalrpop +++ b/src/taiga.lalrpop @@ -84,11 +84,15 @@ ExpressionSign: Box> = { ExpressionBase: Box> = { Num => Box::new(<>.map(|v| ast::Expression::Number(v))), + String => Box::new(<>.map(|v| ast::Expression::String(v))), Spanned => Box::new(<>.map(|v| ast::Expression::Nil)), "(" ")" => <>, }; Num: WithLocation = > => e.map(|v| u64::from_str(v).unwrap()); +String: WithLocation = => { + WithLocation::new(v[1..v.len() - 1].to_owned(), l, r) +}; Spanned: WithLocation = { => WithLocation::new(v, l, r) -- cgit v1.2.3