[e-lang] Bug: three adjacent colons in printed ENodes

Kevin Reid kpreid at mac.com
Mon Sep 24 16:13:49 EDT 2007


On Sep 15, 2007, at 16:40, Mark Miller wrote:
> On 9/15/07, Kevin Reid <kpreid at mac.com> wrote:
>> ? e`def a : ::"" := c`
>> # value: e`def a :::"" := c`
>> ... The obvious printed form fails to parse since the lexer is  
>> producing [::,:] rather than [:,::].
>> ...
>> 1) Should an artificial precedence level be introduced?
>>
>> 2) Should guard-syntax printing look 'down' to see if the guard
>> expression will start with ":"?
>>
>> 3) Should the syntax used for arbitrary nouns be changed?
>>
>> 4) Should the lexer's interpretation of ":::" be changed?
>
> Is there any other case in the grammar that, whitespace aside, could
> correctly allow three consecutive colons? I believe not.

(Note: MarkM and I discussed this last Thursday 2007-09-20; this  
message is partly for the record, but also introduces a new idea at  
the end.)

I can't think of any.

> If not, then I believe we should at least do #4.

Dean said that it's nontrivial to get the ANTLR lexer to do this.

> Once we do #4, then the immediate technical problem is solved, but  
> the printing behavior remains unpleasant. I think we should do #1  
> as well.

I dislike the notion of introducing a precedence level for something  
which isn't actually precedence. But I imagine adjusting "precedence"  
to be "context" which includes the precedence and a flag of  
"immediately preceding colon" which noun printing uses to decide to  
add a prefix space.

Another idea: we could mirror the parser/lexer structure, as in a  
"token printer" which is driven by the ENode tree printer, and would  
know to insert a space whenever necessary or appropriate, including  
between : and ::. What do you think of this?

-- 
Kevin Reid                            <http://homepage.mac.com/kpreid/>




More information about the e-lang mailing list