From 4d15aca72dcad410b2b4bc6a142560bce692cadf Mon Sep 17 00:00:00 2001 From: mitchell Date: Mon, 18 Feb 2019 14:32:33 -0500 Subject: Added documentation on using Scintilla as a Lua library. --- doc/LPegLexer.html | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'doc/LPegLexer.html') 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 @@

See also: SCI_SETDOCPOINTER

+

Using Scintilla as a Lua Library

+ +

In order to use Scintilla as a Lua library, simply place the lexlua/ + directory in your Lua path (or modify Lua’s package.path accordingly), + require() the library and load() a lexer, and call that lexer’s + lex() function. Here is an example interactive Lua session doing this:

+ +
$> 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
+    
+

Writing Lua Lexers

Lexers highlight the syntax of source code. Scintilla (the editing component -- cgit v1.2.3