Related articles |
---|
Parsing C#-like generics harold.aptroot@gmail.com (Harold Aptroot) (2011-07-11) |
Re: Parsing C#-like generics DrDiettrich1@aol.com (Hans-Peter Diettrich) (2011-07-12) |
Re: Parsing C#-like generics cr88192@hotmail.com (BGB) (2011-07-12) |
Re: Parsing C#-like generics ben.titzer@gmail.com (Ben L. Titzer) (2011-07-13) |
Re: Parsing C#-like generics cr88192@hotmail.com (BGB) (2011-07-14) |
From: | Hans-Peter Diettrich <DrDiettrich1@aol.com> |
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
x<x>{x<x}
where the C style braces around statement blocks allow for better
disambiguation of the < token.
DoDi
Return to the
comp.compilers page.
Search the
comp.compilers archives again.