Re: [code] Factor lexer for Textadept

From: Michael Richter <ttmrichter.att.gmail.com>
Date: Thu, 4 Apr 2013 11:54:09 +0800

It will indeed. Nothing like working code to show how to get code
working! :D Thanks again, Mitchell.

On 4 April 2013 11:42, Mitchell <m.att.foicica.com> wrote:

> Hi Michael,
>
>
> On Thu, 4 Apr 2013, Michael Richter wrote:
>
> OK, I've got stack declarations much more solid now:
>>
>> -- some building blocks
>> local maybe_some = function(p) return p^0 end
>> local ws = l.space
>> local with_ws = function(p) return p * #ws end
>> local ws_with = function(p) return B(#ws) * p end
>> local ws_with_ws = function(p) return B(l.space) * p * #ws end
>>
>> local stack_declaration = with_ws(P'(')
>> * maybe_some(1 - P'--')
>> * ws_with_ws(P'--')
>> * maybe_some(1 - P')')
>> * ws_with(P')')
>>
>> This works for non-nested stack declarations exactly as expected. It, of
>> course, breaks down on stack declarations like "( value quote: ( word --
>> word ) -- word )". Attempts to build in nested stack declarations,
>> however, have failed because I'd have to define stack declarations in
>> terms
>> of stack declarations recursively which makes the lexer get all upset and
>> throw up its hands while refusing to recognize *anything* at all.
>>
>>
>> Am I correct in reading http://www.inf.puc-rio.br/~**
>> roberto/lpeg/#grammar <http://www.inf.puc-rio.br/~roberto/lpeg/#grammar>to
>> think that I now have to bite the bullet and figure out how to use LPEG
>> grammar tables?
>>
>
> Nested and recursive patterns generally involve grammars, yes. The
> hypertext lexer uses lpeg.P{} and lpeg.V() when defining attributes
> recursively. Perhaps that may help.
>
>
> 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.
>
>

-- 
"Perhaps people don't believe this, but throughout all of the discussions
of entering China our focus has really been what's best for the Chinese
people. It's not been about our revenue or profit or whatnot."
--Sergey Brin, demonstrating the emptiness of the "don't be evil" mantra.
-- 
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 Wed 03 Apr 2013 - 23:54:09 EDT

This archive was generated by hypermail 2.2.0 : Thu 04 Apr 2013 - 06:36:23 EDT