Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#16 Legitimate ]] causes error, and other parser confusion

open
nobody
None
5
2007-02-02
2006-09-27
Anonymous
No

rkopelman@mainframe.ca

The following lines cannot run in a .spy file; they
result in "Spyce syntax error at test.spy:2-5 - EOF in
multi-line statement".

===================
[[\ array1 = [0, 1, 2, 3, 4]
array2 = [0, 10, 20, 30, 40]

print array2[array1[2]]
]]
===================

I believe that there are other variants of this that
give more obscure errors, but I can't recall for sure.

It seems like doing some bracket matching before
deciding to terminate the Python block would be called for.

This can be worked around by putting a space between
the two bracket characters or by breaking the statement
into multiple lines (using the "<%" "%>" block marking
syntax strangely doesn't help although you get
different errors depending on whether you you use the
"\" to indicate Python indentation - why are the "%>"
and "]]" tokens interchangable?).

Even worse, commenting out the offending "]]" line
(using "#") doesn't change the failure! Very
unintuitive, although I understand that there are
certain limitations given the choice of block markers.

And furthermore, "]]" or "%>" in pure HTML will cause
an error as well - this can't be right, can it? PHP
certainly doesn't mind unmatched "?>" tokens.

Sorry to cover so many issues at once - this seemed
like a pretty narrow problem when I started the report.

Discussion

  • Jonathan Ellis
    Jonathan Ellis
    2007-02-02

    Logged In: YES
    user_id=657828
    Originator: NO

    You're right, the Spyce parser is pretty stupid sometimes. Some of the problems you mention are covered here: http://spyce.sourceforge.net/docs/doc-lang.html

    Actually fixing this would require a rewrite of the parser. The good news is this would be pretty straightforward; the bad news is it's a lot of work with only the payoff of fixing some corner cases. I don't plan to attempt this myself in the forseeable future, but I'd be glad to answer questions if you'd like to work on a patch.

     
  • Jonathan Ellis
    Jonathan Ellis
    2007-02-02

    • summary: Legitimate ]] causes error in .spy files --> Legitimate ]] causes error, and other parser confusion