lua-users home
lua-l archive

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


On 09/10/2014 03: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.

-Steven

I read the source code a few times. I feel the lexer should be easy to
adapt for such usage. but the parser is not, imho.

the Lua parser has tight connection with the VM code generator. the parser
generates the coresponding VM instructions once it has recognized some
syntactic constructs. it won't build a intermediate data structure such as
an AST.

yet from another point of view, Lua's parser is well written, thus it is not
hard to understand. so I suppose it not be difficult to write your own parsing
code to suite your needs.