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

/parsing/d/declaratorsuffixunit.d

http://github.com/wilkie/djehuty
D | 89 lines | 57 code | 14 blank | 18 comment | 4 complexity | c59950b4e9f46fc9f65ecfe5c6aec585 MD5 | raw file
 1/*
 2 * expressionunit.d
 3 *
 4 * This module parses expressions.
 5 *
 6 */
 7
 8module parsing.d.declaratorsuffixunit;
 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 DeclaratorSuffixUnit : ParseUnit {
23	override bool tokenFound(Token current) {
24		switch (this.state) {
25			case 0:
26				// Looking for ( or [
27				// Types which have () or [] after them
28				switch (current.type) {
29					case DToken.LeftParen:
30						this.state = 1;
31						break;
32					case DToken.LeftBracket:
33						this.state = 2;
34						break;
35					default:
36						break;
37				}
38				break;
39
40			case 1:
41				// We have found a ( so we are searching for
42				// a right parenthesis
43				switch (current.type) {
44					case DToken.RightParen:
45						// Done
46						Console.putln("()");
47						break;
48					default:
49						// This is a parameter list
50						// XXX:
51//						auto tree = expand!(ParameterList)();
52						break;
53				}
54				return false;
55
56			case 2:
57				// We have found a [ so we are searching for
58				// a right bracket.
59				switch (current.type) {
60					case DToken.RightBracket:
61						Console.putln("[]");
62						// Done
63						return false;
64
65					case DToken.Dot:
66						break;
67
68					case DToken.Identifier:
69						break;
70
71					default:
72						// We should assume it is an expression
73						lexer.push(current);
74						auto tree = expand!(ExpressionUnit)();
75						break;
76				}
77				break;
78			default:
79				break;
80		}
81		return true;
82	}
83
84protected:
85	string cur_string = "";
86
87	static const string _common_error_msg = "";
88	static const string[] _common_error_usages = null;
89}