PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/parsing/d/gotostmtunit.d

http://github.com/wilkie/djehuty
D | 76 lines | 49 code | 10 blank | 17 comment | 11 complexity | c89688e6ebca46826d6dc946fb4f45c4 MD5 | raw file
 1/*
 2 * expressionunit.d
 3 *
 4 * This module parses expressions.
 5 *
 6 */
 7
 8module parsing.d.gotostmtunit;
 9
10import parsing.parseunit;
11import parsing.token;
12
13import parsing.d.tokens;
14import parsing.d.nodes;
15
16import parsing.d.expressionunit;
17
18import io.console;
19
20import djehuty;
21
22class GotoStmtUnit : ParseUnit {
23	override bool tokenFound(Token current) {
24		switch (current.type) {
25			case DToken.Semicolon:
26				if (this.state == 0) {
27					// Error.
28					// TODO:
29				}
30				if (this.state == 2) {
31					// Error.
32					// TODO:
33				}
34				// Done.
35				return false;
36			case DToken.Identifier:
37				if (this.state != 0) {
38					// Error
39					// TODO:
40				}
41				Console.putln("Goto: ", current.value);
42				cur_string = current.value.toString();
43				this.state = 1;
44				break;
45			case DToken.Default:
46				Console.putln("Goto: Default");
47				this.state = 2;
48				break;
49			case DToken.Case:
50				Console.putln("Goto: Case");
51				this.state = 2;
52				break;
53			default:
54				if (this.state != 2) {
55					// Error
56					// TODO:
57				}
58
59				lexer.push(current);
60				if (this.state == 3) {
61					// Error: Multiple expressions
62					// TODO:
63				}
64				auto tree = expand!(ExpressionUnit)();
65				this.state = 3;
66				break;
67		}
68		return true;
69	}
70
71protected:
72	string cur_string = "";
73
74	static const string _common_error_msg = "";
75	static const string[] _common_error_usages = null;
76}