From: Jambunathan K Date: Wed, 4 Aug 2004 09:32:03 +0000 (-0000) Subject: * mb-tokenizer.cs: X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=5437fa41defaaa672d36016401e114fbdcf3c1d8;p=mono.git * mb-tokenizer.cs: * mb-parser.jay: 1) Fixed the Attributes grammar starting with opt_attributes. Introduced new rules starting with opt_global_attributes rule - section 5.2 of VB.NET spec 2) Introduced new Tokens that correspond to reserved but unused VB.NET keywords. Added some comments as appropriate in the keywords hashtable of tokenizer - section 2.3 of VB.NET spec. svn path=/trunk/mcs/; revision=31851 --- diff --git a/mcs/mbas/ChangeLog b/mcs/mbas/ChangeLog index 665ddf56829..33427cb63e2 100644 --- a/mcs/mbas/ChangeLog +++ b/mcs/mbas/ChangeLog @@ -1,3 +1,16 @@ +2004-08-04 Jambunathan K + * mb-tokenizer.cs: + * mb-parser.jay: + + 1) Fixed the Attributes grammar starting with + opt_attributes. Introduced new rules starting with + opt_global_attributes rule - section 5.2 of VB.NET spec + + 2) Introduced new Tokens that correspond to reserved but unused + VB.NET keywords. Added some comments as appropriate in the + keywords hashtable of tokenizer - section 2.3 of VB.NET spec. + + 2004-08-04 Anirban Bhattacharjee * mb-parser.jay: Added support for modifiers and attributes in interface member grammar diff --git a/mcs/mbas/mb-parser.jay b/mcs/mbas/mb-parser.jay index 277866f7bb2..c4a104d1138 100644 --- a/mcs/mbas/mb-parser.jay +++ b/mcs/mbas/mb-parser.jay @@ -414,12 +414,14 @@ namespace Mono.MonoBASIC %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 @@ -433,7 +435,8 @@ namespace Mono.MonoBASIC %token FRIEND %token FUNCTION %token GET -//%token GETTYPE +%token GETTYPE +%token GOSUB %token GOTO %token HANDLES %token IF @@ -511,6 +514,7 @@ namespace Mono.MonoBASIC %token UNICODE %token UNTIL %token VARIANT +%token WEND %token WHEN %token WHILE %token WITH @@ -621,12 +625,13 @@ compilation_unit : logical_end_of_line opt_option_directives opt_imports_directives - opt_attributes + opt_global_attributes opt_declarations EOF { $$=$5; - } + } + ; opt_option_directives @@ -784,15 +789,15 @@ imports_directive 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); } @@ -803,107 +808,75 @@ opt_params | 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 ; diff --git a/mcs/mbas/mb-tokenizer.cs b/mcs/mbas/mb-tokenizer.cs index e37b732e1a8..4cfe33c3d50 100644 --- a/mcs/mbas/mb-tokenizer.cs +++ b/mcs/mbas/mb-tokenizer.cs @@ -145,7 +145,7 @@ namespace Mono.MonoBASIC 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); @@ -164,7 +164,7 @@ namespace Mono.MonoBASIC 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); @@ -176,25 +176,28 @@ namespace Mono.MonoBASIC 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); @@ -205,7 +208,7 @@ namespace Mono.MonoBASIC 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); @@ -225,7 +228,7 @@ namespace Mono.MonoBASIC 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); @@ -253,16 +256,16 @@ namespace Mono.MonoBASIC 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); @@ -271,7 +274,8 @@ namespace Mono.MonoBASIC 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);