equal
deleted
inserted
replaced
|
1 // A simple lexer inspired by work of Sulzmann & Lu |
|
2 //================================================== |
|
3 |
|
4 |
|
5 object Delexer { |
|
6 |
|
7 import java.io._ |
|
8 |
|
9 abstract class Token extends Serializable |
|
10 case object T_SEMI extends Token |
|
11 case object T_LPAREN extends Token |
|
12 case object T_RPAREN extends Token |
|
13 case class T_ID(s: String) extends Token |
|
14 case class T_OP(s: String) extends Token |
|
15 case class T_NUM(n: Int) extends Token |
|
16 case class T_KWD(s: String) extends Token |
|
17 case class T_STR(s: String) extends Token |
|
18 |
|
19 def deserialise[T](fname: String) : T = { |
|
20 val in = new ObjectInputStream(new FileInputStream(fname)) |
|
21 val data = in.readObject.asInstanceOf[T] |
|
22 in.close |
|
23 data |
|
24 } |
|
25 |
|
26 def main(args: Array[String]) = { |
|
27 println("TEST\n" ++ deserialise[List[Token]]("/tmp/nflx").mkString) |
|
28 } |
|
29 |
|
30 |
|
31 } |