From 8d58aebb4afbffd907d05622654c7a8d851a74b1 Mon Sep 17 00:00:00 2001 From: Reid 'arrdem' McKenzie Date: Sat, 21 Aug 2021 14:23:39 -0600 Subject: [PATCH] Deal with string escaping --- projects/lilith/src/python/lilith/grammar.lark | 1 + projects/lilith/src/python/lilith/parser.py | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/lilith/src/python/lilith/grammar.lark b/projects/lilith/src/python/lilith/grammar.lark index 4ea9440..3d88fa1 100644 --- a/projects/lilith/src/python/lilith/grammar.lark +++ b/projects/lilith/src/python/lilith/grammar.lark @@ -1,6 +1,7 @@ %import common.WORD %import common.INT %import common.FLOAT +%import common.ESCAPED_STRING %import common.WS %ignore WS diff --git a/projects/lilith/src/python/lilith/parser.py b/projects/lilith/src/python/lilith/parser.py index 0024435..a351cf8 100644 --- a/projects/lilith/src/python/lilith/parser.py +++ b/projects/lilith/src/python/lilith/parser.py @@ -44,10 +44,9 @@ class Block(t.NamedTuple): class TreeToTuples(lark.Transformer): - def string(self, args): - # FIXME (arrdem 2021-08-21): - # Gonna have to do escape sequences here - return args[0].value + @lark.v_args(inline=True) + def string(self, s): + return s[1:-1].replace('\\"', '"') def int(self, args): return int(args[0])