List Info

Thread: Error reporting bug in kdev-pg?




Error reporting bug in kdev-pg?
user name
2007-07-13 05:16:05
Hi,

I'm seeing another wrong thing, which I think is a bug, with
kdev-pg.
The current parser for qmake can only parse mutliple NEWLINE
tokens. For
the following file content:

DEPENDPATH += foo

however the first generated token is DEPENDPATH so the
parser fails and
reports the error. What I get for that as error message is:
** ERROR: Expected symbol "project" (current
token: "+=" [1014] at line: 0 col: 11)

So the current index() of the token_stream points already to
the "next"
token. 

So unless I'm mistaken, the parser always reports the token
_after_ the
errorneous one and I think this is not really good. OTOH it
could be by
design, because thats the lookahead token. So what is it -
bug or
feature?

Andreas

-- 
Someone is speaking well of you.

_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

Re: Error reporting bug in kdev-pg?
country flaguser name
Italy
2007-07-13 05:37:49
Hi Andreas,

Il giorno 13/lug/07, alle ore 12:16, Andreas Pakulat ha
scritto:
> design, because thats the lookahead token. So what is
it - bug or
> feature?

it's a feature  it is
the way LL works. LR parsers are different,  
they have the capability to detect an error at the earliest
point  
(well, at least canonical LR)

ciao robe


_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

Re: Error reporting bug in kdev-pg?
user name
2007-07-13 06:32:38
On 13.07.07 12:37:49, Roberto Raggi wrote:
> Hi Andreas,
> 
> Il giorno 13/lug/07, alle ore 12:16, Andreas Pakulat ha
scritto:
> > design, because thats the lookahead token. So what
is it - bug or
> > feature?
> 
> it's a feature  it is
the way LL works. LR parsers are different,  
> they have the capability to detect an error at the
earliest point  
> (well, at least canonical LR)

So can I just do 

size_t index = token_stream->index()-1;
token_type& token = token_stream->token(index);

to get "expected" error reporting? Or does that
have possible bad
side-effects? (I personally can't see why it should, except
if there's a
bug and it seems to work fine here)

Andreas

-- 
You will gain money by an immoral action.

_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

Re: Error reporting bug in kdev-pg?
country flaguser name
Italy
2007-07-13 10:03:14
Hi

Il giorno 13/lug/07, alle ore 13:32, Andreas Pakulat ha
scritto:
> So can I just do
>
> size_t index = token_stream->index()-1;
> token_type& token = token_stream->token(index);
>
> to get "expected" error reporting? Or does
that have possible bad
> side-effects? (I personally can't see why it should,
except if  
> there's a
> bug and it seems to work fine here)

As I said before it is not a bug. btw I don't see why you
want to do  
that. In general the standard error message (when using LL)
is  
something like
   *** Unexpected token `foo' at (line, col).

and `foo' is the look-ahead token, so I really don't
understand why  
you want to use the last recognized token (the one at
position  
token_stream->index() - 1).

ciao robe



_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

Re: Error reporting bug in kdev-pg?
user name
2007-07-13 10:14:33
On 13.07.07 17:03:14, Roberto Raggi wrote:
> Hi
> 
> Il giorno 13/lug/07, alle ore 13:32, Andreas Pakulat ha
scritto:
> > So can I just do
> >
> > size_t index = token_stream->index()-1;
> > token_type& token =
token_stream->token(index);
> >
> > to get "expected" error reporting? Or
does that have possible bad
> > side-effects? (I personally can't see why it
should, except if  
> > there's a
> > bug and it seems to work fine here)
> 
> As I said before it is not a bug. btw I don't see why
you want to do  
> that. In general the standard error message (when using
LL) is  
> something like
>    *** Unexpected token `foo' at (line, col).
> 
> and `foo' is the look-ahead token, so I really don't
understand why  
> you want to use the last recognized token (the one at
position  
> token_stream->index() - 1).

Uhm, then somethings wrong with the parser. As I said
currently the
qmake parser only recognizes NEWLINE tokens, but the example
file
contains no newline in the first 3 tokens. 

All I'm asking is to get an error message telling me on
which token the
error occurs, not the one after that and the error occurs
when the
parser expects NEWLINE but gets something different
(IDENTIFIER in this
case, while it reports PLUSEQ).

I hope its clear I'm not asking for the last recognized
token, I'm
asking to get the last unexpected token. 

