[Mono-list] Re: First Snapshot of MonoBASIC
Miguel de Icaza
miguel@ximian.com
16 Aug 2001 19:34:48 -0400
> >From what I saw of your code I think most of it 'looks' right for VB.NET,
> the biggest trouble I´m having is with how to handle initializers.
>
> In C# one can say:
>
> int z,x,y;
> int a=5,b=6;
>
> and in VB you say:
>
> Dim z,x,y as integer
> Dim a as integer = 5
> Dim b as integer = 6
You could handle this situation by using the extra data on the parse
tree to detect syntax errors:
decl
: DIM var_list as TYPE opt_init
{
if (opt_init != null){
if (var_list.Count != 1)
error ();
else
// single variable with initializer
} else {
// no initializer
}
}
;
var_list
: IDENTIFIER
{
ArrayList list = new ArrayList ();
list.Add ($1);
}
| var_list COMMA IDENTIFIER
{
ArrayList list = (ArrayList) $1;
list.Add ($3);
}
;
opt_init
: /* empty */
| EQUAL VALUE
{ $$ = $2; }
;