Liste des Groupes | Revenir à cl c |
Ben Bacarisse <ben@bsb.me.uk> writes:
>
[...]
>And as for your remarks about typical implementations, does your C>
parser /really/ accept an assignment expression on both sides of
an = operator? What does that even look like in the code? I have
written one C parser, contributed to one other and (over the
years) examined at least two more, and none of them do what you
seem to be suggesting is typical.
It wouldn't be surprising to see a parser written so it would
accept (syntactically) a superset of the well-formed inputs
allowed by the language grammar. Any parses not allowed by the
grammar could then be flagged as erroneous in a later semantics
pass.
One reason to do this is to simplify error recovery in the face
of syntax errors. It's much easier to recover from a "correct"
parse than from one that looks hopelessly lost.
>
I'm not making any claim that such an approach is typical. On
the other hand it does seem to fit with some of the diagnostics
given by gcc for inputs that are syntactically ill-formed.
Les messages affichés proviennent d'usenet.