Liste des Groupes | Revenir à cl c |
bart <bc@freeuk.com> wrote:I can't call it 'context sensitive' because that is a technical term with a specific meaning, but it would be a good description.On 09/12/2024 18:46, Janis Papanagnou wrote:C grammar is not LL(1), that is you can not recognize a constructOn 07.12.2024 16:33, Bart wrote:>>So you're a parser and you see this:>
>
do ... while
>
How do you know whether that 'while' starts a new nested loop or
terminates this one?
Because there's the '...' in between that answers that question.
Oh, I see. That answers everything! Including having a '...' that
includes statements starting with 'while'.
looking at its first token. You need the whole construct and
sometimes also the following token. And there are also well
known troubles due to type names and "dangling else".
So CIt's harder than it need be. You can go quite a way into a declaration before you even know whether it's a function definition, a function declaration, a variable declaration/definition, or even a typedef definition, since 'typedef' can appear towards the end of the basetype:
is almost, but not entirely LR(1). But the description, that
is grammar + extra rules is unambigious, not very complex and
it is well-known how to parse C with good efficiency.
Les messages affichés proviennent d'usenet.