[code] lexer for indentation driven blocks

From: Carl Sturtivant <sturtivant.att.gmail.com>
Date: Sun, 21 Feb 2016 21:46:32 -0600


I could use some clues as to how to proceed with some aspects of writing
an awkward lexer from someone familiar with Lua, Textadept lexers,
and/or LPEG matching.

I'm working on a lexer for Diet templates,
http://vibed.org/templates/diet which are used to generate HTML, and can
embed CSS, JavaScript, Markdown, HTML, and D, as well as plain text,
lexers for all of which fortunately already exist.

A template has a nested block structure. A nested block starts with a
word indented more than the indentation of the word starting the
previous line, and continues up to the first line starting with a less
indented token.

What's the best way to pattern match the end of a block when matching a
block? This is necessary because e.g. embedded JavaScript can make up an
indented block that ends by the above condition, and I need to switch to
the JavaScript lexer for exactly that region.

Also, some ways of embedding other languages continue only until the end
of the current line. Is there a simple way to color those part lines
using an existing lexer and not overflow the line? I could turn on
_LEXBYLINE but I don't know what effect that will have on multi-line
blocks of JavaScript or other embedded text. Is there a clean technique
to track state while matching?

Any advice is welcome.

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 Sun 21 Feb 2016 - 22:46:32 EST

This archive was generated by hypermail 2.2.0 : Mon 22 Feb 2016 - 06:34:55 EST