Page 1 of 1

Preprocessor bug filtering out comments

Posted: Wed Dec 27, 2006 1:27 pm
by epmoyer
There is a bug in the preprocessor with repspect to filtering out comments.

The following:

startshape MAKER
blah blah blah
rule MAKER { TRIANGLE{} MAKER {s 0.9 y 1 r 4}}
rule MAKER { TRIANGLE{} MAKER {s 0.9 y 1 r -4}}

...generates an error, as expected, on line 2.

The following:

startshape MAKER
// blah blah blah
# blah blah blah
/* blah blah blah */
rule MAKER { TRIANGLE{} MAKER {s 0.9 y 1 r 4}}
rule MAKER { TRIANGLE{} MAKER {s 0.9 y 1 r -4}}

...works as expected (all 3 "blah" lines are ignored)./

BUT, the following errors exit

ERROR #1:

The follwing will generate a syntax error if there is no line feed on the end of the last line:

startshape MAKER
// blah blah blah
rule MAKER { TRIANGLE{} MAKER {s 0.9 y 1 r 4}}
// rule MAKER { TRIANGLE{} MAKER {s 0.9 y 1 r -4}}

ERROR #2:

The second rule will be active (i.e. not be ignored) if there is no line feed on the end of the last line:

startshape MAKER
// blah blah blah
rule MAKER { TRIANGLE{} MAKER {s 0.9 y 1 r 4}}
# rule MAKER { TRIANGLE{} MAKER {s 0.9 y 1 r -4}}

I imagine both errors are related.

Posted: Wed Dec 27, 2006 7:38 pm
by MtnViewJohn
They are both caused by lex/flex not being able to skip past a line comment that ends with an end-of-file instead of a line-feed. We have known about this limitation in the lex grammar for a while. Rather than try to fix the lex grammar I put in a fix to always tack a line-feed at the end of the cfdg file.

Commented last line returns error - a-ha!

Posted: Fri Mar 30, 2007 10:04 pm
by jeremydouglass
I've been editing CFDG files in Textmate for the syntax highlighting and rendering in Context Free for the iterative display, and this bug was killing me until I figured it out. I'm glad to see a post about it here.

In 2.0, it still dies with most unhelpful error messages - is the appended-line-feed fix in 2.1b? And when is the line added - on save, or on render?

Posted: Sat Mar 31, 2007 8:48 am
by MtnViewJohn
The linefeed fix is in 2.1b only, not 2.0. The linefeed is added on at the render, so it is OK if Textmate doesn't add on a linefeed.