Re: Parsing C#-like generics

Hans-Peter Diettrich <>
Tue, 12 Jul 2011 13:25:46 +0100

          From comp.compilers

Related articles
Parsing C#-like generics (Harold Aptroot) (2011-07-11)
Re: Parsing C#-like generics (Hans-Peter Diettrich) (2011-07-12)
Re: Parsing C#-like generics (BGB) (2011-07-12)
Re: Parsing C#-like generics (Ben L. Titzer) (2011-07-13)
Re: Parsing C#-like generics (BGB) (2011-07-14)
| List of all articles for this month |

From: Hans-Peter Diettrich <>
Newsgroups: comp.compilers
Date: Tue, 12 Jul 2011 13:25:46 +0100
Organization: Compilers Central
References: 11-07-019
Keywords: parse
Posted-Date: 12 Jul 2011 20:04:42 EDT

Harold Aptroot schrieb:

> I'm having some trouble parsing generics when mixed with comparisons. The
> way I try to do it, there is an ambiguity between LessThan and a "list of
> types between angle brackets".
> For example, x<x>(x<x) should be syntactically OK, and it should be parsed
> to a function call x with a type parameter list < x > and a single argument
> which is the expression x<x (ok not really, I threw in semantics here to
> make it clearer, the actual result should just be an AST).

IMO you should better separate declarations from code (statements,
expressions). Then the parser will "know" from that context, that a
declaration can contain <x> type lists, but not x<y expressions.

Above example should parse better as
where the C style braces around statement blocks allow for better
disambiguation of the < token.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.