// An out-of-band stack.
//
Stack oob_stack;
-
+
ArrayList current_rank_specifiers;
//To handle the End of a block
- // We use grammer, priority, strings, and an integer called Parenta
- //
- // FIX ME: Need to implement some better method than this and in
- // some cases parser will come out without proceding further
- // if it comes acorss error.
-
- public string[] end_blocks = {"Nothing", "Next", "Loop", "End If", "End Sub", "End Module", "End Namespace", "End Class", "End Function", "End Structure", "End Enum", "End Interface", "End Property", "End With", "End Synclock", "End Try", "End While", "End Select", "End Set", "End Get"};
-
- public string[] open_blocks = {"Block", "For", "Do", "If", "Sub", "Module", "Namespace", "Class", "Function", "Structure", "Enum", "Interface", "Property", "With", "Synclock", "Try", "While", "Select", "Set", "Get","\nCompilation failed"};
+ // We use grammer, priority, strings, and an integer called Parenta
+ //
+ // FIX ME: Need to implement some better method than this and in
+ // some cases parser will come out without proceeding further
+ // if it comes acorss error.
+
+ // Used to store
+ // 1) The value for corresponding blocks with which it will be accessed...
+ // In case of any more addition to end of blocks... add it at the end
+
+ public enum Start_block {
+ NOTHING,
+ FOR,
+ DO,
+ IF,
+ SUB,
+ MODULE,
+ NAMESPACE,
+ CLASS,
+ FUNCTION,
+ STRUCTURE,
+ ENUM,
+ INTERFACE,
+ PROPERTY,
+ WITH,
+ SYNCLOCK,
+ TRY,
+ WHILE,
+ SELECT,
+ SET,
+ GET
+ }
- public int[] error_numbers = {29999, 30092, 30091, 30087, 30429, 30622, 30623, 30460, 30430, 30621, 30184, 30252, 30431, 30093, 30674, 30383, 30090, 30088, 30632, 30630, 29999};
+ // Used to store
+ // 1) Start of block
+ // 2) End of Block
+ // In case of any more addition to end of blocks... add it at the end
+
+ public string[,] end_blocks = {
+ { "empty" , "empty" },
+ { "For" , "Next" },
+ { "Do" , "Loop" },
+ { "If" , "End If" },
+ { "Sub" , "End Sub" },
+ { "Module" , "End Module" },
+ { "NameSpace" , "End NameSpace" },
+ { "Class" , "End Class" },
+ { "Function" , "End Function" },
+ { "Structure" , "End Structure" },
+ { "Enum" , "End Enum" },
+ { "Interface" , "End Interface" },
+ { "Property" , "End Property" },
+ { "With" , "End With" },
+ { "SyncLock" , "End SyncLock" },
+ { "Try" , "End Try" },
+ { "While" , "End While" },
+ { "Select" , "End Select" },
+ { "Set" , "End Set" },
+ { "Get" , "End Get" }
+ };
+
+
+ // Used to store
+ // 1) Error number for End of block missing
+ // 2) Extra End of Block
+ // 3) Priority for the end 0f blocks
+ // In case of any more addition to end of blocks... add it at the end
+
+ public int[,] error_end_blocks = {
+ { 29999 , 29999 , 0 },
+ { 30084 , 30092 , 1 },
+ { 30083 , 30091 , 1 },
+ { 30081 , 30087 , 1 },
+ { 30289 , 30429 , 3 },
+ { 30625 , 30622 , 5 },
+ { 30626 , 30623 , 6 },
+ { 30481 , 30460 , 4 },
+ { 30027 , 30430 , 3 },
+ { 30624 , 30621 , 4 },
+ { 30185 , 30184 , 1 },
+ { 30253 , 30252 , 3 },
+ { 30025 , 30431 , 3 },
+ { 30085 , 30093 , 1 },
+ { 30675 , 30674 , 1 },
+ { 30384 , 30383 , 1 },
+ { 30082 , 30090 , 1 },
+ { 30095 , 30088 , 1 },
+ { 30633 , 30632 , 2 },
+ { 30631 , 30630 , 2 }
+ };
+
+ Stack end_of_block;
+ Stack temp_block;
+ Stack loc_end_of_block;
+ Stack loc_temp_block;
- public int[] end_priority = {0,1,1,1,2,3,4,3,2,3,1,2,2,1,1,1,1,1,1,1,1};
-
- int Parent = 0;
Location try_top;
DoOptions do_type;
// A stack for With expressions.
//
Stack with_stack;
-
+
+ //
+ // Hash table for const preprocessing directive
+ //
+ public static Hashtable constPreDir = new Hashtable();
static public bool InitialOptionExplicit = false;
static public bool InitialOptionStrict = false;
%token ELSE
%token ELSEIF
%token END
+%token END_EOL
%token ENDIF
%token ENUM
%token EOL
;
opt_params
- : /* empty */ { $$ = Parameters.EmptyReadOnlyParameters; }
- | OPEN_PARENS CLOSE_PARENS { $$ = Parameters.EmptyReadOnlyParameters; }
- | OPEN_PARENS _mark_ opt_formal_parameter_list CLOSE_PARENS { $$ = $3; }
- | OPEN_PARENS _mark_
- {
- Report.Error(30203,(Location)$2, "Identifier Expected");
- $$ = Parameters.EmptyReadOnlyParameters;
- }
- | OPEN_PARENS _mark_ opt_formal_parameter_list
- {
- Report.Error(30198,(Location)$2, "'(' is not having a matching ')'");
- $$ = $3;
- }
- | _mark_ opt_formal_parameter_list CLOSE_PARENS
- {
- Report.Error(30205,(Location)$1, "')' is not having a matching '('");
- $$ = $2;
- }
- ;
+ : /* empty */ { $$ = Parameters.EmptyReadOnlyParameters; }
+ | OPEN_PARENS CLOSE_PARENS { $$ = Parameters.EmptyReadOnlyParameters; }
+ | OPEN_PARENS _mark_ opt_formal_parameter_list CLOSE_PARENS { $$ = $3; }
+ | OPEN_PARENS _mark_
+ {
+ Report.Error(30203,(Location)$2, "Identifier Expected");
+ $$ = Parameters.EmptyReadOnlyParameters;
+ }
+ | OPEN_PARENS _mark_ opt_formal_parameter_list error
+ {
+ Report.Error(30198,(Location)$2, "'(' is not having a matching ')'");
+ $$ = $3;
+ }
+ | error _mark_ opt_formal_parameter_list CLOSE_PARENS
+ {
+ Report.Error(30205,(Location)$2, "')' is not having a matching '('");
+ $$ = $3;
+ }
+ ;
opt_attributes
: /* empty */
;
attribute_section
- : OP_LT attribute_list OP_GT opt_end_of_stmt
+ : OP_LT _mark_ attribute_list OP_GT opt_end_of_stmt
{
$$ = null;
- if ($2 != null) {
- if (expecting_global_attribs && !(bool) $4) {
- Report.Error (30205, lexer.Location, "End of statement expected");
+ if ($3 != null) {
+ if (expecting_global_attribs && !(bool) $5) {
+ Report.Error (30205, (Location)$2, "End of statement expected");
break;
}
if (expecting_local_attribs) {
- if ((bool) $4) {
- Report.Error (32035, lexer.Location, "Use a line continuation after the attribute specifier to apply it to the following statement.");
+ if ((bool) $5) {
+ Report.Error (32035, (Location)$2, "Use a line continuation after the attribute specifier to apply it to the following statement.");
break;
}
}
- $$ = $2;
+ $$ = $3;
}
}
;
namespace_declaration
: NAMESPACE _mark_ qualified_identifier logical_end_of_line
{
+ push_into_stack((int)Start_block.NAMESPACE, (Location)$2);
current_namespace = RootContext.Tree.RecordNamespace(current_namespace, name, (string)$3);
}
opt_declarations
opt_end_block
{
- int i = (int)$7;
- if (end_priority[6]>=end_priority[i] && i!=6)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=6 && Parent!=6)
- {
- Report.Error(30626,(Location)$2,"'NameSpace' is not having a matching 'End NameSpace'");
- Parent=i;
- }
- if(i!=6)
- Parent=i;
- if(Parent==6)
- Parent=0;
+ pop_out_of_stack((int)$7, lexer.Location);
}
logical_end_of_line
{
// 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
// instead of triggering an error.
+ push_into_stack((int)Start_block.CLASS, (Location)$3);
+
if (implicit_modifiers && ((current_modifiers & Modifiers.STATIC) != 0))
current_modifiers = (current_modifiers & ~Modifiers.STATIC);
opt_class_member_declarations
opt_end_block
{
- int i = (int)$9;
- if (end_priority[7]>=end_priority[i] && i!=7)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=7 && Parent!=7)
- {
- Report.Error(30481,(Location)$3,"'Class' is not having a matching 'End Class'");
- Parent=i;
- }
- if(i!=7)
- Parent=i;
- if(Parent==7)
- Parent=0;
+ pop_out_of_stack((int)$9, lexer.Location);
}
logical_end_of_line
{
module_declaration
: MODULE _mark_ identifier logical_end_of_line
{
+ push_into_stack((int)Start_block.MODULE, (Location)$2);
Module new_module;
string name;
name = MakeName((string) $3);
opt_module_member_declarations
opt_end_block
{
- int i = (int)$7;
- if (end_priority[5]>=end_priority[i] && i!=5)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=5 && Parent!=5)
- {
- Report.Error(30625,(Location)$2,"'Module' is not having a matching 'End Module'");
- Parent=i;
- }
- if(i!=5)
- Parent=i;
- if(Parent==5)
- Parent=0;
+ pop_out_of_stack((int)$7, lexer.Location);
}
logical_end_of_line
{
sub_declaration
: SUB identifier _mark_ opt_params opt_evt_handler opt_implement_clause logical_end_of_line
{
+ push_into_stack((int)Start_block.SUB, (Location)$3);
current_local_parameters = (Parameters) $4;
start_block();
opt_statement_list
opt_end_block
{
- int i = (int)$10;
- if (end_priority[4]>=end_priority[i] && i!=4)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=4 && Parent!=4)
- {
- Report.Error(30289,(Location)$3,"'Sub' is not having a matching 'End Sub'");
- Parent=i;
- }
- if(i!=4)
- Parent=i;
- if(Parent==4)
- Parent=0;
+ pop_out_of_stack((int)$10, lexer.Location);
}
logical_end_of_line
{
: FUNCTION identifier opt_type_character
opt_params _mark_ opt_type_with_ranks opt_implement_clause logical_end_of_line
{
+ push_into_stack((int)Start_block.FUNCTION, (Location)$5);
current_local_parameters = (Parameters) $4;
start_block();
opt_statement_list
opt_end_block
{
- int i = (int)$11;
- if (end_priority[8]>=end_priority[i] && i!=8)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=8 && Parent!=8)
- {
- Report.Error(30027,(Location)$5,"'Function' is not having a matching 'End Function'");
- Parent=i;
- }
- if(i!=8)
- Parent=i;
- if(Parent==8)
- Parent=0;
+ pop_out_of_stack((int)$11, lexer.Location);
}
logical_end_of_line
{
: STRUCTURE _mark_ identifier end_of_stmt
opt_implement_clause
{
+ push_into_stack((int)Start_block.STRUCTURE, (Location)$2);
Struct new_struct;
string full_struct_name = MakeName ((string) $3);
}
opt_end_block
{
- int i = (int)$9;
- if (end_priority[9]>=end_priority[i] && i!=9)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=9 && Parent!=9)
- {
-
- Report.Error(30624,(Location)$2,"'Structure' is not having a matching 'End Structure'");
- Parent=i;
- }
- if(i!=9)
- Parent=i;
- if(Parent==9)
- Parent=0;
+ pop_out_of_stack((int)$9, lexer.Location);
}
logical_end_of_line
;
: ENUM _mark_ identifier opt_type_spec logical_end_of_line
opt_enum_member_declarations
{
+ push_into_stack((int)Start_block.ENUM, (Location)$2);
Location enum_location = (Location)$2;
string full_name = MakeName ((string) $3);
Expression enum_type = ($4 == null) ? TypeManager.system_int32_expr : (Expression) $4;
}
opt_end_block
{
- int i = (int)$8;
- if (end_priority[10]>=end_priority[i] && i!=10)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=10 && Parent!=10)
- {
- Report.Error(30185,(Location)$2,"'ENUM' is not having a matching 'End ENUM'");
- Parent=i;
- }
- if(i!=10)
- Parent=i;
- if(Parent==10)
- Parent=0;
- }
+ pop_out_of_stack((int)$8,lexer.Location);
+ }
logical_end_of_line
;
interface_declaration
: INTERFACE _mark_ identifier logical_end_of_line
{
+ push_into_stack((int)Start_block.INTERFACE, (Location)$2);
Interface new_interface;
string full_interface_name = MakeName ((string) $3);
}
opt_end_block
{
- int i = (int)$9;
- if (end_priority[11]>=end_priority[i] && i!=11)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=11 && Parent!=11)
- {
- Report.Error(30253,(Location)$2,"'INTERFACE' is not having a matching 'End INTERFACE'");
- Parent=i;
- }
- if(i!=11)
- Parent=i;
- if(Parent==11)
- Parent=0;
+ pop_out_of_stack((int)$9, lexer.Location);
}
logical_end_of_line
;
opt_type_with_ranks
opt_implement_clause
{
+ push_into_stack((int)Start_block.PROPERTY, (Location)$5);
if ((current_modifiers & Modifiers.DEFAULT) > 0) {
if (current_container.DefaultPropName != null
&& current_container.DefaultPropName != (string) $2)
accessor_declarations
opt_end_block
{
- int i = (int)$11;
- if (end_priority[12]>=end_priority[i] && i!=12)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=12 && Parent!=12)
- {
- Report.Error(30025,(Location)$5,"'Property' is not having a matching 'End Property'");
- Parent=i;
- }
- if(i!=12)
- Parent=i;
- if(Parent==12)
- Parent=0;
+ pop_out_of_stack((int)$11,lexer.Location);
}
logical_end_of_line
{
get_accessor_declaration
: opt_attributes GET _mark_ logical_end_of_line
{
+ push_into_stack((int)Start_block.GET, (Location)$3);
if ((current_modifiers & Modifiers.WRITEONLY) != 0)
Report.Error (30023, (Location)$3, "'WriteOnly' properties cannot have a 'Get' accessor");
opt_statement_list
opt_end_block
{
- int i = (int)$7;
- if (end_priority[19]>=end_priority[i] && i!=19)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=19 && Parent!=19)
- {
- Report.Error(30631,(Location)$3,"'GET' is not having a matching 'End Get'");
- Parent=i;
- }
- if(i!=19)
- Parent=i;
- if(Parent==19)
- Parent=0;
+ pop_out_of_stack((int)$7,lexer.Location);
}
logical_end_of_line
{
set_accessor_declaration
: opt_attributes SET opt_set_parameter _mark_ logical_end_of_line
{
- if ((current_modifiers & Modifiers.READONLY) != 0)
+ push_into_stack((int)Start_block.SET, (Location)$4);
+ if ((current_modifiers & Modifiers.READONLY) != 0)
Report.Error (30022,
(Location)$4,
"'ReadOnly' properties cannot have a 'Set' accessor");
opt_statement_list
opt_end_block
{
- int i = (int)$8;
- if (end_priority[18]>=end_priority[i] && i!=18)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=18 && Parent!=18)
- {
- Report.Error(30633,(Location)$4,"'SET' is not having a matching 'End Set'");
- Parent=i;
- }
- if(i!=18)
- Parent=i;
- if(Parent==18)
- Parent=0;
+ pop_out_of_stack((int)$8,lexer.Location);
}
logical_end_of_line
;
evt_handler
- : qualified_identifier
+ : qualified_identifier _mark_
{
- $$ = (Expression) DecomposeQI ((string)$1, lexer.Location);
+ $$ = (Expression) DecomposeQI ((string)$1, (Location)$2);
}
| base_access
{
$$ = $1;
}
- | ME DOT qualified_identifier
+ | ME DOT qualified_identifier _mark_
{
- $$ = (Expression) DecomposeQI ((string)$3, lexer.Location);
+ $$ = (Expression) DecomposeQI ((string)$3, (Location)$4);
}
/*| MYBASE DOT qualified_identifier
{
constructor_declaration
: SUB _mark_ NEW opt_params logical_end_of_line
{
+ push_into_stack((int)Start_block.SUB, (Location)$2);
current_local_parameters = (Parameters) $4;
start_block();
- oob_stack.Push (lexer.Location);
-
- Location l = (Location) oob_stack.Pop ();
- $$ = new Constructor ((string) "New", (Parameters) $4, (ConstructorInitializer) null, l);
+ $$ = new Constructor ((string) "New", (Parameters) $4, (ConstructorInitializer) null, (Location)$2);
$1 = $$;
}
opt_statement_list
{
Constructor c = (Constructor) $1;
c.Block = (Block) end_block();
+
+//To support "Sub New()" add default modifier "public"
+
+ if(current_modifiers ==0)
+ current_modifiers = Modifiers.PUBLIC;
c.ModFlags = (int) current_modifiers;
c.OptAttributes = current_attributes;
}
opt_end_block
{
- int i = (int)$9;
- if (end_priority[4]>=end_priority[i] && i!=4)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=4 && Parent!=4)
- {
- Report.Error(30289,(Location)$2,"'Sub' is not having a matching 'End Sub'");
- Parent=i;
- }
- if(i!=4)
- Parent=i;
- if(Parent==4)
- Parent=0;
+ pop_out_of_stack((int)$9, lexer.Location);
}
logical_end_of_line
;
statement_list
: statement
- | statement_list end_of_stmt
+ | statement_list end_of_stmt
statement
;
-
+
statement
: declaration_statement
{
}
;
+opt_end_stmt
+ : END_EOL {$$ = new End (lexer.Location);}
+ ;
+
+
opt_raise_event_args
: /* empty */ { $$ = null; }
| OPEN_PARENS opt_argument_list CLOSE_PARENS
: WITH _mark_ expression end_of_stmt /* was : WITH qualified_identifier end_of_stmt */
{
// was : Expression e = DecomposeQI ((string) $3, (Location)$2);
+ push_into_stack((int)Start_block.WITH, (Location)$2);
Expression e = (Expression) $3;
with_stack.Push(e);
start_block();
opt_statement_list
opt_end_block
{
- int i = (int)$7;
- if (end_priority[13]>=end_priority[i] && i!=13)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=13 && Parent!=13)
- {
- Report.Error(30085,(Location)$2,"'With' is not having a matching 'End With'");
- Parent=i;
- }
- if(i!=13)
- Parent=i;
- if(Parent==13)
- Parent=0;
+ pop_out_of_stack((int)$7,lexer.Location);
Block b = end_block();
with_stack.Pop();
$$ = b;
| throw_statement
| exit_statement
| yield_statement
+ | opt_end_stmt
;
goto_statement
;
throw_statement
- : THROW opt_expression
+ : THROW _mark_ opt_expression
{
- $$ = new Throw ((Expression) $2, lexer.Location);
+ $$ = new Throw ((Expression) $3, (Location)$2);
}
;
expression end_of_stmt
{
Location l = (Location)$4;
+ push_into_stack((int)Start_block.FOR, l);
LocalVariableReference v = null;
VariableInfo vi;
opt_statement_list
opt_end_block
{
- int i = (int)$11;
- if (end_priority[1]>=end_priority[i] && i!=1)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=1 && Parent!=1)
- {
- Report.Error(30084,(Location)$4,"'For' is not having a matching 'Next'");
- Parent=i;
- }
- if(i!=1)
- Parent=i;
- if(Parent==1)
- Parent=0;
+ pop_out_of_stack((int)$11,lexer.Location);
}
- opt_identifier
- {
+ _mark_ opt_identifier
+ {
+ string s = $3.ToString();
+ string s1 = "";
+ if ($14 != null)
+ s1 = $14.ToString();
+ if (s1 != "" && s != s1)
+ {
+ Report.Error(30070, (Location)$13, "Next Control Variable '"+s1+"' does not match with For Loop control variable '"+s+"'");
+ }
LocalVariableReference v = (LocalVariableReference) oob_stack.Pop ();
Block foreach_block = end_block();
synclock_statement
: SYNCLOCK _mark_ expression end_of_stmt
{
+ push_into_stack((int)Start_block.SYNCLOCK, (Location)$2);
start_block();
}
opt_statement_list
opt_end_block
{
- int i = (int)$7;
- if (end_priority[14]>=end_priority[i] && i!=14)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=14 && Parent!=14)
- {
- Report.Error(30675,(Location)$2,"'Synclock' is not having a matching 'End SyncLock'");
- Parent=i;
- }
- if(i!=14)
- Parent=i;
- if(Parent==14)
- Parent=0;
+ pop_out_of_stack((int)$7,lexer.Location);
$$ = new Lock ((Expression) $3, (Statement) (Block) end_block(), (Location)$2);
}
;
try_header
: TRY _mark_ end_of_stmt
{
+ push_into_stack((int)Start_block.TRY, (Location)$2);
try_top=(Location)$2;
start_block();
}
: try_header
_mark_ opt_end_block
{
- int i = (int)$3;
- if (end_priority[15]>=end_priority[i] && i!=15)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=15 && Parent!=15)
- {
- Report.Error(30384,try_top,"'Try' is not having a matching 'End Try'");
- Parent=i;
- }
- if(i!=15)
- Parent=i;
- if(Parent==15)
- Parent=0;
+ pop_out_of_stack((int)$3,lexer.Location);
Catch g = null;
ArrayList s = new ArrayList ();
opt_statement_list
_mark_ opt_end_block
{
- int i = (int)$8;
- if (end_priority[15]>=end_priority[i] && i!=15)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=15 && Parent!=15)
- {
- Report.Error(30384,try_top,"'Try' is not having a matching 'End Try'");
- Parent=i;
- }
- if(i!=15)
- Parent=i;
- if(Parent==15)
- Parent=0;
-
+ pop_out_of_stack((int)$8,lexer.Location);
Catch g = null;
ArrayList s = new ArrayList ();
ArrayList catch_list = (ArrayList) tmp_catch_clauses;
{
$$ = new DictionaryEntry ($4, $1);
}
- | _mark_ AS type
+ | error _mark_ AS type
{
- Report.Error(30203, (Location)$1, "Identifier Expected");
+ Report.Error(30203, (Location)$2, "Identifier Expected");
$$ = null;
}
- | identifier AS _mark_
+ | identifier AS _mark_ error
{
Report.Error(30182, (Location)$3, "Type Expected");
$$ = null;
do_statement
: DO _mark_ opt_do_construct end_of_stmt
{
+ push_into_stack((int)Start_block.DO, (Location)$2);
start_block();
}
opt_statement_list
opt_end_block
{
- int i = (int)$7;
- if (end_priority[2]>=end_priority[i] && i!=2)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=2 && Parent!=2)
- {
- Report.Error(30083,(Location)$2,"'Do' is not having a matching 'Loop'");
- Parent=i;
- }
- if(i!=2)
- Parent=i;
- if(Parent==2)
- Parent=0;
+ pop_out_of_stack((int)$7,lexer.Location);
}
_mark_ opt_do_construct
{
while_statement
: WHILE
{
+ push_into_stack((int)Start_block.WHILE, lexer.Location);
start_block();
oob_stack.Push (lexer.Location);
}
opt_end_block
{
Location l = (Location) oob_stack.Pop ();
- int i = (int)$6;
- if (end_priority[16]>=end_priority[i] && i!=16)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=16 && Parent!=16)
- {
- Report.Error(30082,l,"'While' is not having a matching 'End While'");
- Parent=i;
- }
- if(i!=16)
- Parent=i;
- if(Parent==16)
- Parent=0;
+ pop_out_of_stack((int)$6,lexer.Location);
Block b = end_block();
Expression e = (Expression) $3;
$$ = new While ((Expression) e, (Statement) b, l);
for_statement
: FOR _mark_ identifier opt_type_spec ASSIGN expression TO expression opt_step end_of_stmt
{
+ push_into_stack((int)Start_block.FOR, (Location)$2);
if ($4 != null)
{
start_block();
opt_statement_list
opt_end_block
{
- int i = (int)$13;
- if (end_priority[1]>=end_priority[i] && i!=1)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=1 && Parent!=1)
- {
- Report.Error(30084,(Location)$2,"'For' is not having a matching 'Next'");
- Parent=i;
- }
- if(i!=1)
- Parent=i;
- if(Parent==1)
- Parent=0;
+ pop_out_of_stack((int)$13,lexer.Location);
}
- opt_identifier
- {
- Block inner_statement = end_block();
- Location l = (Location)$2;
- Expression for_var = (Expression) DecomposeQI ((string)$3, l);
-
- Expression assign_expr = new Assign (for_var, (Expression) $6, l);
- Expression test_expr = new Binary (Binary.Operator.LessThanOrEqual,
- for_var, (Expression) $8, l);
- Expression step_expr = new Assign (for_var, (Expression) new Binary (Binary.Operator.Addition,
- for_var, (Expression) $9, l), l);
-
- Statement assign_stmt = new StatementExpression ((ExpressionStatement) assign_expr, l);
- Statement step_stmt = new StatementExpression ((ExpressionStatement) step_expr, l);
+ _mark_ opt_identifier
+ {
+ string s = $3.ToString();
+ string s1 = "";
+ if ($16 != null)
+ s1 = $16.ToString();
+ if (s1 != "" && s != s1) {
+ Report.Error(30070, (Location)$15, "Next Control Variable '"+s1+"' does not match with For Loop control variable '"+s+"'");
+ }
- For f = new For (assign_stmt, test_expr, step_stmt, inner_statement, l);
- if ($4 != null)
- {
- current_block.AddStatement (f);
- $$ = end_block();
- }
- else
- $$ = f;
- }
+ Block inner_statement = end_block();
+ Location l = (Location)$2;
+ Expression for_var = (Expression) DecomposeQI ((string)$3, l);
+
+ For f = new For (for_var, (Expression) $6, (Expression) $8, (Expression) $9, inner_statement, l);
+ if ($4 != null)
+ {
+ current_block.AddStatement (f);
+ $$ = end_block();
+ }
+ else
+ $$ = f;
+ }
;
opt_step
;
if_statement
- : if_statement_open opt_then end_of_stmt opt_statement_list if_statement_rest
- {
- $$ = $5;
- }
+ : if_statement_open opt_then end_of_stmt opt_statement_list
+ {
+ push_into_stack((int)Start_block.IF, (Location)$1);
+ }
+ if_statement_rest
+ {
+ $$ = $6;
+ }
| if_statement_open THEN pre_embedded_statement opt_else_pre_embedded_statement
{
if ($4 == null)
/*FIXME:if without end if not working. Error line shown is nor correct*/
if_statement_open
- : IF
+ : IF _mark_
{
oob_stack.Push (lexer.Location);
}
boolean_expression
{
start_block();
- tmp_expr = (Expression) $3;
+ tmp_expr = (Expression) $4;
expr_stack.Push(tmp_expr);
+ $$ = (Location)$2;
}
;
opt_end_block
{
Location l = (Location) oob_stack.Pop ();
- int i = (int)$1;
- if (end_priority[3]>=end_priority[i] && i!=3)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=3 && Parent!=3)
- {
- Report.Error(30081,l,"'If' is not having a matching 'EndIf'");
- Parent = i;
- }
- if(i!=3)
- Parent=i;
- if(Parent==3)
- Parent=0;
+ pop_out_of_stack((int)$1,lexer.Location);
Expression expr = (Expression)expr_stack.Pop();
$$ = new If ((Expression) expr, (Statement) end_block(), l);
}
opt_end_block
{
Location l = (Location) oob_stack.Pop ();
- int i = (int)$5;
- if (end_priority[3]>=end_priority[i] && i!=3)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=3 && Parent!=3)
- {
- Report.Error(30081,l,"'If' is not having a matching 'EndIf'");
- Parent = i;
- }
- if(i!=3)
- Parent=i;
- if(Parent==3)
- Parent=0;
+ pop_out_of_stack((int)$5,lexer.Location);
tmp_expr = (Expression)expr_stack.Pop();
tmp_block = (Block) tmp_blocks.Pop();
$$ = new If ((Expression) tmp_expr, (Statement) tmp_block, (Statement) end_block(), l);
opt_end_block
{
Location l = (Location) oob_stack.Pop ();
- int i = (int)$5;
- if (end_priority[3]>=end_priority[i] && i!=3)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=3 && Parent!=3)
- {
- Report.Error(30081,l,"'If' is not having a matching 'EndIf'");
- Parent = i;
- }
- if(i!=3)
- Parent=i;
- if(Parent==3)
- Parent=0;
+ pop_out_of_stack((int)$5,lexer.Location);
oob_stack.Push (l);
Expression expr = (Expression)expr_stack.Pop();
Block bl = (Block)tmp_blocks.Pop();
opt_end_block
{
Location l = (Location) oob_stack.Pop ();
- int i = (int)$1;
- if (end_priority[3]>=end_priority[i] && i!=3)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=3 && Parent!=3)
- {
- Report.Error(30081,l,"'If' is not having a matching 'EndIf'");
- Parent = i;
- }
- if(i!=3)
- Parent=i;
- if(Parent==3)
- Parent=0;
+ pop_out_of_stack((int)$1,lexer.Location);
oob_stack.Push (l);
Expression expr = (Expression)expr_stack.Pop();
Statement stmt = (Statement) new If ((Expression) expr, (Statement) end_block(), l);
: SELECT
_mark_ opt_case expression end_of_stmt
{
+ push_into_stack((int)Start_block.SELECT, (Location)$2);
oob_stack.Push (lexer.Location);
switch_stack.Push (current_block);
}
opt_case_sections
opt_end_block
{
- int i = (int)$8;
- if (end_priority[17]>=end_priority[i] && i!=17)
- {
- Report.Error(error_numbers[i],lexer.Location,"'"+end_blocks[i]+"' found without a matching '"+open_blocks[i]+"'"+open_blocks[20]);
- Environment.Exit(1);
- }
- if (i!=17 && Parent!=17)
- {
- Report.Error(30095,(Location)$2,"'Select' is not having a matching 'End Select'");
- Parent = i;
- }
- if(i!=17)
- Parent=i;
- if(Parent==17)
- Parent=0;
+ pop_out_of_stack((int)$8,lexer.Location);
current_block = (Block) switch_stack.Pop ();
$$ = new Switch ((Expression) $4, (ArrayList) $7, (Location) oob_stack.Pop ());
}
topmost.statements.Add (new Break (lexer.Location));
ArrayList a = new ArrayList();
- a.Add (new SwitchLabel (null, lexer.Location));
+ a.Add (new SwitchLabel (null, SwitchLabel.LabelType.Else, Binary.Operator.TOP, lexer.Location));
$$ = new SwitchSection ((ArrayList) a, topmost);
}
;
: case_clause
{
ArrayList labels = new ArrayList ();
-
labels.Add ($1);
$$ = labels;
}
| case_clauses COMMA case_clause
{
ArrayList labels = (ArrayList) ($1);
- labels.Add ($2);
+ labels.Add ($3);
$$ = labels;
}
case_clause
: opt_is comparison_operator expression
+ {
+ $$ = new SwitchLabel ((Expression) $3, SwitchLabel.LabelType.Operator, (Binary.Operator) $2, lexer.Location);
+ }
| expression
{
- $$ = new SwitchLabel ((Expression) $1, lexer.Location);
+ $$ = new SwitchLabel ((Expression) $1, SwitchLabel.LabelType.Label, Binary.Operator.TOP, lexer.Location);
}
+ | expression TO expression
+ {
+ $$ = new SwitchLabel ((Expression) $1, (Expression) $3, SwitchLabel.LabelType.Range,
+ Binary.Operator.TOP, lexer.Location);
+ }
+
;
opt_is
;
comparison_operator
- : OP_LT
+ : OP_LT
+ {
+ $$ = Binary.Operator.LessThan;
+ }
| OP_GT
+ {
+ $$ = Binary.Operator.GreaterThan;
+ }
+ | OP_GE
+ {
+ $$ = Binary.Operator.GreaterThanOrEqual;
+ }
| OP_LE
+ {
+ $$ = Binary.Operator.LessThanOrEqual;
+ }
| OP_NE
- /*| OP_EQ */
+ {
+ $$ = Binary.Operator.Inequality;
+ }
+ | ASSIGN
+ {
+ $$ = Binary.Operator.Equality;
+ }
;
opt_case
;
array_creation_expression
- : object_creation_expression opt_rank_specifiers array_initializer
+ : object_creation_expression opt_rank_specifiers _mark_ array_initializer
{
New n = (New) $1;
ArrayList dims = new ArrayList();
Expression atype = n.RequestedType;
if ($2 != null)
- atype = DecomposeQI (atype.ToString () + VariableDeclaration.BuildRanks ((ArrayList)$2, true, lexer.Location), lexer.Location);
+ atype = DecomposeQI (atype.ToString () + VariableDeclaration.BuildRanks ((ArrayList)$2, true, (Location)$3), (Location)$3);
- ArrayList init = (ArrayList) $3;
+ ArrayList init = (ArrayList) $4;
if (init.Count == 0)
init = null;
if (VariableDeclaration.IndexesSpecifiedInRank(dims)) {
VariableDeclaration.VBFixIndexList (ref dims);
- $$ = new ArrayCreation (atype, dims, "", init, lexer.Location);
+ $$ = new ArrayCreation (atype, dims, "", init, (Location)$3);
}
else
{
string rank = VariableDeclaration.BuildRank (dims);
- $$ = new ArrayCreation (atype, rank, (ArrayList) $3, lexer.Location);
+ $$ = new ArrayCreation (atype, rank, (ArrayList) $4, (Location)$3);
}
//Console.WriteLine ("Creating a new array of type " + (atype.ToString()) + " with rank '" + dims + "'");
}
"Array types specified in too many places");
if (VariableDeclaration.IndexesSpecifiedInRank (args))
- Report.Error (30638, "Array bounds cannot appear in type specifiers.");
+ Report.Error (30638, (Location)$1,"Array bounds cannot appear in type specifiers.");
current_rank_specifiers = new ArrayList ();
current_rank_specifiers.Add (args);
opt_type_with_ranks
: opt_type_spec
- | AS type rank_specifiers
+ | AS type _mark_ rank_specifiers
{
- $$ = DecomposeQI ($2.ToString() + VariableDeclaration.BuildRanks ((ArrayList)$3, true, lexer.Location), lexer.Location);
+ $$ = DecomposeQI ($2.ToString() + VariableDeclaration.BuildRanks ((ArrayList)$4, true, (Location)$3), (Location)$3);
}
;
variable_initializer
: expression
{
- $$ = $1;
+ Expression etmp = (Expression) $1;
+ etmp = SetValueRequiredFlag (etmp);
+ $$ = etmp;
}
| array_initializer
{
| parenthesized_expression
| this_access
| base_access
- | qualified_identifier
+ | qualified_identifier opt_type_character _mark_
{
string name = (string) $1;
- $$ = DecomposeQI (name, lexer.Location);
+ $$ = DecomposeQI (name, (Location)$3);
}
| get_type_expression
| member_access
//| element_access
| new_expression
| cast_expression
- | /*empty*/ _mark_
- { Report.Error(30201,(Location)$1,"Expression expected"); }
+ | error _mark_
+ { Report.Error(30201,(Location)$2,"Expression expected"); $$ = (Expression)null;}
;
literal
;
member_access
- : primary_expression DOT identifier
+ : primary_expression DOT _mark_ identifier
{
if ($1 != null) {
- string id_name = (string)$3;
+ string id_name = (string)$4;
if (id_name.ToUpper() == "NEW")
id_name = ".ctor";
- $$ = new MemberAccess ((Expression) $1, id_name, lexer.Location);
+ $$ = new MemberAccess ((Expression) $1, id_name, (Location)$3);
}
else
{
if (with_stack.Count > 0) {
Expression e = (Expression) with_stack.Peek();
- $$ = new MemberAccess (e, (string) $3, lexer.Location);
+ $$ = new MemberAccess (e, (string) $4, (Location)$3);
}
else
{
}
}
}
-/* | primary_expression DOT NEW
+/* | primary_expression DOT _mark_ NEW
{
- $$ = new MemberAccess ((Expression) $1, (string) ".ctor", lexer.Location);
+ $$ = new MemberAccess ((Expression) $1, (string) ".ctor", (Location)$3);
} */
- | predefined_type DOT identifier
+ | predefined_type DOT _mark_ identifier
{
if ($1 != null)
- $$ = new MemberAccess ((Expression) $1, (string) $3, lexer.Location);
+ $$ = new MemberAccess ((Expression) $1, (string) $4, (Location)$3);
else
{
if (with_stack.Count > 0) {
Expression e = (Expression) with_stack.Peek();
- $$ = new MemberAccess (e, (string) $3, lexer.Location);
+ $$ = new MemberAccess (e, (string) $4, (Location)$3);
}
else
{
;
invocation_expression
- : primary_expression OPEN_PARENS opt_argument_list _mark_ CLOSE_PARENS
- {
- if ($1 == null) {
- Location l = (Location)$4;
- Report.Error (1, l, "THIS IS CRAZY");
- }
- $$ = new Invocation ((Expression) $1, (ArrayList) $3, (Location)$4);
-// Console.WriteLine ("Invocation: {0} with {1} arguments", $1, ($3 != null) ? ((ArrayList) $3).Count : 0);
- }
-
// To support Mid$()
- | primary_expression DOLAR_SIGN OPEN_PARENS opt_argument_list _mark_ CLOSE_PARENS
+ : primary_expression opt_dolar_sign OPEN_PARENS opt_argument_list _mark_ CLOSE_PARENS
{
if ($1 == null) {
Location l = (Location)$5;
$$ = new Invocation ((Expression) $2, (ArrayList) $3, (Location)$5);
// Console.WriteLine ("Invocation: {0} with {1} arguments", $2, ($3 != null) ? ((ArrayList) $3).Count : 0);
}
+ | primary_expression EXCLAMATION _mark_ identifier // FIXME : This should be identifier-or-keyword
+ {
+ if ($1 == null) {
+ Location l = (Location)$3;
+ Report.Error (1, l, "THIS IS CRAZY");
+ }
+
+ ArrayList args = new ArrayList ();
+ Expression etmp = new StringLiteral ((string)$4);
+
+ args.Add (new Argument (etmp, Argument.AType.Expression));
+ $$ = new Invocation ((Expression) $1, args, (Location)$3);
+ }
;
-
+
+opt_dolar_sign
+ : DOLAR_SIGN
+ | /*empty*/
+ ;
+
base_access
: MYBASE DOT IDENTIFIER
{
{
$$ = new Argument ((Expression) $2, Argument.AType.AddressOf);
}
+ | identifier ATTR_ASSIGN expression
+ {
+ $$ = new Argument ((string) $1, (Expression) $3, Argument.AType.Expression);
+ }
;
variable_reference
expression
: conditional_xor_expression { $$ = $1; }
- | /*empty*/ _mark_
- { Report.Error(30201,(Location)$1,"Expression expected"); }
/*| assignment_expression*/
;
}
| MYCLASS
{
- // FIXME: This is actually somewhat different from Me
- // because it is for accessing static (classifier) methods/properties/fields
- $$ = new This (current_block, lexer.Location);
+ $$ = new This (This.TypeOfAccess.MyClass, current_block, lexer.Location);
}
;
;
get_type_expression
- : GETTYPE _mark_ OPEN_PARENS type CLOSE_PARENS
+ : GETTYPE OPEN_PARENS _mark_ type CLOSE_PARENS
{
- $$ = new TypeOf ((Expression) $4, (Location)$2);
+ $$ = new TypeOf ((Expression) $4, (Location)$3);
}
- | /*empty*/ _mark_
- { Report.Error(30201,(Location)$1,"Expression expected"); }
;
exponentiation_expression
- : primary_expression
+ : prefixed_unary_expression
| exponentiation_expression OP_EXP _mark_ primary_expression
{
- $$ = new Exponentiation ((Location)$3, (Expression) $1, (Expression) $4);
+ $$ = new Binary (Binary.Operator.Exponentiation,
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | /*empty*/ _mark_
- { Report.Error(30201,(Location)$1,"Expression expected"); }
;
prefixed_unary_expression
- : exponentiation_expression
+ : primary_expression
| PLUS _mark_ prefixed_unary_expression
{
//FIXME: Is this rule correctly defined ?
//FIXME: Is this rule correctly defined ?
$$ = new Unary (Unary.Operator.UnaryNegation, (Expression) $3, (Location)$2);
}
- | /*empty*/ _mark_
- { Report.Error(30201,(Location)$1,"Expression expected"); }
;
multiplicative_expression
- : prefixed_unary_expression
- | multiplicative_expression _mark_ STAR prefixed_unary_expression
+ : exponentiation_expression
+ | multiplicative_expression STAR _mark_ prefixed_unary_expression
{
$$ = new Binary (Binary.Operator.Multiply,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | multiplicative_expression _mark_ DIV prefixed_unary_expression
+ | multiplicative_expression DIV _mark_ prefixed_unary_expression
{
$$ = new Binary (Binary.Operator.Division,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | /*empty*/ _mark_
- { Report.Error(30201,(Location)$1,"Expression expected"); }
;
integer_division_expression
: multiplicative_expression
- | integer_division_expression _mark_ OP_IDIV multiplicative_expression
+ | integer_division_expression OP_IDIV _mark_ multiplicative_expression
{
//FIXME: Is this right ?
$$ = new Binary (Binary.Operator.IntDivision,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | /*empty*/ _mark_
- { Report.Error(30201,(Location)$1,"Expression expected"); }
;
mod_expression
: integer_division_expression
- | mod_expression _mark_ MOD integer_division_expression
+ | mod_expression MOD _mark_ integer_division_expression
{
$$ = new Binary (Binary.Operator.Modulus,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | /*empty*/ _mark_
- { Report.Error(30201,(Location)$1,"Expression expected"); }
;
additive_expression
: mod_expression
- | additive_expression _mark_ PLUS mod_expression
+ | additive_expression PLUS _mark_ mod_expression
{
$$ = new Binary (Binary.Operator.Addition,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | additive_expression _mark_ MINUS mod_expression
+ | additive_expression MINUS _mark_ mod_expression
{
$$ = new Binary (Binary.Operator.Subtraction,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | /*empty*/ _mark_
- { Report.Error(30201,(Location)$1,"Expression expected"); }
;
concat_expression
: additive_expression
- | concat_expression _mark_ OP_CONCAT additive_expression
+ | concat_expression OP_CONCAT _mark_ additive_expression
{
// FIXME: This should only work for String expressions
// We probably need to use something from the runtime
- $$ = new StringConcat((Location)$2,
+ $$ = new StringConcat((Location)$3,
(Expression) $1, (Expression) $4);
}
- | /*empty*/ _mark_
- { Report.Error(30201,(Location)$1,"Expression expected"); }
;
shift_expression
: concat_expression
- | shift_expression _mark_ OP_SHIFT_LEFT concat_expression
+ | shift_expression OP_SHIFT_LEFT _mark_ concat_expression
{
- $$ = new Binary(Binary.Operator.LeftShift, (Expression) $1, (Expression) $4, (Location)$2);
+ $$ = new Binary(Binary.Operator.LeftShift, (Expression) $1, (Expression) $4, (Location)$3);
}
- | shift_expression _mark_ OP_SHIFT_RIGHT concat_expression
+ | shift_expression OP_SHIFT_RIGHT _mark_ concat_expression
{
- $$ = new Binary(Binary.Operator.RightShift, (Expression) $1, (Expression) $4, (Location)$2);
+ $$ = new Binary(Binary.Operator.RightShift, (Expression) $1, (Expression) $4, (Location)$3);
}
- | /*empty*/ _mark_
- { Report.Error(30201,(Location)$1,"Expression expected"); }
;
relational_expression
: shift_expression
- | relational_expression _mark_ ASSIGN shift_expression
+ | relational_expression LIKE _mark_ shift_expression
+ {
+ $$ = new Binary (Binary.Operator.Like,
+ (Expression) $1, (Expression) $4, (Location)$3);
+ }
+ | relational_expression ASSIGN _mark_ shift_expression
{
$$ = new Binary (Binary.Operator.Equality,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | relational_expression _mark_ OP_NE shift_expression
+ | relational_expression OP_NE _mark_ shift_expression
{
$$ = new Binary (Binary.Operator.Inequality,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | relational_expression _mark_ OP_LT shift_expression
+ | relational_expression OP_LT _mark_ shift_expression
{
$$ = new Binary (Binary.Operator.LessThan,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | relational_expression _mark_ OP_GT shift_expression
+ | relational_expression OP_GT _mark_ shift_expression
{
$$ = new Binary (Binary.Operator.GreaterThan,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | relational_expression _mark_ OP_LE shift_expression
+ | relational_expression OP_LE _mark_ shift_expression
{
$$ = new Binary (Binary.Operator.LessThanOrEqual,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | relational_expression _mark_ OP_GE shift_expression
+ | relational_expression OP_GE _mark_ shift_expression
{
$$ = new Binary (Binary.Operator.GreaterThanOrEqual,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | relational_expression _mark_ IS shift_expression
+ | relational_expression IS _mark_ shift_expression
{
$$ = new Binary (Binary.Operator.Is,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | TYPEOF _mark_ shift_expression IS type
+ | TYPEOF shift_expression _mark_ IS type
{
//FIXME: Is this rule correctly defined ?
- $$ = new Is ((Expression) $3, (Expression) $5, (Location)$2);
+ $$ = new Is ((Expression) $2, (Expression) $5, (Location)$3);
}
- | /*empty*/ _mark_
- { Report.Error(30201,(Location)$1,"Expression expected"); }
;
negation_expression
//FIXME: Is this rule correctly defined ?
$$ = new Unary (Unary.Operator.LogicalNot, (Expression) $3, (Location)$2);
}
- | /*empty*/ _mark_
- { Report.Error(30201,(Location)$1,"Expression expected"); }
;
conditional_and_expression
: negation_expression
- | conditional_and_expression _mark_ AND negation_expression
+ | conditional_and_expression AND _mark_ negation_expression
{
$$ = new Binary (Binary.Operator.BitwiseAnd,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | conditional_and_expression _mark_ ANDALSO negation_expression
+ | conditional_and_expression ANDALSO _mark_ negation_expression
{ // FIXME: this is likely to be broken
$$ = new Binary (Binary.Operator.LogicalAnd,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | /*empty*/ _mark_
- { Report.Error(30201,(Location)$1,"Expression expected"); }
;
conditional_or_expression
: conditional_and_expression
- | conditional_or_expression _mark_ OR conditional_and_expression
+ | conditional_or_expression OR _mark_ conditional_and_expression
{
$$ = new Binary (Binary.Operator.BitwiseOr,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | conditional_or_expression _mark_ ORELSE conditional_and_expression
+ | conditional_or_expression ORELSE _mark_ conditional_and_expression
{ // FIXME: this is likely to be broken
$$ = new Binary (Binary.Operator.LogicalOr,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | /*empty*/ _mark_
- { Report.Error(30201,(Location)$1,"Expression expected"); }
;
conditional_xor_expression
: conditional_or_expression
- | conditional_xor_expression _mark_ XOR conditional_or_expression
+ | conditional_xor_expression XOR _mark_ conditional_or_expression
{
$$ = new Binary (Binary.Operator.ExclusiveOr,
- (Expression) $1, (Expression) $4, (Location)$2);
+ (Expression) $1, (Expression) $4, (Location)$3);
}
- | /* empty */ _mark_
- { Report.Error(30201,(Location)$1,"Expression expected"); }
;
assignment_expression
- : prefixed_unary_expression _mark_ ASSIGN expression
+ : prefixed_unary_expression ASSIGN _mark_ expression
{
- $$ = new Assign ((Expression) $1, (Expression) $4, (Location)$2);
+ $$ = new Assign ((Expression) $1, (Expression) $4, (Location)$3);
}
- | prefixed_unary_expression _mark_ STAR ASSIGN expression
+ | prefixed_unary_expression OP_EXP ASSIGN _mark_ expression
{
- Location l = (Location)$2;
-
+ Location l = (Location)$4;
+ $$ = new CompoundAssign (
+ Binary.Operator.Exponentiation, (Expression) $1, (Expression) $5, l);
+ }
+ | prefixed_unary_expression STAR ASSIGN _mark_ expression
+ {
+ Location l = (Location)$4;
$$ = new CompoundAssign (
Binary.Operator.Multiply, (Expression) $1, (Expression) $5, l);
}
- | prefixed_unary_expression _mark_ DIV ASSIGN expression
+ | prefixed_unary_expression DIV ASSIGN _mark_ expression
{
- Location l = (Location)$2;
-
+ Location l = (Location)$4;
$$ = new CompoundAssign (
Binary.Operator.Division, (Expression) $1, (Expression) $5, l);
}
- | prefixed_unary_expression _mark_ PLUS ASSIGN expression
+ | prefixed_unary_expression PLUS ASSIGN _mark_ expression
{
- Location l = (Location)$2;
-
+ Location l = (Location)$4;
$$ = new CompoundAssign (
Binary.Operator.Addition, (Expression) $1, (Expression) $5, l);
}
- | prefixed_unary_expression _mark_ MINUS ASSIGN expression
+ | prefixed_unary_expression MINUS ASSIGN _mark_ expression
{
- Location l = (Location)$2;
-
+ Location l = (Location)$4;
$$ = new CompoundAssign (
Binary.Operator.Subtraction, (Expression) $1, (Expression) $5, l);
}
- | prefixed_unary_expression _mark_ OP_SHIFT_LEFT ASSIGN expression
+ | prefixed_unary_expression OP_SHIFT_LEFT ASSIGN _mark_ expression
{
- Location l = (Location)$2;
-
+ Location l = (Location)$4;
$$ = new CompoundAssign (
Binary.Operator.LeftShift, (Expression) $1, (Expression) $5, l);
}
- | prefixed_unary_expression _mark_ OP_SHIFT_RIGHT ASSIGN expression
+ | prefixed_unary_expression OP_SHIFT_RIGHT ASSIGN _mark_ expression
{
- Location l = (Location)$2;
-
+ Location l = (Location)$4;
$$ = new CompoundAssign (
Binary.Operator.RightShift, (Expression) $1, (Expression) $5, l);
}
- | prefixed_unary_expression _mark_ OP_CONCAT ASSIGN expression
+ | prefixed_unary_expression OP_CONCAT ASSIGN _mark_ expression
{
- Location l = (Location)$2;
+ Location l = (Location)$4;
// FIXME should be strings only
$$ = new CompoundAssign (
Binary.Operator.Addition, (Expression) $1, (Expression) $5, l);
}
- | prefixed_unary_expression _mark_ OP_EXP ASSIGN expression
- {
- /*Location l = (Location)$2;
-
- TODO: $$ = new CompoundAssign (
- Binary.Operator.ExclusiveOr, (Expression) $1, (Expression) $5, l); */
- }
- | prefixed_unary_expression _mark_ ASSIGN ADDRESSOF expression
+ | prefixed_unary_expression ASSIGN ADDRESSOF _mark_ expression
{
ArrayList args = new ArrayList();
Argument arg = new Argument ((Expression) $5, Argument.AType.Expression);
args.Add (arg);
- New n = new New ((Expression) $1, (ArrayList) args, (Location)$2);
+ New n = new New ((Expression) $1, (ArrayList) args, (Location)$4);
n.isDelegate = true;
- $$ = new Assign ((Expression) $1, (Expression) n, (Location)$2);
+ $$ = new Assign ((Expression) $1, (Expression) n, (Location)$4);
}
;
;
boolean_expression
- : expression
+ : expression
+ {
+ Expression expr = (Expression) $1;
+ expr = SetValueRequiredFlag (expr);
+ $$ = expr;
+ }
;
type
| DOUBLE { $$ = TypeManager.system_double_expr; }
;
+directive_exp
+ : boolean_literal
+ | constant_expression _mark_ //FIXME: Fix for binary expression
+ {
+ Expression exp = (Expression) $1;
+ if(exp is SimpleName) {
+ string key = ((SimpleName)exp).Name;
+ if(constPreDir.Contains(key)) {
+ $$ = new BoolLiteral ((bool)constPreDir [key]);
+ }
+ }
+ else {
+ object o = ((Constant) exp).GetValue ();
+ bool temp = Convert.ToBoolean(o);
+ $$ = new BoolLiteral ((bool)temp);
+ // Report.Error (30580, (Location)$2, "value of Const used is not set");
+ }
+ }
+ ;
+
pp_directive
: HASH IDENTIFIER OPEN_PARENS LITERAL_STRING COMMA LITERAL_INTEGER CLOSE_PARENS _mark_ EOL
{
}
}
}
- | HASH CONST IDENTIFIER ASSIGN boolean_literal _mark_ EOL
+ | HASH CONST IDENTIFIER ASSIGN constant_expression _mark_ EOL
{
- if(tokenizerController.IsAcceptingTokens)
{
- //TODO;
- //FIXME;
+ Expression express = (Expression) $5;
+ if (express is Binary) {
+ // FIXME
+ // TODO
+ }
+ object o = ((Constant) express).GetValue ();
+ bool temp = Convert.ToBoolean(o);
+ constPreDir.Add($3,temp);
}
}
| HASH IF _mark_
throw new MBASException(ifElseStateMachine.Error, (Location)$3, ifElseStateMachine.ErrString);
}
}
- boolean_literal opt_then EOL
+ directive_exp opt_then EOL
{
+ //FIXME: Fix for constant expression
+
HandleConditionalDirective(IfElseStateMachine.Token.IF, (BoolLiteral)$5);
}
| HASH opt_elseif _mark_
throw new MBASException(ifElseStateMachine.Error, (Location)$3, ifElseStateMachine.ErrString);
}
}
- boolean_literal opt_then EOL
- {
+ directive_exp opt_then EOL
+ {
+ //FIXME: Fix for constant expression
+
HandleConditionalDirective(IfElseStateMachine.Token.ELSEIF, (BoolLiteral)$5);
}
| HASH ELSE _mark_
| HASH END IF _mark_
{
/*FIXME: IF without ENDIF not working properly. Error line is not diplayed properly*/
-
+
IfElseStateMachine.Token tok = IfElseStateMachine.Token.ENDIF;
try {
ifElseStateMachine.HandleToken(tok);
// Changed so as to check if every block is closed or not...
opt_end_block
- : END opt_block_types
+ : opt_block_types
{
- $$ = 2 + (int)$2 ;
+ $$ = 2 + (int)$1 ;
}
| NEXT
{$$ = 1;}
| LOOP
{$$ = 2;}
- | /* empty */
- {$$ = 0;}
+ | EOF
+ {$$ = Token.EOF;}
;
opt_block_types
- : IF
+ : END IF
{$$ = 1;}
- | SUB
+ | END SUB
{$$ = 2;}
- | MODULE
+ | END MODULE
{$$ = 3;}
- | NAMESPACE
+ | END NAMESPACE
{$$ = 4;}
- | CLASS
+ | END CLASS
{$$ = 5;}
- | FUNCTION
+ | END FUNCTION
{$$ = 6;}
- | STRUCTURE
+ | END STRUCTURE
{$$ = 7;}
- | ENUM
+ | END ENUM
{$$ = 8;}
- | INTERFACE
+ | END INTERFACE
{$$ = 9;}
- | PROPERTY
+ | END PROPERTY
{$$ = 10;}
- | WITH
+ | END WITH
{$$ = 11;}
- | SYNCLOCK
+ | END SYNCLOCK
{$$ = 12;}
- | TRY
+ | END TRY
{$$ = 13;}
- | WHILE
+ | END WHILE
{$$ = 14;}
- | SELECT
+ | END SELECT
{$$ = 15;}
- | SET
+ | END SET
{$$ = 16;}
- | GET
+ | END GET
{$$ = 17;}
+ /*In case of any new end block please add it here.. after END_GET as single token... and please continue the numbering from 17...*/
;
%%
return (res);
}
+void push_into_stack(int BlockStart, Location l)
+{
+ end_of_block.Push(BlockStart);
+ loc_end_of_block.Push(l);
+}
+
+void pop_out_of_stack(int BlockEnd, Location l)
+{
+ if(BlockEnd != Token.EOF) {
+ int current = (int)end_of_block.Pop();
+ Location current_loc = (Location)loc_end_of_block.Pop();
+ if(BlockEnd != current) {
+ // Block end is missing
+ // eg: For 'Sub' BlockEnd should be 'End Sub'
+
+ if(error_end_blocks[BlockEnd,2] > error_end_blocks[current,2]) {
+ while(error_end_blocks[BlockEnd,2] > error_end_blocks[current,2])
+ {
+ if(error_end_blocks[BlockEnd,2] > error_end_blocks[current,2])
+ Report.Error(error_end_blocks[current,0],current_loc,"'"+end_blocks[current,0]+"' is not having matching '"+end_blocks[current,1]+"'");
+ current = (int)end_of_block.Pop();
+ current_loc = (Location)loc_end_of_block.Pop();
+ }
+ }
+
+ // Extra end is present, but works for lesser priority
+ // (for priority see opt_end_block opt_block_types return values
+ // eg: 'EndIf' without 'If' inside 'Sub'
+ // Also certain other errors like 'Sub' having a 'End Module' etc
+ // can be handled here
+
+ if(error_end_blocks[BlockEnd,2] < error_end_blocks[current,2]) {
+ Report.Error(error_end_blocks[BlockEnd,1],l,"'"+end_blocks[BlockEnd,1]+"' is not having a corresponding '"+end_blocks[BlockEnd,0]+"'");
+ end_of_block.Push(current);
+ loc_end_of_block.Push(current_loc);
+ }
+ // Extra end is present but with equal priorty
+
+ if((error_end_blocks[BlockEnd,2] == error_end_blocks[current,2]) && BlockEnd != current) {
+ while((error_end_blocks[BlockEnd,2] == error_end_blocks[current,2]) && BlockEnd != current) {
+ temp_block.Push(current);
+ loc_temp_block.Push(current_loc);
+ current = (int)end_of_block.Pop();
+ current_loc = (Location)loc_end_of_block.Pop();
+ }
+
+ if(BlockEnd == current) {
+ while(temp_block.Count !=0)
+ {
+ int lapse = (int) temp_block.Pop();
+ Location lapse_location = (Location)loc_temp_block.Pop();
+ Report.Error(error_end_blocks[lapse,0],lapse_location,"'"+end_blocks[lapse,0]+"' is not having matching '"+end_blocks[lapse,1]+"'");
+ }
+ }
+
+ else {
+ Report.Error(error_end_blocks[BlockEnd,1],l,"'"+end_blocks[BlockEnd,1]+"' is not having a corresponding '"+end_blocks[BlockEnd,0]+"'");
+ end_of_block.Push(current);
+ loc_end_of_block.Push(current_loc);
+ while(temp_block.Count !=0) {
+ int lapse = (int) temp_block.Pop();
+ Location lapse_location = (Location)loc_temp_block.Pop();
+ end_of_block.Push(lapse);
+ loc_end_of_block.Push(lapse_location);
+ }
+ }
+ }
+ }
+ }
+ else {
+ while(end_of_block.Count !=0) {
+ int lapse = (int) end_of_block.Pop();
+ Location lapse_location = (Location)loc_end_of_block.Pop();
+ Report.Error(error_end_blocks[lapse,0],lapse_location,"'"+end_blocks[lapse,0]+"' is not having matching '"+end_blocks[lapse,1]+"'");
+ }
+ }
+}
+
private void AddHandler (Expression evt_definition, Expression handler_exp)
{
AddHandler (current_block, evt_definition, handler_exp);
}
+/*
void CheckAttributeTarget (string a)
{
switch (a) {
break;
}
}
+*/
private void AddHandler (Block b, Expression evt_id, Expression handles_exp)
{
return ci;
}
+/*
void Error_ExpectingTypeName (Location l, Expression expr)
{
if (expr is Invocation){
Report.Error (-1, l, "Invalid Type definition");
}
}
+*/
+
+public static Expression SetLeftHandFlag (Expression expr) {
+ if (expr is Invocation) {
+ Invocation e = (Invocation) expr;
+ e.IsLeftHand = true;
+ return e;
+ } else if (expr is MemberAccess) {
+ MemberAccess e = (MemberAccess) expr;
+ e.IsLeftHand = true;
+ return e;
+ }
+ return expr;
+}
+
+public static Expression SetValueRequiredFlag (Expression expr) {
+ if (expr is Invocation) {
+ Invocation e = (Invocation) expr;
+ e.IsRetvalRequired = true;
+ expr = e;
+ return expr;
+ }
+ if (expr is Binary) {
+ Binary binary = (Binary) expr;
+ binary.Left = SetValueRequiredFlag (binary.Left);
+ binary.Right = SetValueRequiredFlag (binary.Right);
+ return binary;
+ }
+ if (expr is Unary) {
+ Unary unary = (Unary) expr;
+ unary.Expr = SetValueRequiredFlag (unary.Expr);
+ return unary;
+ }
+ return expr;
+}
+
+/*
static bool AlwaysAccept (MemberInfo m, object filterCriteria) {
return true;
}
+*/
private void ReportError9998()
{
tmp_blocks = new Stack();
with_stack = new Stack();
statement_stack = new Stack();
+ end_of_block = new Stack ();
+ loc_end_of_block = new Stack ();
+ temp_block = new Stack();
+ loc_temp_block = new Stack();
allow_global_attribs = true;
expecting_global_attribs = false;