Groups | Search | Server Info | Login | Register
Groups > comp.compilers > #197
| From | Hans-Peter Diettrich <DrDiettrich1@aol.com> |
|---|---|
| Newsgroups | comp.compilers |
| Subject | Re: Parsing C#-like generics |
| Date | 2011-07-12 13:25 +0100 |
| Organization | Compilers Central |
| Message-ID | <11-07-021@comp.compilers> (permalink) |
| References | <11-07-019@comp.compilers> |
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
x<x>{x<x}
where the C style braces around statement blocks allow for better
disambiguation of the < token.
DoDi
Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar
Parsing C#-like generics "Harold Aptroot" <harold.aptroot@gmail.com> - 2011-07-11 20:22 +0200
Re: Parsing C#-like generics Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2011-07-12 13:25 +0100
Re: Parsing C#-like generics BGB <cr88192@hotmail.com> - 2011-07-14 13:13 -0700
Re: Parsing C#-like generics BGB <cr88192@hotmail.com> - 2011-07-12 16:39 -0700
Re: Parsing C#-like generics "Ben L. Titzer" <ben.titzer@gmail.com> - 2011-07-13 10:19 -0700
csiph-web