FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Bug: Parser fails on 'const' after parameters

 
Post new topic   Reply to topic     Forum Index -> Poseidon
View previous topic :: View next topic  
Author Message
Etherous



Joined: 05 Sep 2009
Posts: 6

PostPosted: Thu May 12, 2011 1:56 pm    Post subject: Bug: Parser fails on 'const' after parameters Reply with quote

The following will cause poseidon's parser to fail when parsing a source file (attempted on r278). If anyone plans to create a fix, please also have const methods be indicated as const in the outline:
Code:

class Foo
{
    int bar () const; // Fails
    int bar const (); // Fails
    const int bar (); // Okay (but not indicated as const in outline)
    const(int) bar (); // Okay
}
Back to top
View user's profile Send private message
Kuan Hsu



Joined: 15 Apr 2006
Posts: 143
Location: Taiwan

PostPosted: Mon Jun 06, 2011 4:23 am    Post subject: Reply with quote

In recent day, I rewrote CodeAnalyzer follow D Programming Language Language Reference.

At first, I rewrote for DMD1.0, it worked well, the newest code can completelly parsed phobos and tango, then I think I could continue to DMD2.0 by the same way.

But I am too Naive! By the same way I could'nt parsed DMD2.0 phobos very well, too many files are parsed failure! I need to fix the code again and again evan they are not exist in DMD2.0 Language Reference!

for example:
Code:
        foreach (Unused; 0..blocks) {
            immutable val = srcptr[0] << 16 | srcptr[1] << 8 | srcptr[2];
            *bufptr++ = EncodeMap[val >> 18       ];
            *bufptr++ = EncodeMap[val >> 12 & 0x3f];
            *bufptr++ = EncodeMap[val >>  6 & 0x3f];
            *bufptr++ = EncodeMap[val       & 0x3f];
            srcptr += 3;
        }

I can't realize how "0..blocks" can parse pass, the Language Reference says:
Code:
ForeachStatement:
    Foreach (ForeachTypeList ; Aggregate) NoScopeNonEmptyStatement

Foreach:
    foreach
    foreach_reverse

ForeachTypeList:
    ForeachType
    ForeachType , ForeachTypeList

ForeachType:
    ref BasicType Declarator
    BasicType Declarator
    ref Identifier
    Identifier

Aggregate:
    Expression

but the Expression just only SliceExpression, it should put between [ ]
Code:
      SliceExpression:
         PostfixExpression [ ]
         PostfixExpression [ AssignExpression .. AssignExpression ]

Although I can fixed the code to expand Expression, but it isn't follow the Language Reference!

So forgive me, I won't plan to create a fix, because I've tried, then I fail.... Evil or Very Mad
Back to top
View user's profile Send private message Send e-mail
Kuan Hsu



Joined: 15 Apr 2006
Posts: 143
Location: Taiwan

PostPosted: Sat Jun 11, 2011 7:09 pm    Post subject: Re: Bug: Parser fails on 'const' after parameters Reply with quote

Etherous wrote:
The following will cause poseidon's parser to fail when parsing a source file (attempted on r278). If anyone plans to create a fix, please also have const methods be indicated as const in the outline:
Code:

class Foo
{
    int bar () const; // Fails
    int bar const (); // Fails
    const int bar (); // Okay (but not indicated as const in outline)
    const(int) bar (); // Okay
}


Fixed at rev.279, but
Code:
int bar const (); // Fails

is Illegal(compile error)
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Poseidon All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group