2009/4/4 Emmanuel Onzon <e.on...@gmail.com>

> 2009/4/4 john skaller <skal...@users.sourceforge.net>
>
>
>> On 05/04/2009, at 12:57 AM, Emmanuel Onzon wrote:
>>
>>
>>> The build system is now doing this:
>>> [...]
>>> checking build/test/regress/rt/rt-1.01.30-0: ok
>>>  * build/bin/flx.py --test=build        :
>>> build/test/regress/rt/rt-1.01.31-0.flx -> build/test/regress/rt/
>>> rt-1.01.31-0.so
>>> checking build/test/regress/rt/rt-1.01.31-0.so: ok
>>>  * build/bin/flx.py --test=build        :
>>> build/test/regress/rt/rt-1.01.31-0.flx -> build/test/regress/rt/rt-1.01.31-0
>>> checking build/test/regress/rt/rt-1.01.31-0: ok
>>>  * build/bin/flx.py --test=build        :
>>> build/test/regress/rt/rt-1.01.32-0.flx -> build/test/regress/rt/
>>> rt-1.01.32-0.so
>>> checking build/test/regress/rt/rt-1.01.32-0.so: ok
>>>  * build/bin/flx.py --test=build        :
>>> build/test/regress/rt/rt-1.01.32-0.flx -> build/test/regre
>>> [...]
>>>
>>>
>>> Running regression tests :)
>>>
>>>
>> OK, so now we have it all working again it is time to break it again :)
>>
>> The hope for the new version of Dypgen is we can get priorities working.
>> The goal is to allow stuff like the following use case:
>>
>> "The end user wishes to add /\ and \/ binary operators to the grammar,
>> these are called Wedge and Vee, and are used for logical and and logical
>> or, for gcd and lcm, and also in lattices and other math stuff where
>> there is some concept of infinum and supremum. The precedence
>> should be higher than logical and/or but lower than + and - somewhere"
>>
>> To make this work, the whole expression grammar needs to be rewritten
>> with priority information instead of using  (tail) recursion. And then we
>> have to parse the rewritten grammar. If that works, then we can add new
>> binary operators (since we already have, just to load Felix standard
>> grammar).
>>
>> The syntax I used before was something like:
>>
>>
>>        nt [pri] = rest of the production =># scheme action ;
>>
>> We would also require
>>
>>        order pri1 < pri2 < pri3;
>>
>> or something. This does NOT handle arbitrary priorities, just a linear
>> ordering,
>> but it does support insertion. (The transitive closure is implied).
>>
>> Unfortunately this makes a real mess of expression RHS. You have to write:
>>
>>        expr [term] = expr[term] + expr[<term];
>>
>> to get left associativity and the right precendences (or is that right
>> assoc ?)
>>
>
> This is left assoc, since expr of priority term are not allowed
> on the right side of +.
>
>
>>
>> This is too messy, so we might do:
>>
>>        def sterm = expr[term];
>>
>>        sterm = sterm + <sterm;
>>
>> where <expr[term] is shorthand for expr[<term]
>>
>> But this too is messy ..
>>
>> The problem goes away if non-terminals have unique priorities,
>> in which case the priority name can just be used in lieu of the
>> non-terminal.
>
>
> Interesting idea.
> For the extensions of the grammar done in the felix code,
> it is possible to do it without any change to dypgen this way:
>
> When the user defines a new rule like:
>
> term: <=term "+" <term
>
> Felix would add the rule:
>
> "expr",
> [Non_ter ("expr",Priority_Lesseq "term");
> Ter "Plus";
> Non_ter ("expr",Priority_Less "term")],
> "term",
> []
>
> The user only writes the priorities.
>

I realize this is actually just what you wrote :)


> This means Felix would have to guess which non terminal
> is implicitly used, which shouldn't be difficult if each priority
> is used for only one distinct non terminal.
>
>
------------------------------------------------------------------------------
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to