hughperman / pure-lang

Automatically exported from code.google.com/p/pure-lang
0 stars 0 forks source link

Only namespace-with blocks require a final ";" #74

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I've come across a difference in the syntax of two kinds of with-blocks:

    x with y=3; x=y+1 end;

(note no ; after the last rule) is fine. Indeed it seems to be the
canonical form, see how the last ; is stripped here:

> __str__ ('(x with y=3; x=y+1; end));
"x with x = y+1; y = 3 end"

On the other hand, it is not permitted to omit the ; in a namespace-with
block:

> namespace jones with h x = 1; t y = 3 end;
<stdin>, line 16: syntax error, unexpected end, expecting ';'

Is there a compelling reason for this difference? Could we get the
namespace-with blocks to accept a missing final ;? Or could we get
__str__ to include it in its output?

What version of the product are you using? On what operating system?
Pure 0.5.3 on FreeBSD

Original issue reported on code.google.com by dubious...@gmail.com on 14 Jun 2012 at 12:54

GoogleCodeExporter commented 8 years ago
Well, the contents of a namespace block are actually at toplevel syntactically, 
which requires a semicolon to terminate declarations and definitions, so it 
makes sense to have them here, too.

There's also a technical issue, namely that the grammar causes all kinds of 
nasty LALR parsing conflicts if I allow to drop the final semicolon in a 
namespace block. IIRC, that's due to the way declarations are parsed which 
requires some lexical tie-ins so that operator declarations can be parsed 
correctly. I didn't deem this important enough to rewrite the entire grammar 
(and possibly the lexer) for it.

I still don't consider this a big issue, so I'm closing this bug for now. If 
you consider it important, you're invited to reopen it -- preferably with the 
appropriate patches to parser.yy and lexer.ll to make it work. ;-)

Original comment by aggraef@gmail.com on 14 Jun 2012 at 6:22

GoogleCodeExporter commented 8 years ago
No, not important. If there are technical reasons as you describe I'd also say 
leave it be. I just pointed it out in case it was a simple oversight. Thanks.

Original comment by dubious...@gmail.com on 14 Jun 2012 at 3:01