Goldie Parsing System v0.4 Released - Now for D2

Kagamin spam at here.lot
Sat Apr 16 15:27:46 PDT 2011


Nick Sabalausky Wrote:

> Yea, turns out that grammar just doesn't support using user-defined types 
> without preceding them with "struct", "union", or "enum". You can see that 
> here:
> 
> <Var Decl>     ::= <Mod> <Type> <Var> <Var List>  ';'
>                  |       <Type> <Var> <Var List>  ';'
>                  | <Mod>        <Var> <Var List>  ';'
> 
> <Mod>      ::= extern
>              | static
>              | register
>              | auto
>              | volatile
>              | const
> 
> <Type>     ::= <Base> <Pointers>
> 
> <Base>     ::= <Sign> <Scalar>  ! Ie, the built-ins like char, signed int, 
> etc...
>              | struct Id
>              | struct '{' <Struct Def> '}'
>              | union Id
>              | union '{' <Struct Def> '}'
>              | enum Id
> 
> So when you use "MyType" instead of "struct MyType": It sees "MyType", 
> assumes it's a variable since it doesn't match any of the <Type> forms 
> above, and then barfs on "var" because "variable1 variable2" isn't valid C 
> code. Normally, you'd just add another form to <Base> (Ie, add a line after 
> "  | enum Id" that says "  | Id "). Except, the problem is...
> 
> C is notorious for types and variables being ambiguous with each other.

As I understand, <Type> is a type, <Var> is a variable. There should be no problem here.


More information about the Digitalmars-d-announce mailing list