Go to Google Groups Home    Qilang
Re: segment matching variables in Qi-YACC (for Snorgers ;))

snorgers <stefan.ta...@spray.se>

Hi Mark,

Cool this looks like a natural building block, but what do you think
about patterns like

(defcc <f>
 <<L>> <numbers> <<L>> := ...)

They is nice to have for situations like
<string-prefix> <<boundary>> <endl> <<String>> <<boundary>> := (COERCE
<<String>> STRING);

/Stefan

On 26 June, 11:37, Mark Tarver <dr.mtar...@ukonline.co.uk> wrote:

> Here is a sugaring on top of Qi that enables you to have segment
> matching variables in Qi-YACC.  <<...>> is a stuff matcher.

> (defcc <grab-numbers>
>        <<X>> <numbers> <<Y>> := <numbers>;)

> (defcc <numbers>
>        <number> <numbers>;
>        <number>;)

> (defcc <number>
>         -*- := (if (number? -*-) [-*-] #\Escape);)

> (defcc <grab-my-name>
>    <<X>> :name <<Y>> := <<Y>>;)

> Examples:

> (compile <grab-my-name> [ghhghg 7 8 :name Mark Tarver])
> [Mark Tarver]

> (compile <grab-numbers> [just some numbers 1 2 3/4 tum te tum])
> [1 2 3/4]

> The code is 85 lines.

> Mark