comparison parser/Parser.d @ 140:927ae00bd9d2

Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
author Anders Johnsen <skabet@gmail.com>
date Sun, 20 Jul 2008 23:23:56 +0200
parents 2be29b296081
children d76cc5cad4fc
comparison
equal deleted inserted replaced
136:2be29b296081 140:927ae00bd9d2
114 case Tok.Depracted: 114 case Tok.Depracted:
115 a.setDepracted; 115 a.setDepracted;
116 break; 116 break;
117 case Tok.Auto: 117 case Tok.Auto:
118 a.setAuto; 118 a.setAuto;
119 break;
120 case Tok.Extern:
121 Extern e = parseLinkageType;
122 a.setExtern(e);
119 break; 123 break;
120 } 124 }
121 if(sco) 125 if(sco)
122 { 126 {
123 sco = false; 127 sco = false;
194 .arg(t.getType) 198 .arg(t.getType)
195 .arg(Tok.Identifier) 199 .arg(Tok.Identifier)
196 .fatal(ExitLevel.Parser); 200 .fatal(ExitLevel.Parser);
197 } 201 }
198 202
203 Extern parseLinkageType()
204 {
205 Extern e = Extern.D;
206 if(lexer.peek(1).type != Tok.OpenParentheses)
207 return e;
208
209 lexer.next; lexer.next;
210
211 Token t = require(Tok.Identifier);
212
213 switch(sm.getText(t.asRange))
214 {
215 case "C":
216 if (lexer.peek(0).type == Tok.Plus &&
217 lexer.peek(1).type == Tok.Plus)
218 e = Extern.CPlusPlus;
219 else
220 e = Extern.C;
221 break;
222 case "D":
223 break;
224 case "Windows":
225 e = Extern.Windows;
226 break;
227 case "Pascal":
228 e = Extern.Pascal;
229 break;
230 case "System":
231 e = Extern.System;
232 break;
233 default:
234 messages.report(UnexpectedLinkType, t.location);
235 }
236
237 require(Tok.CloseParentheses);
238
239 return e;
240 }
241
199 /** 242 /**
200 Parse a series of imports belonging to a single import token. 243 Parse a series of imports belonging to a single import token.
201 */ 244 */
202 Decl[] parseImports() 245 Decl[] parseImports()
203 { 246 {