lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 9/10/2014 3:21 AM, Steven Degutis wrote:
Are Lua's llex.h and lparser.h files suitable for me to use to build a
structure that I can then traverse to do my syntax highlighting in a
rich text field?

If so, is there any documentation anywhere on using functionality
within these files for this purpose?

Note: This is for educational reasons, so while I could just use a
third party library, it defeats the point.

If you just convert the lexer, then you can classify many types of tokens and highlight accordingly. The result will be roughly equivalent to the kind of output that SciTE or Notepad++ (Scintilla-based editors) provides. (For smarter editors this may not be enough.)

I have done one using a Lua 5.1 llex more-or-less work-alike, heavily modified to use Lua shortcuts rather than C-style coding. The text-to-HTML function clocks in at 208 SLOC, plus an additional small function to generate some HTML entities.

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia