Re: [code] [textadept] open file and latex lexer

From: Mitchell <m.att.foicica.com>
Date: Mon, 6 Jan 2014 10:35:49 -0500 (Eastern Standard Time)

Hi Olivier,

On Sun, 5 Jan 2014, Olivier Guibé wrote:

> Hi Mitchell
>
> [snip]
>
> I read some of the lexers.lua to try to understand. For example
> I do not understand some P(function(input,index) as in tcl.lua
> ########
> local comment = token(l.COMMENT, '#' * P(function(input, index)
> local i = index - 2
> while i > 0 and input:find('^[ \t]', i) do i = i - 1 end
> if i < 1 or input:find('^[\r\n;]', i) then return index end
> end) * l.nonnewline^0)
> ####

This code ensures that a comment is by itself in a statement (ignoring
whitespace). It looks for the first non-space and non-tab character
behind the starting '#' and verifies that it is either a newline or ';'.

For example:

   # this is a valid comment
   a = 1 # this is not a valid comment
   b = 2; # but this is

Cheers,
Mitchell

-- 
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 Mon 06 Jan 2014 - 10:35:49 EST

This archive was generated by hypermail 2.2.0 : Tue 07 Jan 2014 - 06:50:40 EST