kdev-pg: Token definitions

Jakob Petsovits jpetso at gmx.at
Wed Feb 8 18:01:10 UTC 2006


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.

> so how about you change a bit the patch so we can write things like
> %token SEMICOLON = ";"
> %token ID "identifier"
> ...

Hmm... to me this looks very much like a lexer replacement. ANTLR has a 
similar syntax in its token definitions that can be used to parse the given 
string without being helped by the lexer (although I don't know how it 
works). How about this one:

%token SEMICOLON (";"), ID ("identifier") ;;

It would at least show that the string is not so important.

bye,
  Jakob




More information about the KDevelop-devel mailing list