@@ -29,24 +29,24 @@ To support multiple Scala versions, see the example in [scala/scala-module-depen
29
29
import scala .util .parsing .combinator ._
30
30
31
31
case class WordFreq (word : String , count : Int ) {
32
- override def toString = " Word <" + word + " > " +
33
- " occurs with frequency " + count
32
+ override def toString = " Word <" + word + " > " +
33
+ " occurs with frequency " + count
34
34
}
35
35
36
36
class SimpleParser extends RegexParsers {
37
- def word : Parser [String ] = """ [a-z]+""" .r ^^ { _.toString }
38
- def number : Parser [Int ] = """ (0|[1-9]\d*)""" .r ^^ { _.toInt }
39
- def freq : Parser [WordFreq ] = word ~ number ^^ { case wd ~ fr => WordFreq (wd,fr) }
37
+ def word : Parser [String ] = """ [a-z]+""" .r ^^ { _.toString }
38
+ def number : Parser [Int ] = """ (0|[1-9]\d*)""" .r ^^ { _.toInt }
39
+ def freq : Parser [WordFreq ] = word ~ number ^^ { case wd ~ fr => WordFreq (wd,fr) }
40
40
}
41
41
42
42
object TestSimpleParser extends SimpleParser {
43
- def main (args : Array [String ]) = {
44
- parse(freq, " johnny 121" ) match {
45
- case Success (matched,_) => println(matched)
46
- case Failure (msg,_) => println(" FAILURE: " + msg)
47
- case Error (msg,_) => println(" ERROR: " + msg)
48
- }
43
+ def main (args : Array [String ]) = {
44
+ parse(freq, " johnny 121" ) match {
45
+ case Success (matched,_) => println(matched)
46
+ case Failure (msg,_) => println(" FAILURE: " + msg)
47
+ case Error (msg,_) => println(" ERROR: " + msg)
49
48
}
49
+ }
50
50
}
51
51
```
52
52
0 commit comments