Aladdin - Scala Bugtracking
[#384] project: specification priority: low category: feature
submitter assigned to status date submitted
Philippe Martin won't fix 2004-12-13 18:28:12.0
subject The scanner does not use the longest match rule for ids containing // and /*
code
object Bug {
  val +       = '0';
  val +------ = 'A';
  val +/----- = 'B';
  val +//---- = 'C';
  val +/*/--- = 'D';
  val +/**/-- = 'E';
  val +/***/- = 'F';
  val +/****/ = 'G';
  val +/***** = 'H';
  val +/****- = 'I';
  val +/***-- = 'J';
  val +/**--- = 'K';
  val +/*---- = 'L';
}
what happened
tmp/test.scala:5: '=' expected but 'val' found.
  val +//---- = 'C';
                    ^
tmp/test.scala:6: unclosed comment
  val +/*/--- = 'D';
      ^
tmp/test.scala:606: illegal start of expression

^
three errors found
what expected Each line should define a new field. If the longest match rule is applied then this program contains no comment only identifiers, keywords and punctuation.
[back to overview]
Changes of this bug report
Burak  edited on  2004-12-16 15:01:01.0
Actually, the longest match rule applies only to operators and identifiers. Comments are whitespace, and handled differently. The spec probably needs some clarification like "eliding of comments happens before parsing".
So I change "project" to "specification" and reassign to Martin.
Burak  edited on  2004-12-16 15:01:36.0
Philippe  edited on  2004-12-16 15:30:30.0
Note that "eliding of comments happens before parsing" is significantly different from what happens in Java. In Java, comments and tokens are parsed at the same time and the longest match rule applies to everything. This implies that if in Java we changed the syntax of identifiers to the Scala syntax, then "+//-" would be recognised as an identifier.
Burak  edited on  2004-12-16 16:11:00.0
Sure, there has just a choice to be made. In this choice (comments are whitespace, are stripped before parsing), uniform handling of comments outweighs uniform handling of operators.
Martin  edited on  2006-05-28 21:56:39.0
I agree with Burak and close the bug.