PageRenderTime 22ms CodeModel.GetById 12ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/parsing/d/parameterunit.d

http://github.com/wilkie/djehuty
D | 83 lines | 47 code | 15 blank | 21 comment | 10 complexity | c8a2800888f7c430dc119b1d0877a9d4 MD5 | raw file
 1/*
 2 * expressionunit.d
 3 *
 4 * This module parses expressions.
 5 *
 6 */
 7
 8module parsing.d.parameterunit;
 9
10import parsing.parseunit;
11import parsing.token;
12
13import parsing.d.tokens;
14import parsing.d.nodes;
15
16import parsing.d.parameterlistunit;
17import parsing.d.functionbodyunit;
18import parsing.d.declaratorunit;
19import parsing.d.basictypeunit;
20
21import io.console;
22
23import djehuty;
24
25class ParameterUnit : ParseUnit {
26	override bool tokenFound(Token current) {
27		switch (current.type) {
28
29			// Default Initializers
30			case DToken.Assign:
31				if (this.state < 1) {
32					// Error: We don't have a declarator!
33					// TODO:
34				}
35				// TODO:
36				// auto tree = expand!(DefaultInitializerUnit)();
37
38				// Done.
39				return false;
40
41			// Figure out the specifier.
42			case DToken.In:
43			case DToken.Out:
44			case DToken.Ref:
45			case DToken.Lazy:
46				if (this.state >= 1) {
47					// Error: Already have an in, out, ref, or lazy specifier.
48					// TODO:
49				}
50
51				// Specifier.
52
53				// Fall through to hit the declarator call
54
55			default:
56				lexer.push(current);
57				if (this.state == 2) {
58					// Could not find an equals
59					// Done.
60					lexer.push(current);
61					return false;
62				}
63				if (this.state == 1) {
64					// Could be a declarator then.
65					auto tree = expand!(DeclaratorUnit)();
66					this.state = 2;
67				}
68				else if (this.state == 0) {
69					// Hopefully this is a BasicType 
70					auto tree = expand!(BasicTypeUnit)();
71					this.state = 1;
72				}
73				break;
74		}
75		return true;
76	}
77
78protected:
79	string cur_string = "";
80
81	static const string _common_error_msg = "";
82	static const string[] _common_error_usages = null;
83}