Related articles |
---|
Parser ambiguity m.helvensteijn@gmail.com (2009-03-15) |
Re: Parser ambiguity cfc@shell01.TheWorld.com (Chris F Clark) (2009-03-15) |
Re: Parser ambiguity max@gustavus.edu (Max Hailperin) (2009-03-15) |
Re: Parser ambiguity m.helvensteijn@gmail.com (2009-03-16) |
Re: Parser ambiguity m.helvensteijn@gmail.com (2009-03-16) |
From: | m.helvensteijn@gmail.com |
Newsgroups: | comp.compilers |
Date: | Mon, 16 Mar 2009 05:24:43 -0700 (PDT) |
Organization: | Compilers Central |
References: | 09-03-066 09-03-071 |
Keywords: | parse, comment |
Posted-Date: | 17 Mar 2009 07:08:50 EDT |
On Mar 16, 1:28 am, Chris F Clark <c...@shell01.TheWorld.com> wrote:
> > The problem is that, syntactically, a function-declaration doesn't
> > need any sections ...
>
> Doesn't your language require a semicolon at the end of a
> function-declaration with no body? Most languages of the form you
> have described do. If it does, "int f()" cannot be a function
> declaration by itself.
I did say 'syntactically'. It's a trick to avoid grammar duplication.
After parsing, the compiler would give an error if you did not provide
at least a function body.
--
Michiel Helvensteijn
[So change the grammar to require at least one body part.
function_declaration:
type identifier '(' formal_parameter_list ')' bodylist ;
bodylist: bodypart | bodylist bodypart ;
bodypart: '{' statement_sequence '}'
| "body" '{' statement_sequence '}'
| "pre" '{' statement_sequence '}'
| "post" '{' statement_sequence '}'
;
-John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.