Skip to content

Commit

Permalink
lexer: move some state out of the automaton loop
Browse files Browse the repository at this point in the history
Signed-off-by: Jean Privat <[email protected]>
  • Loading branch information
privat committed Aug 20, 2024
1 parent 9d6746d commit 2f39c74
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/parser/lexer_work.nit
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ class Lexer
var accept_pos = -1
var accept_line = -1

var cr = _cr
var line = _line
var pos = _pos
loop
if sp >= string_len then
dfa_state = -1
Expand All @@ -177,9 +180,6 @@ class Lexer
if c >= 256 then c = 255
sp += 1

var cr = _cr
var line = _line
var pos = _pos
if c == 10 then
if cr then
cr = false
Expand Down Expand Up @@ -228,10 +228,10 @@ class Lexer
if dfa_state > -2 then break
end

_cr = cr
_line = line
_pos = pos
end
_cr = cr
_line = line
_pos = pos

if dfa_state >= 0 then
var tok = lexer_accept(dfa_state)
Expand Down

0 comments on commit 2f39c74

Please sign in to comment.