Closed aseemk closed 13 years ago
The funny thing was that this error took me a long time to realize! The error message is completely misleading: Unexpected 'INDENT'
.
Eco doesn't really know anything about comments... it just passes them off to CoffeeScript.
We can detect comment tags by modifying the scanner to explicitly look for /^\s*#/
in the tag content. Would you like to take a shot at patching this?
Ah, perhaps looking at it from a different perspective will help:
Yes, Eco doesn't know about CoffeeScript syntax, e.g. comments. But CoffeeScript doesn't know about colons -- that's purely an Eco addition.
To my understanding, Eco's colon is a way of signaling "begin an indentation block" for e.g. if
, for
, while
, etc. The problem here is, Eco does this with colons indiscriminately, even when the colon is at the end of a comment.
So should the solution be for Eco to manually detect comments? Or should it be to detect colons only when the statement is an if
, for
, etc.?
Yes, that's certainly one way to look at it, but it doesn't reflect how Eco is designed. Eco does not parse CoffeeScript. It does know how to automatically dedent on the few keywords that require it (like else
), but otherwise it's a simple set of preprocessing rules for compiling down to CoffeeScript source.
Scanning for #
at the beginning of a tag will be far simpler to implement than parsing the source and checking for every possible keyword that can be followed by a newline + indent.
Whoa, I never got notified that you fixed this, so even though this is overdue, thanks for fixing! /cc @gasi
https://gist.github.com/966242
Trailing colons in comments should be ignored. =)