scala.tmbundle
scala.tmbundle copied to clipboard
scala parsing bug?
Hi,
Github uses this tmbundle for rendering scala code - I noticed that there seems to be an issue with highlighting:
e.g. https://github.com/twitter/util/blob/master/util-core/src/main/scala/com/twitter/util/Future.scala
OsX 10.10, Chrome version 38.0.2125.122 - 10.10
Another broken example is this one:
https://github.com/2beaucoup/akka/blob/f6b1c90abc5011a9a4ec06663deea8174a76fdae/akka-http/src/main/scala/akka/http/server/RequestContextImpl.scala
I think both of those boil down to a too simplistic grammar that allows arbitrary nesting of any code elements.
@infininight
The first example shows the bundle doesn't understand nested comments.
/* this is a comment
/* this is a nested comment */
this is part of the outer comment, and should be colored as such */
The second example shows that the bundle doesn't understand back-ticked identifiers.
val `string/*` = Foo("""
I'm pleased to see that the tm grammar does understand that the /*
above is part of the identifier declaration. Pretty much anything can
go in there. Spaces, escaped characters, until the closing backtick.
It also understands that /* within strings don't really start comments.
""")
val length = `string/*`.explain("""
It doesn't understand this time that /* is part of the referenced identifier,
which means that the closing backtick, the method call, and this string
are all colored incorrectly as comments.
""")
I had planned to link to the language spec around back-ticked identifiers, but it turns out that the spec is messed up :disappointed:. I filed an issue about the spec here. Let me know if there's anything else I can do to help.
The first issue seems to have been patched in https://github.com/textmate/scala.tmbundle/commit/40f14ec14a5bfb3198ffc1629480d50b74850337.
I'll create a new issue for the second one.