PageRenderTime 33ms CodeModel.GetById 13ms app.highlight 15ms RepoModel.GetById 1ms app.codeStats 0ms

/parsing/d/foreachstmtunit.d

http://github.com/wilkie/djehuty
D | 97 lines | 75 code | 12 blank | 10 comment | 24 complexity | f5297d133e3110a14b479dae09fec53b MD5 | raw file
 1/*
 2 * expressionunit.d
 3 *
 4 * This module parses expressions.
 5 *
 6 */
 7
 8module parsing.d.foreachstmtunit;
 9
10import parsing.parseunit;
11import parsing.token;
12
13import parsing.d.tokens;
14import parsing.d.nodes;
15
16import parsing.d.expressionunit;
17import parsing.d.scopedstmtunit;
18import parsing.d.typeunit;
19
20import io.console;
21
22import djehuty;
23
24class ForeachStmtUnit : ParseUnit {
25	override bool tokenFound(Token current) {
26		switch (current.type) {
27			case DToken.LeftParen:
28				if (this.state > 0) {
29					// Error: Already found left parenthesis.
30					// TODO:
31				}
32				this.state = 1;
33				break;
34			case DToken.RightParen:
35				if (this.state != 5) {
36				}
37				auto tree = expand!(ScopedStmtUnit)();
38				return false;
39			case DToken.Ref:
40				if (this.state == 0) {
41				}
42				else if (this.state >= 2) {
43				}
44				this.state = 2;
45				break;
46			case DToken.Identifier:
47				if (this.state == 0) {
48				}
49				if (this.state > 3) {
50				}
51				if (this.state == 3) {
52					this.state = 4;
53				}
54				else {
55					// This needs lookahead to know it isn't a type
56					Token foo = lexer.pop();
57					lexer.push(foo);
58					if (foo.type == DToken.Comma || foo.type == DToken.Semicolon) {
59						this.state = 4;
60					}
61					else {
62						lexer.push(current);
63	
64						// Getting type of identifier
65						auto tree = expand!(TypeUnit)();
66	
67						this.state = 3;
68					}
69				}
70
71				if (this.state == 4) {
72					Console.putln("Foreach: identifier: ", current.value);
73				}
74				break;
75			case DToken.Semicolon:
76				if (this.state < 4) {
77				}
78				auto tree = expand!(ExpressionUnit)();
79				this.state = 5;
80				break;
81			case DToken.Comma:
82				if (this.state != 4) {
83				}
84				this.state = 1;
85				break;
86			default:
87				break;
88		}
89		return true;
90	}
91
92protected:
93	string cur_string = "";
94
95	static const string _common_error_msg = "";
96	static const string[] _common_error_usages = null;
97}