19 private Lexer.TokenType token;
21 public Parser(StreamReader stream) {
22 lexer = new Lexer(stream);
26 token = lexer.GetNextToken();
31 if(token == Lexer.TokenType.EOF) {
37 Console.WriteLine("Token: " + token.ToString() + " - " +
41 case Lexer.TokenType.CLOSE_PAREN:
43 throw new Exception("Parse Error: unexpected )");
45 type = LispType.END_LIST;
47 case Lexer.TokenType.OPEN_PAREN:
48 type = LispType.START_LIST;
51 case Lexer.TokenType.SYMBOL:
52 type = LispType.SYMBOL;
54 case Lexer.TokenType.STRING:
55 type = LispType.STRING;
57 case Lexer.TokenType.TRUE:
58 type = LispType.BOOLEAN;
60 case Lexer.TokenType.INTEGER:
61 type = LispType.INTEGER;
67 public static void ParseIntList(Parser parser, System.Collections.Generic.List<int> intList) {
69 while(parser.Depth >= d) {
70 intList.Add(parser.IntegerValue);
75 private LispType type;
76 public LispType Type {
79 private bool delayinc;
85 public string SymbolValue {
86 get { return lexer.TokenString; }
88 public string StringValue {
89 get { return lexer.TokenString; }
91 public int IntegerValue {
92 get { return Int32.Parse(lexer.TokenString); }
94 public bool BoolValue {
95 get { return StringValue == "t"; }
97 public float FloatValue {
98 get { return Single.Parse(lexer.TokenString); }