//
// Mono.MonoBASIC.Parser.cs (from .jay): The Parser for the MonoBASIC compiler
//
-// Author: A Rafael D Teixeira (rafaelteixeirabr@hotmail.com)
-// Anirban Bhattacharjee (banirban@novell.com)
+// Authors: A Rafael D Teixeira (rafaelteixeirabr@hotmail.com)
+// Anirban Bhattacharjee (banirban@novell.com)
+// Jambunathan K (kjambunathan@novell.com)
//
// Licensed under the terms of the GNU GPL
//
-// Copyright (C) 2001 A Rafael D Teixeira
+// Copyright (C) 2001, 2002, 2003, 2004 A Rafael D Teixeira
+// Copyright (C) 2003, 2004 Novell
//
//
{
+
/// <summary>
/// Current block is used to add statements as we find
/// them.
} else
break;
- if ((mod_flags & (Modifiers.PRIVATE|Modifiers.PROTECTED)) != 0){
+ if ((mod_flags & (Modifiers.PRIVATE)) != 0){
+ Report.Error (
+ 31089, lexer.Location,
+ "Namespace elements cannot be explicitly " +
+ "declared private in '" + name + "'");
+ }
+ else if ((mod_flags & (Modifiers.PROTECTED)) != 0){
Report.Error (
- 1527, lexer.Location,
+ 31047, lexer.Location,
"Namespace elements cannot be explicitly " +
- "declared private or protected in '" + name + "'");
+ "declared protected in '" + name + "'");
}
}
;
if (expecting_local_attribs) {
local_attrib_section_added = true;
allow_global_attribs = false;
- }
+
+ $$ = new Attributes ((ArrayList) $1);
+ }
+
+ if (expecting_global_attribs) {
+ $$ = null;
+ CodeGen.AddGlobalAttributes ((ArrayList) $1);
+ }
expecting_local_attribs = false;
expecting_global_attribs = false;
}
attribute_section
{
- $$ = null;
+ $$ = $1;
if ($3 != null) {
+ ArrayList attrs = (ArrayList) $3;
if (expecting_local_attribs) {
if (local_attrib_section_added) {
break;
}
+ if ($1 == null)
+ $$ = new Attributes (attrs);
+ else
+ ((Attributes) $1).Add (attrs);
+
local_attrib_section_added = true;
allow_global_attribs = false;
}
+
+ if (expecting_global_attribs) {
+ $$ = null;
+ CodeGen.AddGlobalAttributes ((ArrayList) $3);
+ }
}
expecting_local_attribs = false;
expecting_global_attribs = false;
-
- $$ = $1;
-
}
;
}
}
- AttributeSection sect = new AttributeSection (null, (ArrayList) $2);
- $$ = new Attributes (sect, lexer.Location);
+ $$ = $2;
}
}
;
attrs.Add ($3);
}
- $$ = $1;
+ $$ = attrs;
}
;
Report.Error (32015, (Location) $2, "Expecting Assembly or Module attribute specifiers");
else {
expecting_local_attribs = true;
- $$ = new Mono.MonoBASIC.Attribute ((string) $1, (ArrayList) $3, (Location) $2);
+ $$ = new Attribute ((string) $1, (ArrayList) $3, (Location) $2);
}
}
| attribute_target_specifier
}
expecting_global_attribs = true;
- $$ = new Mono.MonoBASIC.Attribute ((string) $4, (ArrayList) $6, (Location) $5);
+ $$ = new Attribute (attribute_target, (string) $4, (ArrayList) $6, (Location) $5);
}
;
;
class_declaration
- : CLASS identifier logical_end_of_line opt_inherits opt_implements
+ : CLASS identifier end_of_stmt opt_inherits opt_implements
{
// Module members are static by default, but Class *can't* be declared static
// so we must fix it, if mbas was the one actually responsible for this
opt_inherits
: /* empty */ { $$ = null; }
- | INHERITS type_list logical_end_of_line { $$ = $2; }
+ | INHERITS type_list end_of_stmt { $$ = $2; }
;
opt_implements
: /* empty */ { $$ = null; }
- | IMPLEMENTS type_list logical_end_of_line { $$ = $2; }
+ | IMPLEMENTS type_list end_of_stmt { $$ = $2; }
;
opt_modifiers
;
constant_declaration
- : CONST constant_declarators logical_end_of_line
+ : CONST constant_declarators end_of_stmt
{
// Module members are static by default, but constants *can't* be declared static
// so we must fix it, if mbas was the one actually responsible for this
evt_target + " is not declared with WithEvents");
}
} else if (handles_exp is BaseAccess) {
- string evt_id = ((BaseAccess) $4).member;
Statement addhnd = (Statement) new AddHandler ((Expression) $4,
DecomposeQI((string) $2, loc),
loc);
;
struct_declaration
- : STRUCTURE identifier logical_end_of_line
+ : STRUCTURE identifier end_of_stmt
opt_implement_clause
{
Struct new_struct;
VariableDeclaration var = new VariableDeclaration ((string) $2, (Expression) $4, lexer.Location);
Event e = new Event ((Expression) $4, var.identifier,
- null, current_modifiers, null, null,
+ null, current_modifiers,
current_attributes, (ArrayList) $5,
lexer.Location);
Event e = new Event (DecomposeQI (delName, lexer.Location),
(string) $2,
- null, current_modifiers, null, null,
+ null, current_modifiers,
current_attributes, (ArrayList) $4,
lexer.Location);
VariableDeclaration var = new VariableDeclaration ((string) $2, (Expression) $4, lexer.Location);
Event e = new Event ((Expression) $4, var.identifier,
- null, current_modifiers, null, null,
+ null, current_modifiers,
current_attributes, lexer.Location);
CheckDef (current_interface.AddEvent (e), e.Name, e.Location);
Event e = new Event (DecomposeQI (delName, lexer.Location),
(string) $2,
- null, current_modifiers, null, null,
+ null, current_modifiers,
current_attributes, lexer.Location);
CheckDef (current_interface.AddEvent (e), e.Name, e.Location);
non_abstract_propery_declaration
: PROPERTY identifier opt_type_character opt_property_parameters opt_type_with_ranks opt_implement_clause logical_end_of_line
{
+ if ((current_modifiers & Modifiers.DEFAULT) > 0) {
+ if (current_container.DefaultPropName != null
+ && current_container.DefaultPropName != (string) $2)
+ Report.Error (30359,
+ lexer.Location,
+ "Type '" + current_container.Name +
+ "' cannot have more than one 'Default Property' ");
+
+ current_container.DefaultPropName = (string) $2;
+ }
+
get_implicit_value_parameter_type =
($5 == null) ? (($3 == null) ?
TypeManager.system_object_expr : (Expression) $3 ) : (Expression) $5;
set_implicit_value_parameter_type = (Expression) $4;
- if (set_implicit_value_parameter_type != get_implicit_value_parameter_type)
+ if (set_implicit_value_parameter_type.ToString () != get_implicit_value_parameter_type.ToString ())
Report.Error (31064,
lexer.Location,
"Set value parameter type can not be different from property type");
-
+
if ($2 != null)
set_implicit_value_parameter_name = (string) $3;
else
field_declaration
: opt_dim_stmt
- variable_declarators logical_end_of_line
+ variable_declarators end_of_stmt
{
int mod = (int) current_modifiers;
}
| embedded_statement
{
- Statement s = (Statement) $1;
-
current_block.AddStatement ((Statement) $1);
}
| labeled_statement
/* | empty_statement */
| with_statement
{
- Statement s = (Statement) $1;
-
current_block.AddStatement ((Statement) $1);
}
;
pre_embedded_statement
: embedded_statement
{
- Statement s = (Statement) $1;
-
current_block.AddStatement ((Statement) $1);
}
;
tmp_blocks.Push(bl);
start_block();
- Statement s = (Statement) $2;
current_block.AddStatement ((Statement) $2);
}
;
string varname = (string) vname.Name;
current_rank_specifiers = (ArrayList) vname.Rank;
object varinit = $3;
- ArrayList a_dims = null;
if (varinit == null)
Report.Error (
}
| prefixed_unary_expression OP_EXP ASSIGN expression
{
- Location l = lexer.Location;
+ /*Location l = lexer.Location;
- /* TODO: $$ = new CompoundAssign (
+ TODO: $$ = new CompoundAssign (
Binary.Operator.ExclusiveOr, (Expression) $1, (Expression) $4, l); */
}
| prefixed_unary_expression ASSIGN ADDRESSOF expression
{
if(tokenizerController.IsAcceptingTokens)
{
- string id = ($2 as string);
-
if(!($2 as string).ToLower().Equals("region"))
Report.Error (30205, lexer.Location, "Invalid Pre-processor directive");
else
public static void FixupArrayTypes (ArrayList vars)
{
- int varcount = vars.Count;
string dims;
foreach (VariableDeclaration var in vars) {
private void AddHandler (Block b, Expression evt_id, Expression handles_exp)
{
- Expression evt_target;
Location loc = lexer.Location;
Statement addhnd = (Statement) new AddHandler (evt_id,
handles_exp,
loc);
-
b.AddStatement (addhnd);
}
private void RemoveHandler (Block b, Expression evt_definition, Expression handler_exp)
{
- Expression evt_target;
Location loc = lexer.Location;
Statement rmhnd = (Statement) new RemoveHandler (evt_definition,
with_stack = new Stack();
statement_stack = new Stack();
+ allow_global_attribs = true;
+ expecting_global_attribs = false;
+ expecting_local_attribs = false;
+ local_attrib_section_added = false;
+
UseExtendedSyntax = name.EndsWith(".mbs");
OptionExplicit = InitialOptionExplicit || UseExtendedSyntax;
OptionStrict = InitialOptionStrict || UseExtendedSyntax;
ifElseStateMachine = new IfElseStateMachine();
tokenizerController = new TokenizerController(lexer);
- StringBuilder value = new StringBuilder ();
try {
- if (yacc_verbose_flag)
+ if (yacc_verbose_flag > 0)
yyparse (lexer, new yydebug.yyDebugSimple ());
else {
yyparse (lexer);