PageRenderTime 20ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/parsing/d/forstmtunit.d

http://github.com/wilkie/djehuty
D | 81 lines | 54 code | 14 blank | 13 comment | 15 complexity | a62ede43abe02d65f0c86bddcb15d265 MD5 | raw file
 1/*
 2 * expressionunit.d
 3 *
 4 * This module parses expressions.
 5 *
 6 */
 7
 8module parsing.d.forstmtunit;
 9
10import parsing.parseunit;
11import parsing.token;
12
13import parsing.d.tokens;
14import parsing.d.nodes;
15
16import parsing.d.statementunit;
17import parsing.d.scopedstmtunit;
18import parsing.d.expressionunit;
19
20import io.console;
21
22import djehuty;
23
24class ForStmtUnit : ParseUnit {
25	override bool tokenFound(Token current) {
26		switch (current.type) {
27			case DToken.LeftParen:
28				Console.putln("For: ");
29				auto tree = expand!(StatementUnit)();
30				this.state = 1;
31				break;
32
33			case DToken.RightParen:
34				if (this.state < 3 || this.state > 4) {
35				}
36
37				// Found end of for loop expressions
38				this.state = 5;
39				auto tree = expand!(ScopedStmtUnit)();
40				break;
41
42			case DToken.Semicolon:
43				if (this.state == 0) {
44				}
45
46				if (this.state == 1) {
47					// No expression.
48					this.state = 3;
49				}
50				else if (this.state == 2) {
51					// Had expression, looking for end
52					// or loop expression
53					this.state = 3;
54				}
55				break;
56
57			// We have an expression here.	
58			default:
59				if (this.state == 1) {
60					// Invariant Expression
61					lexer.push(current);
62					auto tree = expand!(ExpressionUnit)();
63					this.state = 2;
64				}
65				else if (this.state == 3) {
66					// Loop expression
67					lexer.push(current);
68					auto tree = expand!(ExpressionUnit)();
69					this.state = 4;
70				}
71				break;
72		}
73		return true;
74	}
75
76protected:
77	string cur_string = "";
78
79	static const string _common_error_msg = "";
80	static const string[] _common_error_usages = null;
81}