Andreas

-- 
Beware the one behind you.

_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

Re: Error reporting bug in kdev-pg?
country flaguser name
Italy
2007-07-13 10:35:26
Il giorno 13/lug/07, alle ore 17:14, Andreas Pakulat ha
scritto:
> Uhm, then somethings wrong with the parser. As I said
currently the
> qmake parser only recognizes NEWLINE tokens, but the
example file
> contains no newline in the first 3 tokens.
>
> All I'm asking is to get an error message telling me on
which token  
> the
> error occurs, not the one after that and the error
occurs when the
> parser expects NEWLINE but gets something different
(IDENTIFIER in  
> this
> case, while it reports PLUSEQ).
>
> I hope its clear I'm not asking for the last recognized
token, I'm
> asking to get the last unexpected token.

oops! I see. The problem is the token_stream's next_token()

   inline int kdev_pg_token_stream::next_token() {
     return _M_token_buffer[_M_index++].kind;
   }

see? _M_index points to the next token and not to the
look-ahead.  
This is so unintuitive! I hate myself  well,
add a function (e.g.  
yytoken_index() or something like that) to
kdev_pg_token_stream. The  
function should return `0' if _M_index is `0'  and _M_index
- 1 when  
_M_index is valid.

ciao robe


_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

Re: Error reporting bug in kdev-pg?
user name
2007-07-13 11:42:53
On 13.07.07 17:35:26, Roberto Raggi wrote:
> 
> Il giorno 13/lug/07, alle ore 17:14, Andreas Pakulat ha
scritto:
> > Uhm, then somethings wrong with the parser. As I
said currently the
> > qmake parser only recognizes NEWLINE tokens, but
the example file
> > contains no newline in the first 3 tokens.
> >
> > All I'm asking is to get an error message telling
me on which token  
> > the
> > error occurs, not the one after that and the error
occurs when the
> > parser expects NEWLINE but gets something
different (IDENTIFIER in  
> > this
> > case, while it reports PLUSEQ).
> >
> > I hope its clear I'm not asking for the last
recognized token, I'm
> > asking to get the last unexpected token.
> 
> oops! I see. The problem is the token_stream's
next_token()
> 
>    inline int kdev_pg_token_stream::next_token() {
>      return _M_token_buffer[_M_index++].kind;
>    }
> 
> see? _M_index points to the next token and not to the
look-ahead.  
> This is so unintuitive! I hate myself 

At least its easy to spot with simple grammars 

> well, add a function (e.g.  yytoken_index() or
something like that) to
> kdev_pg_token_stream. The  function should return `0'
if _M_index is
> `0'  and _M_index - 1 when  _M_index is valid.

Ok, will do so.

Andreas

-- 
You have a reputation for being thoroughly reliable and
trustworthy.
A pity that it's totally undeserved.

_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

Re: Error reporting bug in kdev-pg?
user name
2007-07-13 21:59:19
On Friday 13 July 2007 10:35, Roberto Raggi wrote:
> Il giorno 13/lug/07, alle ore 17:14, Andreas Pakulat ha
scritto:
> > Uhm, then somethings wrong with the parser. As I
said currently the
> > qmake parser only recognizes NEWLINE tokens, but
the example file
> > contains no newline in the first 3 tokens.
> >
> > All I'm asking is to get an error message telling
me on which token
> > the
> > error occurs, not the one after that and the error
occurs when the
> > parser expects NEWLINE but gets something
different (IDENTIFIER in
> > this
> > case, while it reports PLUSEQ).
> >
> > I hope its clear I'm not asking for the last
recognized token, I'm
> > asking to get the last unexpected token.
>
> oops! I see. The problem is the token_stream's
next_token()
>
>    inline int kdev_pg_token_stream::next_token() {
>      return _M_token_buffer[_M_index++].kind;
>    }
>
> see? _M_index points to the next token and not to the
look-ahead.
> This is so unintuitive! I hate myself  well,
add a function (e.g.
> yytoken_index() or something like that) to
kdev_pg_token_stream. The
> function should return `0' if _M_index is `0'  and
_M_index - 1 when
> _M_index is valid.
>
> ciao robe
>

Now now, no need for self hate.  
-- 
Matt

_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

[1-8]

about | contact  Other archives ( Real Estate discussion Medical topics )