[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FYI: default %printer/%destructor
From: |
Joel E. Denny |
Subject: |
Re: FYI: default %printer/%destructor |
Date: |
Sat, 18 Nov 2006 18:03:51 -0500 (EST) |
On Sat, 18 Nov 2006, Hans Aberg wrote:
> I have looked at this, and tried to find an examples of other similar uses,
> though I failed.
Thanks for responding. I think Akim got this from Lemon. There are some
examples here:
http://www.hwaci.com/sw/lemon/lemon.html
> One variation might be
> exp/sum: exp/term1 '+' exp/term2 {...}
> Instead of the proposed
> exp/sum -> exp/term1 '+' exp/term2 {...}
Parentheses are easier on my eyes than slash or colon is. (Colon is
discussed in TODO.) For example, these look ambiguous to me:
a: b/ c
a -> c :b
In either case, is b's value named c? Or is c another RHS symbol and the
value for b is not used? Yes, the space between them probably indicates
the latter interpretation, but it still looks ugly to me. Compare with:
a: b() c
a: c b()
In TODO, I just noticed a couple of other issues for this area that I had
forgotten. I don't much care for making values regular variables as
suggested by this example:
r:exp -> a:exp '+' b:exp { r = a + b; } ;
Bison currently detects uses of values for the sake of warnings, and I
think searching for variables will make parsing the actions difficult
especially when faced with new target languages.
On the other hand, what if $ is special in some target language?
Declaring $ as part of the value name might help:
exp($sum): exp($term1) '+' exp($term2)
That is, one could potentially choose something other than $. There's an
example of this in TODO as well. For now, we could require that the first
character be $ since searching for any arbitrary sequence in an action
will take some work. I'd just like to get the notation right for now.
As TODO notes, there's still the issue of how to handle locations.
Perhaps Bison could automatically append `_loc' to the value name. So,
exp($sum) would have a value of $sum and a location of $sum_loc.
Or maybe it should be possible to name these separately:
exp($sum, @sum): exp($term1, @term1) '+' exp($term2, @term2)
The notation is getting verbose, but how many sym locations do you
typically use in a semantic action anyway? You'd only need to specify the
ones you use.
This would also make it possible to declare a value as unused but still
access the location. The only value used in the following is the LHS
value:
exp($sum): exp(, @term1) '+' exp()
- Re: FYI: default %printer/%destructor, Joel E. Denny, 2006/11/17
- Re: FYI: default %printer/%destructor, Hans Aberg, 2006/11/18
- Re: FYI: default %printer/%destructor,
Joel E. Denny <=
- Re: FYI: default %printer/%destructor, Hans Aberg, 2006/11/19
- Re: FYI: default %printer/%destructor, Joel E. Denny, 2006/11/19
- Re: FYI: default %printer/%destructor, Hans Aberg, 2006/11/19
- Re: FYI: default %printer/%destructor, Joel E. Denny, 2006/11/19
- Re: FYI: default %printer/%destructor, Hans Aberg, 2006/11/19
- Re: FYI: default %printer/%destructor, Joel E. Denny, 2006/11/19
- Re: FYI: default %printer/%destructor, Hans Aberg, 2006/11/19
- Re: FYI: default %printer/%destructor, Joel E. Denny, 2006/11/19
- Re: FYI: default %printer/%destructor, Hans Aberg, 2006/11/20
- Re: FYI: default %printer/%destructor, Joel E. Denny, 2006/11/20