Re: [code] Factor lexer for Textadept

From: Mitchell <m.att.foicica.com>
Date: Wed, 3 Apr 2013 23:42:34 -0400 (EDT)

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 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.
Received on Wed 03 Apr 2013 - 23:42:34 EDT

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