From b7831b49c345589b5eea631c1d1001664fa9f0d4 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sun, 10 Apr 2016 03:26:23 -0700 Subject: [PATCH] be smarter about lexing spaces --- lips/Lexer.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lips/Lexer.lua b/lips/Lexer.lua index ff4184a..ee8bb5c 100644 --- a/lips/Lexer.lua +++ b/lips/Lexer.lua @@ -89,6 +89,10 @@ function Lexer:read_chars(pattern) return buff end +function Lexer:read_spaces() + return self:read_chars('[ \t]') +end + function Lexer:read_decimal() local buff = self:read_chars('%d') local num = tonumber(buff) @@ -262,7 +266,7 @@ function Lexer:lex_string_naive(yield) -- no escape sequences end function Lexer:lex_include(_yield) - self:read_chars('%s') + self:read_spaces() local fn self:lex_string_naive(function(tt, tok) fn = tok @@ -376,6 +380,7 @@ function Lexer:lex(_yield) self:nextc() yield('RELLABEL', sign_chr) else + self:read_spaces() local n = self:read_number() if n then yield('NUM', sign*n)