lua-users home
lua-l archive

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


> 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?

For syntax highlighting, you don't need the parser, just the lexer, right?

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

There is no official documentation except the source.

The only interface that should interest you is llex and the SemInfo
struct. To see how these work, search the archives for "proxy.c" and
"token filter". See for instance
	http://lua-users.org/lists/lua-l/2012-03/msg00309.html

See also my recent rewrite of my lstrip as a token filter:
	http://lua-users.org/lists/lua-l/2014-07/msg00058.html

The code in lstrip should be a good place to start. The only problem is
that you won't be able to run Lua programs since the token filter in
lstrip eats all tokens and the parser sees an empty stream.

You may use a global variable to switch off the token filter and then
allow your app to run Lua programs. This should be easy to do.

Feel free to contact me about all this.
--lhf