Change OvaleLexer into an object factory to generate lexers.
Change OvaleLexer into an object factory to generate lexers.
The calling code must provide an iterator, which is typically generated
with OvaleLexer.scan. The lexer buffers the token stream so that it may
be accessed with look-ahead capabilities.
The lexer provides two methods for accessing the buffered token stream:
Peek(k) buffers the next k tokens from the stream and returns the k'th one.
Consume(k) consumes the next k tokens from the buffer and returns the k'th one.
This allows the following code to iterate through the token stream without
consuming extra tokens.
-- Process tokens until seeing a '}'.
local tokenType, token = lexer:Peek()
while tokenType ~= "}" do
lexer:Consume()
-- do stuff here with the token
tokenType, token = lexer:Peek()
end
-- Here, the next token to be consumed is still '}'.
git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1540 d5049fe3-3747-40f7-a4b5-f36d6801af5f