mirror of
https://github.com/notwa/lips
synced 2024-11-14 09:39:03 -08:00
be smarter about lexing spaces
This commit is contained in:
parent
311b1e362f
commit
b7831b49c3
1 changed files with 6 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue