Compiler/lexical analyzer: Difference between revisions

m
Line 4,682:
=={{header|Lua}}==
===Using LPeg library===
This version uses LPeg, a parsing expression grammar library, developed by one of the authors of Lua.
The source is broken into several modules, in part to make it easier to present the "vanilla Lua" version afterwards.
Tested with Lua 5.3.5 and LPeg 1.0.2-1.
Line 4,886:
</lang>
 
This script uses <i>lexer.tokenize_text</i> to show the tokens produced froma tokenizing asource text.
 
<lang Lua>lexer = require 'lexer'
Line 4,927:
end
</lang>
 
===Using only standard libraries===
This version replaces the <i>lpeg_token_finder</i> module of the LPeg version with this <i>basic_token_finder</i> module, altering the <i>require</i> expression near the top of the <i>lexer</i> module accordingly. Tested with Lua 5.3.5. (Note that <i>select</i> is a standard function as of Lua 5.2.)
Anonymous user