Re: [code] lexer for indentation driven blocks

From: Carl Sturtivant <>
Date: Mon, 22 Feb 2016 09:04:37 -0600

Hello Mitchell,

On 2/22/2016 8:15 AM, Mitchell wrote:
>> 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.
> I'm having trouble visualizing this. Could you provide an example? By
> the way, the markdown lexer is not a _LEXBYLINE lexer and can match
> leading indentation for embedded HTML. That may be worth looking into.

This is a bit like Python (disclaimer: I don't use Python). When the
indentation decreases, it's the end of a block. I need to find the block
end starting from the current matching position.

I realize I can do that using lexer.indent_amount[] if I have a way to
get the current line number from the lexer. But I don't know how to do that.


You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Mon 22 Feb 2016 - 10:04:37 EST

This archive was generated by hypermail 2.2.0 : Tue 23 Feb 2016 - 06:50:31 EST