summaryrefslogtreecommitdiff
path: root/docs/examples/typeinf.scala
diff options
context:
space:
mode:
Diffstat (limited to 'docs/examples/typeinf.scala')
-rw-r--r--docs/examples/typeinf.scala9
1 files changed, 6 insertions, 3 deletions
diff --git a/docs/examples/typeinf.scala b/docs/examples/typeinf.scala
index d9b2b5f3d1..f21d514f87 100644
--- a/docs/examples/typeinf.scala
+++ b/docs/examples/typeinf.scala
@@ -149,7 +149,7 @@ object typeInfer {
)
}
- mixin class MiniMLParsers extends CharParsers {
+ trait MiniMLParsers extends CharParsers {
/** whitespace */
def whitespace = rep{chr(' ') ||| chr('\t') ||| chr('\n')}
@@ -157,11 +157,14 @@ object typeInfer {
/** A given character, possible preceded by whitespace */
def wschr(ch: char) = whitespace &&& chr(ch)
+ def isLetter = (c: char) => Character.isLetter(c)
+ def isLetterOrDigit: char => boolean = Character.isLetterOrDigit
+
/** identifiers or keywords */
def id: Parser[String] =
for (
- val c: char <- rep(chr(' ')) &&& chr(Character.isLetter);
- val cs: List[char] <- rep(chr(Character.isLetterOrDigit))
+ val c: char <- rep(chr(' ')) &&& chr(isLetter);
+ val cs: List[char] <- rep(chr(isLetterOrDigit))
) yield (c :: cs).mkString("", "", "")
/** Non-keyword identifiers */