Re: [code] use of scintillua outside scintilla

From: Mitchell <m.att.foicica.com>
Date: Sat, 28 Dec 2013 15:35:54 -0500 (EST)

Hi Cosmin,

On Thu, 24 Oct 2013, Cosmin Apreutesei wrote:

> Hi again Mitchell,
>
> Thanks for your help so far. I have a few more questions (I will make
> separate threads for each).
>
> I want to use the syntax highlighting engine from Lua, not from C. I
> see that lexer.lua assumes a clean Lua state (eg. it thinks
> package.loaded only contains lexer modules, it uses a _LEXER global,
> etc).
>
> Do you have any plans to release lexers.lua for Lua use? Ideally that
> means a Lua module that doesn't create or assume global variables or
> package.path, used like this:
>
> local lexer = require'lexers.lexer'
> lexer.lex(some_html_code, hypertext')

You can do this now from latest Scintillua hg (which should show up in
tonight's nightly build). Here's an example interactive session from the
updated Installation page:

   $> lua
   Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> lexer_path = '/home/mitchell/code/scintillua/lexers/?.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

Scintillua no longer messes with the global environment nor does it modify
`package.path`.

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Sat 28 Dec 2013 - 15:35:54 EST

This archive was generated by hypermail 2.2.0 : Sun 29 Dec 2013 - 06:54:13 EST