mirror of
https://github.com/notwa/lips
synced 2024-11-14 18:39:02 -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
|
return buff
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Lexer:read_spaces()
|
||||||
|
return self:read_chars('[ \t]')
|
||||||
|
end
|
||||||
|
|
||||||
function Lexer:read_decimal()
|
function Lexer:read_decimal()
|
||||||
local buff = self:read_chars('%d')
|
local buff = self:read_chars('%d')
|
||||||
local num = tonumber(buff)
|
local num = tonumber(buff)
|
||||||
|
@ -262,7 +266,7 @@ function Lexer:lex_string_naive(yield) -- no escape sequences
|
||||||
end
|
end
|
||||||
|
|
||||||
function Lexer:lex_include(_yield)
|
function Lexer:lex_include(_yield)
|
||||||
self:read_chars('%s')
|
self:read_spaces()
|
||||||
local fn
|
local fn
|
||||||
self:lex_string_naive(function(tt, tok)
|
self:lex_string_naive(function(tt, tok)
|
||||||
fn = tok
|
fn = tok
|
||||||
|
@ -376,6 +380,7 @@ function Lexer:lex(_yield)
|
||||||
self:nextc()
|
self:nextc()
|
||||||
yield('RELLABEL', sign_chr)
|
yield('RELLABEL', sign_chr)
|
||||||
else
|
else
|
||||||
|
self:read_spaces()
|
||||||
local n = self:read_number()
|
local n = self:read_number()
|
||||||
if n then
|
if n then
|
||||||
yield('NUM', sign*n)
|
yield('NUM', sign*n)
|
||||||
|
|
Loading…
Reference in a new issue