From: skaller <skaller@users.sourceforge.net>
To: Erik de Castro Lopo <ocaml-erikd@mega-nerd.com>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] yacc style
Date: 28 Jan 2005 15:30:30 +1100 [thread overview]
Message-ID: <1106886629.12114.246.camel@pelican.wigram> (raw)
In-Reply-To: <20050128132812.7001512c.ocaml-erikd@mega-nerd.com>
On Fri, 2005-01-28 at 13:28, Erik de Castro Lopo wrote:
> On 28 Jan 2005 12:14:39 +1100
> skaller <skaller@users.sourceforge.net> wrote:
>
> > On Fri, 2005-01-28 at 08:39, Erik de Castro Lopo wrote:
> > >
> > > Yes, normally the parser generates a parse tree which is then
> > > passed to the semantic analyser for semantic checking.
> >
> > Unfortunately this is useless in the common case
> > of needing to parse C.
>
> I'm happy to take your word for it John, but I'd like to know
> why.
Sure: there are several contexts, but one is that:
(X)(Y)(Z)
could mean either
((X)(Y))(Z)
or
(X)((Y)(Z))
depending on whether Y is a type, in which case (Y)(Z) is a cast,
or an expression, in which case (Y)(Z) is a function application.
The precedences of casts and function applications in C are different.
Function calls bind more tightly than casts, so (int)(f)(x) means
cast the result of f(x) to an int, whereas (g)(a)(b)
means apply g(a) to b .. assuming g,a,b are not typenames .. :)
Smly
(f)(x,y,z)
comma is a separator if f is a function, if f is a typename
its a cast, and (x,y,z) is an expression value 'z'... :)
I guess there is more, and C++ is worse, but this is enough
to be as confused as a one token lookahead context free
parser would be .. :)
--
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850,
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net
next prev parent reply other threads:[~2005-01-28 4:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-27 20:17 Chris King
2005-01-27 21:39 ` [Caml-list] " Erik de Castro Lopo
2005-01-28 1:14 ` skaller
2005-01-28 2:28 ` Erik de Castro Lopo
2005-01-28 4:30 ` skaller [this message]
2005-01-28 9:04 ` Jean-Christophe Filliatre
[not found] ` <200501272252.43720.jon@jdh30.plus.com>
2005-01-28 0:41 ` Chris King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1106886629.12114.246.camel@pelican.wigram \
--to=skaller@users.sourceforge.net \
--cc=caml-list@inria.fr \
--cc=ocaml-erikd@mega-nerd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).