| Thread overview | |||||
|---|---|---|---|---|---|
|
January 12, 2009 D2 Grammar | ||||
|---|---|---|---|---|
| ||||
In the documentation, the grammar for Declarator is:
Declarator:
BasicType2 Declarator DeclaratorSuffixesopt
BasicType2 Identifier DeclaratorSuffixesopt
How is possible to parse something like " int i,j; "?
What are the parser reduction steps?
Thanks in advance!
Paolo
| ||||
January 12, 2009 Re: D2 Grammar | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Paolo Invernizzi | Paolo Invernizzi wrote:
> In the documentation, the grammar for Declarator is:
>
> Declarator:
> BasicType2 Declarator DeclaratorSuffixesopt
> BasicType2 Identifier DeclaratorSuffixesopt
>
> How is possible to parse something like " int i,j; "?
> What are the parser reduction steps?
>
> Thanks in advance!
> Paolo
>
Why not take a peek at the source :p? parse.c has the method parseDeclarator. Like any recursive descent parser, it just checks the next token and then chooses what to parse next. You have to kind of unwind the grammar a bit to get all possible tokens that can appear next.
| |||
January 12, 2009 Re: D2 Grammar | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Paolo Invernizzi | Reply to Paolo,
> In the documentation, the grammar for Declarator is:
>
> Declarator:
> BasicType2 Declarator DeclaratorSuffixesopt
> BasicType2 Identifier DeclaratorSuffixesopt
> How is possible to parse something like " int i,j; "? What are the
> parser reduction steps?
>
> Thanks in advance!
> Paolo
The only real definition for the D grammar is the parser code itself (cpp source code). The BNF in the docs is known to be incomplete and/or wrong. In the past Walter has edited it from corrections people has submitted so...
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply