Closed GoogleCodeExporter closed 8 years ago
I'm still learning Scala, but are you sure all of these are keywords.
Specifically, "match"?
Scala by example ( http://www.scala-lang.org/docu/files/ScalaByExample.pdf )
claims that it is a valid method name:
Pattern matching is a generalization of C or Java’s switch
statement to class hierarchies. Instead of a switch statement,
there is a standard method match, which is defined in Scala’s
root class Any, and therefore is available for all objects.
Maybe it should be highlit because of its special significance in common idioms
either way.
Original comment by msam...@google.com
on 11 Jun 2010 at 10:10
I am surprised by the quote you mention. If you look at the API, this method
does not exist: http://www.scala-lang.org/docu/files/api/scala/Any.html . Maybe
that's the way the pattern matching is or was implemented internally.
In the PDF you mention there is also a list of reserved words (page 29) which
includes match. Strangely, that list is missing two words from the list that I
mentionend: forSome and lazy. I suppose they are newer and were forgotten.
I tried to compile some code where I name a variable "match" which resulted in:
IsMatchAKeyword.scala:6: error: illegal start of simple pattern
val match = 4;
^
So it seems match really is a reserved word.
Original comment by christop...@gmail.com
on 11 Jun 2010 at 10:46
I can confirm that it's not on Any in the scaladoc and
http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk/src/compiler/scala/tools/nsc/
ast/parser/Parsers.scala contains the comment
| PostfixExpr match `{' CaseClauses `}'
which would seem to indicate "match" is a keyword.
The grammar that is spread throughout that class should provide the starting
point for a lang-scala.js extension.
Original comment by msam...@google.com
on 12 Jun 2010 at 12:57
From http://www.scala-lang.org/node/3419
Re: where is the machine-readable grammar for scala
Hi Greg,
I do not think the grammar exists anywhere as a whole, in the form you imply
(EBNF?). But I have a few pointers that might be of help:
a) Scattered BNF fragments in:
http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk/src/compiler/scala/tools/nsc/
ast/parser/Parsers.scala
Search for ::= in the Parsers.scala file
b) LaTeX-ized version of EBNF grammar in:
http://lampsvn.epfl.ch/svn-repos/scala/scala-documentation/trunk/src/reference/S
yntaxSummary.tex
c) Andrew Foggin's project:
http://code.google.com/p/scala-rules/
which builds a parser for the complete Scala grammar. AFAIK the Jetbrains gurus
use(d) this stuff for the IDEA Scala plugin.
BRChristos
Original comment by mikesamuel@gmail.com
on 21 Jul 2010 at 4:26
Added a scala mode at revision 108.
Please see
http://google-code-prettify.googlecode.com/svn/trunk/tests/prettify_test.html#sc
ala
Original comment by mikesamuel@gmail.com
on 21 Jul 2010 at 5:09
Original issue reported on code.google.com by
christop...@gmail.com
on 11 Jun 2010 at 9:23