%token DEFAULT
%token DELEGATE
%token DIM
+%token DIRECTCAST
%token DO
%token DOUBLE
%token EACH
%token ELSE
%token ELSEIF
%token END
+%token ENDIF
%token ENUM
%token EOL
%token ERASE
%token FRIEND
%token FUNCTION
%token GET
-//%token GETTYPE
+%token GETTYPE
+%token GOSUB
%token GOTO
%token HANDLES
%token IF
%token UNICODE
%token UNTIL
%token VARIANT
+%token WEND
%token WHEN
%token WHILE
%token WITH
: logical_end_of_line
opt_option_directives
opt_imports_directives
- opt_attributes
+ opt_global_attributes
opt_declarations
EOF
{
$$=$5;
- }
+ }
+
;
opt_option_directives
imports_terms
: imports_term
- | imports_terms COMMA imports_terms
+ | imports_terms COMMA imports_term
;
imports_term
- : qualified_identifier
+ : qualified_identifier
{
RootContext.SourceBeingCompiled.Imports ((string) $1, lexer.Location);
}
- | qualified_identifier ASSIGN qualified_identifier
+ | qualified_identifier ASSIGN qualified_identifier //FIXME: Should it be identifier ASSIGN qualified_identifier
{
RootContext.SourceBeingCompiled.ImportsWithAlias ((string) $1, (string) $3, lexer.Location);
}
| OPEN_PARENS CLOSE_PARENS { $$ = Parameters.EmptyReadOnlyParameters; }
| OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS { $$ = $2; }
;
-
-opt_attributes
- : /* empty */
- | attribute_sections { $$ = $1; }
+
+opt_global_attributes
+ : /*empty */
+ | global_attributes
;
-attribute_sections
- : attribute_section
- {
- AttributeSection sect = (AttributeSection) $1;
+global_attributes
+ : OPT_LT global_attribute_list OP_GT
- if (sect.Target == "assembly")
- RootContext.AddGlobalAttributeSection (current_container, sect);
-
- $$ = new Attributes ((AttributeSection) $1, lexer.Location);
-
- }
- /*
- FIXME: we should check if extended syntax is enabled;
- otherwise an exception should be thrown since VB.NET
- only allows one attribute section
- */
- | attribute_sections attribute_section
- {
- Attributes attrs = null;
- AttributeSection sect = (AttributeSection) $2;
-
- if (sect.Target == "assembly")
- RootContext.AddGlobalAttributeSection (current_container, sect);
-
- if ($1 != null) {
- attrs = (Attributes) $1;
- attrs.AddAttributeSection (sect);
- }
-
- $$ = attrs;
- }
- ;
-
-attribute_section
- : OP_LT attribute_target_specifier attribute_list OP_GT
- {
- string target = null;
-
- if ($2 != null)
- target = (string) $2;
-
- $$ = new AttributeSection (target, (ArrayList) $3);
- }
- | OP_LT attribute_list OP_GT
- {
- $$ = new AttributeSection (null, (ArrayList) $2);
- }
- ;
-attribute_target_specifier
- : attribute_target COLON
- {
- $$ = $1;
- }
+global_attribute_list
+ : global_attribute
+ | global_attribute_list, global_attribute
;
-attribute_target
- : identifier
- {
- CheckAttributeTarget ((string) $1);
- $$ = $1;
- }
- | EVENT { $$ = "event"; }
- | RETURN { $$ = "return"; }
+global_attribute
+ : attribute_modifier COLON attribute
+
+attribute_modifier
+ : ASSEMBLY
+ | MODULE
+ | identifier
+ {
+ Report.Error (658, lexer.Location, "`" + (string)$1 + "' is an invalid attribute target");
+ }
;
-
+
+opt_attributes
+ : /* empty */
+ | attributes { $$ = $1; }
+ ;
+
+attributes
+ : OP_LT attribute_list OP_GT
+ {
+ AttributeSection sect = new AttributeSection (null, (ArrayList) $2);
+ $$ = new Attributes (sect, lexer.Location);
+ }
+ ;
+
attribute_list
- : attribute
- {
- ArrayList attrs = new ArrayList ();
- attrs.Add ($1);
+ : attribute
+ {
+ ArrayList attrs = new ArrayList ();
+ attrs.Add ($1);
- $$ = attrs;
+ $$ = attrs;
- }
- | attribute_list COMMA attribute
- {
- ArrayList attrs = (ArrayList) $1;
- attrs.Add ($3);
+ }
+ | attribute_list COMMA attribute
+ {
+ ArrayList attrs = (ArrayList) $1;
+ attrs.Add ($3);
+
+ $$ = attrs;
+ }
+ ;
- $$ = attrs;
- }
- ;
-
attribute
- : attribute_name
- {
- $$ = lexer.Location;
- }
- opt_attribute_arguments
- {
- $$ = new Mono.MonoBASIC.Attribute ((string) $1, (ArrayList) $3, (Location) $2);
- }
- ;
-
+ : attribute_name
+ {
+ $$ = lexer.Location;
+ }
+ opt_attribute_arguments
+ {
+ $$ = new Mono.MonoBASIC.Attribute ((string) $1, (ArrayList) $3, (Location) $2);
+ }
+ ;
+
attribute_name
: type_name
;
keywords.Add ("as", Token.AS);
keywords.Add ("assembly", Token.ASSEMBLY);
keywords.Add ("auto", Token.AUTO);
- keywords.Add ("binary", Token.BINARY);
+ keywords.Add ("binary", Token.BINARY); // Not a VB.NET Keyword
keywords.Add ("boolean", Token.BOOLEAN);
keywords.Add ("byref", Token.BYREF);
keywords.Add ("byte", Token.BYTE);
keywords.Add ("class", Token.CLASS);
keywords.Add ("clng", Token.CLNG);
keywords.Add ("cobj", Token.COBJ);
- keywords.Add ("compare", Token.COMPARE);
+ keywords.Add ("compare", Token.COMPARE); // Not a VB.NET Keyword
keywords.Add ("const", Token.CONST);
keywords.Add ("cshort", Token.CSHORT);
keywords.Add ("csng", Token.CSNG);
keywords.Add ("default", Token.DEFAULT);
keywords.Add ("delegate", Token.DELEGATE);
keywords.Add ("dim", Token.DIM);
+ keywords.Add ("directcast", Token.DIRECTCAST);
keywords.Add ("do", Token.DO);
keywords.Add ("double", Token.DOUBLE);
keywords.Add ("each", Token.EACH);
keywords.Add ("else", Token.ELSE);
keywords.Add ("elseif", Token.ELSEIF);
keywords.Add ("end", Token.END);
+ keywords.Add ("endif", Token.ENDIF); // An unused VB.NET keyword
keywords.Add ("enum", Token.ENUM);
keywords.Add ("erase", Token.ERASE);
keywords.Add ("error", Token.ERROR);
keywords.Add ("event", Token.EVENT);
keywords.Add ("exit", Token.EXIT);
- keywords.Add ("explicit", Token.EXPLICIT);
+ keywords.Add ("explicit", Token.EXPLICIT); // Not a VB.NET keyword
keywords.Add ("false", Token.FALSE);
keywords.Add ("finally", Token.FINALLY);
keywords.Add ("for", Token.FOR);
keywords.Add ("friend", Token.FRIEND);
keywords.Add ("function", Token.FUNCTION);
keywords.Add ("get", Token.GET);
- //keywords.Add ("gettype", Token.GETTYPE);
+ keywords.Add ("gettype", Token.GETTYPE);
+ keywords.Add ("gosub", Token.GOSUB); // An unused VB.NET keyword
keywords.Add ("goto", Token.GOTO);
keywords.Add ("handles", Token.HANDLES);
keywords.Add ("if", Token.IF);
keywords.Add ("integer", Token.INTEGER);
keywords.Add ("interface", Token.INTERFACE);
keywords.Add ("is", Token.IS);
- keywords.Add ("let ", Token.LET );
+ keywords.Add ("let ", Token.LET ); // An unused VB.NET keyword
keywords.Add ("lib ", Token.LIB );
keywords.Add ("like ", Token.LIKE );
keywords.Add ("long", Token.LONG);
keywords.Add ("notinheritable", Token.NOTINHERITABLE);
keywords.Add ("notoverridable", Token.NOTOVERRIDABLE);
keywords.Add ("object", Token.OBJECT);
- keywords.Add ("off", Token.OFF);
+ keywords.Add ("off", Token.OFF); // Not a VB.NET Keyword
keywords.Add ("on", Token.ON);
keywords.Add ("option", Token.OPTION);
keywords.Add ("optional", Token.OPTIONAL);
keywords.Add ("shared", Token.SHARED);
keywords.Add ("short", Token.SHORT);
keywords.Add ("single", Token.SINGLE);
- keywords.Add ("sizeof", Token.SIZEOF);
+ keywords.Add ("sizeof", Token.SIZEOF); // Not a VB.NET Keyword
keywords.Add ("static", Token.STATIC);
keywords.Add ("step", Token.STEP);
keywords.Add ("stop", Token.STOP);
- keywords.Add ("strict", Token.STRICT);
+ keywords.Add ("strict", Token.STRICT); // Not a VB.NET Keyword
keywords.Add ("string", Token.STRING);
keywords.Add ("structure", Token.STRUCTURE);
keywords.Add ("sub", Token.SUB);
keywords.Add ("synclock", Token.SYNCLOCK);
- keywords.Add ("text", Token.TEXT);
+ keywords.Add ("text", Token.TEXT); // Not a VB.NET Keyword
keywords.Add ("then", Token.THEN);
keywords.Add ("throw", Token.THROW);
keywords.Add ("to", Token.TO);
keywords.Add ("typeof", Token.TYPEOF);
keywords.Add ("unicode", Token.UNICODE);
keywords.Add ("until", Token.UNTIL);
- keywords.Add ("variant", Token.VARIANT);
+ keywords.Add ("variant", Token.VARIANT); // An unused VB.NET keyword
+ keywords.Add ("wend", Token.WEND); // An unused VB.NET keyword
keywords.Add ("when", Token.WHEN);
keywords.Add ("while", Token.WHILE);
keywords.Add ("with", Token.WITH);