comparison parser/Parser.d @ 154:0ea5d2f3e96b

Parsing "this" as constructor. Also removed regex from the test run program(seg fault - dmd???)
author Anders Johnsen <skabet@gmail.com>
date Mon, 21 Jul 2008 21:45:54 +0200
parents 893f23a9de93
children 57b0b4464a0b
comparison
equal deleted inserted replaced
153:ee202c72cd30 154:0ea5d2f3e96b
99 return action.actOnDeclarator(type, iden, exp, att); 99 return action.actOnDeclarator(type, iden, exp, att);
100 } 100 }
101 else if ( isa(Tok.OpenParentheses) ) 101 else if ( isa(Tok.OpenParentheses) )
102 return parseFunc(type, iden, att); 102 return parseFunc(type, iden, att);
103 else 103 else
104 messages.report(UnexpectedTok, next().location).arg(next().getType); 104 {
105 auto n1 = next();
106 messages.report(UnexpectedTok, n1.location).arg(n1.getType);
107 }
105 return null; 108 return null;
106 } 109 }
107 t = peek(len); 110 t = peek(len);
108 messages.report(InvalidDeclType, t.location) 111 messages.report(InvalidDeclType, t.location)
109 .arg(sm.getText(t.asRange)); 112 .arg(sm.getText(t.asRange));
110 while(len--) 113 while(len--)
111 next(); 114 next();
112 while(peek.type != Tok.Identifier) 115 while( !isa(Tok.Identifier) && !isa(Tok.EOF))
113 next(); 116 next();
117 if ( isa(Tok.EOF ) )
118 messages.report(UnexpectedTok, t.location)
119 .fatal(ExitLevel.Parser);
120
114 type = Id(peek); 121 type = Id(peek);
115 goto parseDeclAfterInvalidType; 122 goto parseDeclAfterInvalidType;
116 } 123 }
117 else if (t.type == Tok.Struct) 124 else if (t.type == Tok.Struct)
118 { 125 {
354 while( !isa(Tok.EOF) && !isa(Tok.CloseBrace) ) 361 while( !isa(Tok.EOF) && !isa(Tok.CloseBrace) )
355 { 362 {
356 while ( peek.isAttribute ) 363 while ( peek.isAttribute )
357 nes ~= parseAttribute(nes[$-1]); 364 nes ~= parseAttribute(nes[$-1]);
358 365
359 auto m_decl = parseDecl(nes[$-1].a); 366 switch(peek.type)
360 action.actOnClassMember(decl, m_decl); 367 {
368 case Tok.This:
369 auto id = Id(next);
370 auto m_decl = parseFunc(iden, id, nes[$-1].a);
371 break;
372
373 default:
374 auto m_decl = parseDecl(nes[$-1].a);
375 action.actOnClassMember(decl, m_decl);
376 }
361 377
362 nes = parseAttributeScope(nes); 378 nes = parseAttributeScope(nes);
363 } 379 }
364 380
365 require(Tok.CloseBrace); 381 require(Tok.CloseBrace);