kdev-pg: Token definitions

Jakob Petsovits jpetso at gmx.at
Thu Mar 2 19:09:52 UTC 2006


On Wednesday, 8. February 2006 18:00, Jakob Petsovits wrote:
> On Wednesday, 8. February 2006 17:18, Roberto Raggi wrote:
> > I like the patch. please commit it. I have a tiny suggestion. Sometimes
> > is very useful to associate some description to the token. For instance
> > you may want to associate the string ';' to the token SEMICOLON. This is
> > very useful when reporting errors. In general you want to use the token
> > description and not the token id in the error message (e.g. ';' not
> > SEMICOLON).
>
> Good idea, I'll try to do that. But it needs to be optional.

Ok, i'm late, but here it is:
The patch adapts the parser to accept token description strings,
adds an "_M_description" member to the terminal node structure,
and uses that one instead of the token name for error output.

A token list example, according to the new syntax:

%token NULL ("null"), STRING_LITERAL ("string literal"), ASSIGN ("="),
    LPAREN ("("), COMMA (","), ELLIPSIS ("..."), SOME_STRING ("\"some\"") ;;

Tokens without description strings are still accepted (mixing is allowed):

%token NULL, STRING_LITERAL, COMMA (",") ;;


When there is no description string, an error output looks like before:
** ERROR expected token ``RBRACE''
(which is the java parser command line tool version - it may look different in 
other frameworks, like when integrated in KDevelop)

With description strings available, it's less confusing now:
** ERROR expected token ``}''

So, ok to apply?

bye,
  Jakob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: token-descriptions.diff.gz
Type: application/x-gzip
Size: 1505 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20060302/3c1a9f7b/attachment.gz>


More information about the KDevelop-devel mailing list