diff options
author | mitchell <unknown> | 2019-02-18 14:32:33 -0500 |
---|---|---|
committer | mitchell <unknown> | 2019-02-18 14:32:33 -0500 |
commit | 4d15aca72dcad410b2b4bc6a142560bce692cadf (patch) | |
tree | 88d3609f5b9c1dca4c92acd52f1908a6beb5bc23 | |
parent | c35abc15c8f987eb7c8fef03dd1432aa9dec1257 (diff) | |
download | scintilla-mirror-4d15aca72dcad410b2b4bc6a142560bce692cadf.tar.gz |
Added documentation on using Scintilla as a Lua library.
-rw-r--r-- | doc/LPegLexer.html | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/doc/LPegLexer.html b/doc/LPegLexer.html index 4613c241e..57b0622af 100644 --- a/doc/LPegLexer.html +++ b/doc/LPegLexer.html @@ -405,6 +405,38 @@ <p>See also: <a class="message" href="#SCI_SETDOCPOINTER"><code>SCI_SETDOCPOINTER</code></a></p> + <h2>Using Scintilla as a Lua Library</h3> + + <p>In order to use Scintilla as a Lua library, simply place the <code>lexlua/</code> + directory in your Lua path (or modify Lua’s <code>package.path</code> accordingly), + <code>require()</code> the library and <a href="#lexer.load"><code>load()</code></a> a lexer, and call that lexer’s + <a href="#lexer.lex"><code>lex()</code></a> function. Here is an example interactive Lua session doing this:</p> + + <pre><code>$> lua +Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio +> lexer_path = '/home/mitchell/code/scintilla/lexlua/?.lua' +> package.path = package.path..';'..lexer_path +> c = require('lexer').load('ansi_c') +> tokens = c:lex('int void main() { return 0; }') +> for i = 1, #tokens, 2 do print(tokens[i], tokens[i+1]) end +type 4 +ansi_c_whitespace 5 +type 9 +ansi_c_whitespace 10 +identifier 14 +operator 15 +operator 16 +ansi_c_whitespace 17 +operator 18 +ansi_c_whitespace 19 +keyword 25 +ansi_c_whitespace 26 +number 27 +operator 28 +ansi_c_whitespace 29 +operator 30 + </code></pre> + <h2 id="lexer">Writing Lua Lexers</h2> <p>Lexers highlight the syntax of source code. Scintilla (the editing component |