nitc :: InjectedLexer :: defaultinit
# A modified lexer that feed tokens before and after the real tokens.
class InjectedLexer
super Lexer
# The tokens to use before the real tokens (in order).
var injected_before = new List[Token]
# The tokens to use after the real tokens (in order).
# The real EOF token is produced after these tokens.
var injected_after = new List[Token]
private var is_finished = false
redef fun get_token
do
if not injected_before.is_empty then
var tok = injected_before.shift
return tok
end
if not is_finished then
var next = super
if not next isa EOF then return next
injected_after.push(next)
is_finished = true
end
var tok = injected_after.shift
return tok
end
end
src/parser_util.nit:225,1--253,3