Author: manjula
Date: 2005-03-11 06:17:59 -0500 (Fri, 11 Mar 2005)
New Revision: 41685
Modified:
trunk/mcs/mbas/ChangeLog
trunk/mcs/mbas/mb-parser.jay
Log:
Fixes related to displaying correct line number,error message and handle End of
blocks
Modified: trunk/mcs/mbas/ChangeLog
===================================================================
--- trunk/mcs/mbas/ChangeLog 2005-03-11 11:05:17 UTC (rev 41684)
+++ trunk/mcs/mbas/ChangeLog 2005-03-11 11:17:59 UTC (rev 41685)
@@ -1,3 +1,8 @@
+2005-03-11 Manjula GHM <[EMAIL PROTECTED]>
+ Sudharsan V <[EMAIL PROTECTED]>
+ * mb-parser.jay:
+ Fixes related to displaying correct line number,error message
and handle End of blocks
+
2005-03-11 Satya Sudha K <[EMAIL PROTECTED]>
* expression.cs :
Support for 'Nothing' with all operators.
Modified: trunk/mcs/mbas/mb-parser.jay
===================================================================
--- trunk/mcs/mbas/mb-parser.jay 2005-03-11 11:05:17 UTC (rev 41684)
+++ trunk/mcs/mbas/mb-parser.jay 2005-03-11 11:17:59 UTC (rev 41685)
@@ -14,7 +14,6 @@
// Copyright (C) 2003, 2004 Novell
//
//
-
namespace Mono.MonoBASIC
{
using System.Text;
@@ -131,6 +130,22 @@
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"};
+
+ 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};
+
+ 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;
@@ -627,7 +642,7 @@
;
compilation_unit
- : _mark_ logical_end_of_line
+ : logical_end_of_line _mark_
opt_option_directives
opt_imports_directives
declarations
@@ -635,7 +650,7 @@
{
$$=$4;
}
- |_mark_ logical_end_of_line
+ | logical_end_of_line _mark_
opt_option_directives
opt_imports_directives
opt_attributes
@@ -659,6 +674,14 @@
: option_explicit_directive
| option_strict_directive
| option_compare_directive
+ | OPTION _mark_ logical_end_of_line
+ {
+ Report.Error(30206 ,(Location)$2, "Option must be followed by
'Compare' or 'Explicit' or 'Strict'");
+ }
+ | OPTION _mark_ IDENTIFIER logical_end_of_line
+ {
+ Report.Error(30206 ,(Location)$2, "Option must be followed by
'Compare' or 'Explicit' or 'Strict'");
+ }
;
on_off
@@ -688,26 +711,26 @@
;
option_explicit_directive
- : OPTION EXPLICIT on_off logical_end_of_line
+ : OPTION EXPLICIT _mark_ on_off logical_end_of_line
{
if (!UseExtendedSyntax)
- OptionExplicit = (bool)$3;
+ OptionExplicit = (bool)$4;
else
Report.Warning (
- 9999, lexer.Location,
+ 9999, (Location)$3,
"In MonoBASIC extended syntax explicit
declaration is always required. So OPTION EXPLICIT is deprecated");
}
;
option_strict_directive
- : OPTION STRICT on_off logical_end_of_line
+ : OPTION STRICT _mark_ on_off logical_end_of_line
{
if (!UseExtendedSyntax)
- OptionStrict = (bool)$3;
+ OptionStrict = (bool)$4;
else
Report.Warning (
- 9999, lexer.Location,
+ 9999, (Location)$3,
"In MonoBASIC extended syntax strict
assignability is always required. So OPTION STRICT is deprecated");
}
;
@@ -794,9 +817,9 @@
qualified_identifier
- : identifier
+ : identifier
| qualified_identifier DOT identifier // FIXME: It should be
qualified_identifier DOT identifier-or-keyword
- {
+ {
$$ = (($1).ToString ()) + "." + ($3.ToString ());
}
;
@@ -825,16 +848,39 @@
{
RootContext.SourceBeingCompiled.Imports ((string) $1,
lexer.Location);
}
- | identifier ASSIGN namespace_or_type_name
+ | identifier _mark_ ASSIGN namespace_or_type_name
{
- RootContext.SourceBeingCompiled.ImportsWithAlias ((string) $1,
(string) $3, lexer.Location);
+ RootContext.SourceBeingCompiled.ImportsWithAlias ((string) $1,
(string) $4, (Location)$2);
}
+ | identifier _mark_ ASSIGN
+ {
+ Report.Error(30203, (Location)$2, "Alias Statement no complete:
Expression Expected");
+ }
+ | _mark_ /* empty */
+ {
+ Report.Error(30203, (Location)$1, "No namespace imported:
Expression Expected");
+ }
;
opt_params
: /* empty */ { $$ = Parameters.EmptyReadOnlyParameters; }
| OPEN_PARENS CLOSE_PARENS { $$ =
Parameters.EmptyReadOnlyParameters; }
- | OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS { $$ = $2; }
+ | 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;
+ }
;
opt_attributes
@@ -1107,6 +1153,11 @@
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'");
@@ -1165,6 +1216,11 @@
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'");
@@ -1264,6 +1320,11 @@
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'");
@@ -1473,6 +1534,11 @@
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'");
@@ -1558,6 +1624,11 @@
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'");
@@ -1614,6 +1685,11 @@
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)
{
@@ -1664,39 +1740,39 @@
;
event_declaration
- : EVENT identifier AS type opt_implement_clause logical_end_of_line
+ : EVENT identifier _mark_ AS type opt_implement_clause
logical_end_of_line
{
- VariableDeclaration var = new VariableDeclaration ((string) $2,
(Expression) $4, lexer.Location);
+ VariableDeclaration var = new VariableDeclaration ((string) $2,
(Expression) $5, (Location)$3);
- Event e = new Event ((Expression) $4, var.identifier,
+ Event e = new Event ((Expression) $5, var.identifier,
null, current_modifiers,
- current_attributes, (ArrayList) $5,
- lexer.Location);
+ current_attributes, (ArrayList) $6,
+ (Location)$3);
CheckDef (current_container.AddEvent (e), e.Name, e.Location);
}
- | EVENT identifier opt_params opt_implement_clause logical_end_of_line
+ | EVENT identifier _mark_ opt_params opt_implement_clause
logical_end_of_line
{
string delName = null;
- if ($4 == null) {
+ if ($5 == null) {
delName = (string) $2;
delName = delName + "EventHandler";
Mono.MonoBASIC.Delegate del = new
Mono.MonoBASIC.Delegate
(current_container,
TypeManager.system_void_expr,
- (int)
current_modifiers, MakeName(delName), (Parameters) $3,
- (Attributes)
current_attributes, lexer.Location);
+ (int)
current_modifiers, MakeName(delName), (Parameters) $4,
+ (Attributes)
current_attributes, (Location)$3);
del.Namespace = current_namespace;
- CheckDef (current_container.AddDelegate (del),
del.Name, lexer.Location);
+ CheckDef (current_container.AddDelegate (del),
del.Name, (Location)$3);
} else {
- ArrayList impls = (ArrayList) $4;
+ ArrayList impls = (ArrayList) $5;
if (impls.Count > 1) {
string expstr = "Event '" + ((Expression)
impls[1]).ToString () +
"' can not be implemented with Event '"
+
(string) $2 + "', since it's delegate
type does not match " +
"with the delegate type of '" +
((Expression) impls[0]).ToString () + "'";
- Report.Error (31407, lexer.Location, expstr);
+ Report.Error (31407, (Location)$3, expstr);
}
Expression impl = (Expression) impls[0];
delName = impl.ToString();
@@ -1704,11 +1780,11 @@
delName = delName + "EventHandler";
}
- Event e = new Event (DecomposeQI (delName, lexer.Location),
+ Event e = new Event (DecomposeQI (delName, (Location)$3),
(string) $2,
null, current_modifiers,
- current_attributes, (ArrayList) $4,
- lexer.Location);
+ current_attributes, (ArrayList) $5,
+ (Location)$3);
CheckDef (current_container.AddEvent (e), e.Name, e.Location);
}
@@ -1718,7 +1794,7 @@
: ENUM _mark_ identifier opt_type_spec logical_end_of_line
opt_enum_member_declarations
{
- Location enum_location = lexer.Location;
+ Location enum_location = (Location)$2;
string full_name = MakeName ((string) $3);
Expression enum_type = ($4 == null) ?
TypeManager.system_int32_expr : (Expression) $4;
ArrayList enum_members = (ArrayList) $6;
@@ -1754,6 +1830,11 @@
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'");
@@ -1791,9 +1872,9 @@
;
enum_member_declaration
- : opt_attributes identifier logical_end_of_line
+ : opt_attributes identifier _mark_ logical_end_of_line
{
- $$ = new VariableDeclaration ((string) $2, null,
lexer.Location, (Attributes) $1);
+ $$ = new VariableDeclaration ((string) $2, null, (Location)$3,
(Attributes) $1);
}
| opt_attributes identifier
{
@@ -1801,7 +1882,7 @@
}
ASSIGN expression logical_end_of_line
{
- $$ = new VariableDeclaration ((string) $2, $5, lexer.Location,
(Attributes) $1);
+ $$ = new VariableDeclaration ((string) $2, (Expression)$5,
(Location)$3, (Attributes) $1);
}
;
@@ -1836,6 +1917,11 @@
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'");
@@ -1906,36 +1992,36 @@
;
interface_method_declaration
- : SUB identifier opt_params logical_end_of_line
+ : SUB identifier opt_params _mark_ logical_end_of_line
{
Method method = new Method (TypeManager.system_void_expr, (int)
current_modifiers, (string) $2,
- (Parameters) $3,
current_attributes, null, lexer.Location);
+ (Parameters) $3,
current_attributes, null, (Location)$4);
$$ = method;
}
- | FUNCTION identifier opt_type_character opt_params opt_type_with_ranks
logical_end_of_line
+ | FUNCTION identifier opt_type_character opt_params _mark_
opt_type_with_ranks logical_end_of_line
{
- Expression ftype = ($5 == null) ? (($3 == null) ? TypeManager.
- system_object_expr : (Expression) $3 ) : (Expression)
$5;
+ Expression ftype = ($6 == null) ? (($3 == null) ? TypeManager.
+ system_object_expr : (Expression) $3 ) : (Expression)
$6;
Method method = new Method ((Expression) ftype, (int)
current_modifiers,
(string) $2,(Parameters) $4,
current_attributes, null,
- lexer.Location);
+ (Location)$5);
$$ = method;
}
;
interface_property_declaration
- : PROPERTY identifier opt_type_character opt_property_parameters
opt_type_with_ranks logical_end_of_line
+ : PROPERTY identifier _mark_ opt_type_character opt_property_parameters
opt_type_with_ranks logical_end_of_line
{
- Expression ftype = ($5 == null) ? (($3 == null) ?
- TypeManager.system_object_expr : (Expression)
$3 ) : (Expression) $5;
+ Expression ftype = ($6 == null) ? (($4 == null) ?
+ TypeManager.system_object_expr : (Expression)
$4 ) : (Expression) $6;
- current_local_parameters = (Parameters) $4;
+ current_local_parameters = (Parameters) $5;
if (current_local_parameters !=
Parameters.EmptyReadOnlyParameters) {
- get_parameters = current_local_parameters.Copy
(lexer.Location);
- set_parameters = current_local_parameters.Copy
(lexer.Location);
+ get_parameters = current_local_parameters.Copy
((Location)$3);
+ set_parameters = current_local_parameters.Copy
((Location)$3);
Parameter implicit_value_parameter = new Parameter (
ftype, "Value",
Parameter.Modifier.NONE, null);
@@ -1945,7 +2031,7 @@
else
{
get_parameters = Parameters.EmptyReadOnlyParameters;
- set_parameters = new Parameters (null, null
,lexer.Location);
+ set_parameters = new Parameters (null, null
,(Location)$3);
Parameter implicit_value_parameter = new Parameter (
ftype, "Value",
Parameter.Modifier.NONE, null);
@@ -1958,10 +2044,10 @@
Accessor set_block = new Accessor (null, null);
Property prop = new Property ((Expression) ftype, (string) $2,
current_modifiers,
- get_block, set_block,
current_attributes, lexer.Location,
+ get_block, set_block,
current_attributes, (Location)$3,
null, get_parameters, set_parameters,
null);
- CheckDef (current_interface.AddProperty (prop), prop.Name,
lexer.Location);
+ CheckDef (current_interface.AddProperty (prop), prop.Name,
(Location)$3);
get_implicit_value_parameter_type = null;
set_implicit_value_parameter_type = null;
@@ -1972,18 +2058,18 @@
;
interface_event_declaration
- : EVENT identifier AS type logical_end_of_line
+ : EVENT identifier AS _mark_ type logical_end_of_line
{
- VariableDeclaration var = new VariableDeclaration ((string) $2,
(Expression) $4, lexer.Location);
+ VariableDeclaration var = new VariableDeclaration ((string) $2,
(Expression) $5, (Location)$4);
- Event e = new Event ((Expression) $4, var.identifier,
+ Event e = new Event ((Expression) $5, var.identifier,
null, current_modifiers,
- current_attributes, lexer.Location);
+ current_attributes, (Location)$4);
CheckDef (current_interface.AddEvent (e), e.Name, e.Location);
}
- | EVENT identifier opt_params logical_end_of_line
+ | EVENT identifier opt_params _mark_ logical_end_of_line
{
string delName = (string) $2;
delName = delName + "EventHandler";
@@ -1991,15 +2077,15 @@
Mono.MonoBASIC.Delegate del = new Mono.MonoBASIC.Delegate
(current_container,
TypeManager.system_void_expr,
(int) delModifiers,
MakeName(delName), (Parameters) $3,
- (Attributes) current_attributes,
lexer.Location);
+ (Attributes) current_attributes,
(Location)$4);
del.Namespace = current_namespace;
- CheckDef (current_interface.AddDelegate (del), del.Name,
lexer.Location);
+ CheckDef (current_interface.AddDelegate (del), del.Name,
(Location)$4);
- Event e = new Event (DecomposeQI (delName, lexer.Location),
+ Event e = new Event (DecomposeQI (delName, (Location)$4),
(string) $2,
null, current_modifiers,
- current_attributes, lexer.Location);
+ current_attributes, (Location)$4);
CheckDef (current_interface.AddEvent (e), e.Name, e.Location);
}
@@ -2110,6 +2196,11 @@
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'");
@@ -2238,6 +2329,11 @@
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'");
@@ -2279,6 +2375,11 @@
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'");
@@ -2405,13 +2506,13 @@
;
delegate_declaration
- : DELEGATE SUB
+ : DELEGATE SUB _mark_
identifier OPEN_PARENS
opt_formal_parameter_list
CLOSE_PARENS
logical_end_of_line
{
- Location l = lexer.Location;
+ Location l = (Location)$3;
// Module members are static by default, but delegates *can't*
be declared static
// so we must fix it, if mbas was the one actually responsible
for this
// instead of triggering an error.
@@ -2421,18 +2522,18 @@
Mono.MonoBASIC.Delegate del = new Mono.MonoBASIC.Delegate
(current_container,
TypeManager.system_void_expr,
(int) current_modifiers,
- MakeName ((string) $3), (Parameters) $5,
+ MakeName ((string) $4), (Parameters) $6,
(Attributes) current_attributes,
l);
del.Namespace = current_namespace;
CheckDef (current_container.AddDelegate (del), del.Name, l);
}
- | DELEGATE FUNCTION
+ | DELEGATE FUNCTION _mark_
identifier OPEN_PARENS
opt_formal_parameter_list
CLOSE_PARENS opt_type_with_ranks logical_end_of_line
{
- Location l = lexer.Location;
+ Location l = (Location)$3;
// Module members are static by default, but delegates *can't*
be declared static
// so we must fix it, if mbas was the one actually responsible
for this
@@ -2440,12 +2541,12 @@
if (implicit_modifiers && ((current_modifiers &
Modifiers.STATIC) != 0))
current_modifiers = (current_modifiers &
~Modifiers.STATIC);
- Expression ftype = ($7 == null) ?
TypeManager.system_object_expr : (Expression) $7;
+ Expression ftype = ($8 == null) ?
TypeManager.system_object_expr : (Expression) $8;
Mono.MonoBASIC.Delegate del = new Mono.MonoBASIC.Delegate (
current_container,
- ftype, (int) current_modifiers, MakeName ((string) $3),
- (Parameters) $5, (Attributes) current_attributes, l);
+ ftype, (int) current_modifiers, MakeName ((string) $4),
+ (Parameters) $6, (Attributes) current_attributes, l);
del.Namespace = current_namespace;
CheckDef (current_container.AddDelegate (del), del.Name, l);
@@ -2503,6 +2604,11 @@
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'");
@@ -2574,41 +2680,41 @@
parameter
: opt_attributes
opt_parameter_modifier
- identifier opt_type_character opt_rank_specifiers opt_type_with_ranks
opt_variable_initializer
+ identifier _mark_ opt_type_character opt_rank_specifiers
opt_type_with_ranks opt_variable_initializer
{
Parameter.Modifier pm = (Parameter.Modifier)$2;
bool opt_parm = ((pm & Parameter.Modifier.OPTIONAL) != 0);
Expression ptype;
- if (opt_parm && ($7 == null))
- Report.Error (30812, lexer.Location, "Optional
parameters must have a default value");
+ if (opt_parm && ($8 == null))
+ Report.Error (30812, (Location)$4, "Optional parameters
must have a default value");
- if (!opt_parm && ($7 != null))
- Report.Error (32024, lexer.Location, "Non-Optional
parameters should not have a default value");
+ if (!opt_parm && ($8 != null))
+ Report.Error (32024, (Location)$4, "Non-Optional
parameters should not have a default value");
if ((pm & Parameter.Modifier.PARAMS) != 0) {
if ((pm & ~Parameter.Modifier.PARAMS) != 0)
- Report.Error (30667, lexer.Location,
"ParamArray parameters must be ByVal");
+ Report.Error (30667, (Location)$4, "ParamArray
parameters must be ByVal");
}
if ((pm & Parameter.Modifier.REF) !=0)
pm |= Parameter.Modifier.ISBYREF;
- if ($4 != null && $6 != null && $4 != $6)
- Report.Error (30302, lexer.Location, "Type character
conflicts with declared type."); // TODO: Correct error number and message text
+ if ($5 != null && $7 != null && $5 != $7)
+ Report.Error (30302, (Location)$4, "Type character
conflicts with declared type."); // TODO: Correct error number and message text
- ptype = (Expression)(($6 == null) ? (($4 == null) ?
TypeManager.system_object_expr : $4) : $6);
- if ($5 != null) {
+ ptype = (Expression)(($7 == null) ? (($5 == null) ?
TypeManager.system_object_expr : $5) : $7);
+ if ($6 != null) {
string t = ptype.ToString ();
if (t.IndexOf('[') >= 0)
- Report.Error (31087, lexer.Location, "Array
types specified in too many places");
+ Report.Error (31087, (Location)$4, "Array types
specified in too many places");
else
- ptype = DecomposeQI (t +
VariableDeclaration.BuildRanks ((ArrayList) $5, true, lexer.Location),
lexer.Location);
+ ptype = DecomposeQI (t +
VariableDeclaration.BuildRanks ((ArrayList) $6, true, (Location)$4),
(Location)$4);
}
if ((pm & Parameter.Modifier.PARAMS) != 0 && ptype.ToString
().IndexOf('[') < 0)
- Report.Error (30050, lexer.Location, "ParamArray
parameters must be an array type");
+ Report.Error (30050, (Location)$4, "ParamArray
parameters must be an array type");
$$ = new Parameter (ptype, (string) $3, pm,
- (Attributes) $1, (Expression) $7,
opt_parm);
+ (Attributes) $1, (Expression) $8,
opt_parm);
}
;
@@ -2636,7 +2742,8 @@
statement_list
: statement
- | statement_list end_of_stmt statement
+ | statement_list end_of_stmt
+ statement
;
statement
@@ -2742,6 +2849,11 @@
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'");
@@ -2947,6 +3059,11 @@
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'");
@@ -2977,7 +3094,7 @@
;
yield_statement
- : YIELD expression
+ : YIELD expression _mark_
{
if (!UseExtendedSyntax)
{
@@ -2986,14 +3103,14 @@
}
/* else
if (iterator_container == null){
- Report.Error (204, lexer.Location, "yield
statement can only be used within a method, operator or property");
+ Report.Error (204, (Location)$3, "yield
statement can only be used within a method, operator or property");
$$ = null;
} else {
iterator_container.SetYields ();
- $$ = new Yield ((Expression) $2,
lexer.Location);
+ $$ = new Yield ((Expression) $2, (Location)$3);
} */
}
- | YIELD STOP
+ | YIELD STOP _mark_
{
if (!UseExtendedSyntax)
{
@@ -3002,11 +3119,11 @@
}
/* else
if (iterator_container == null){
- Report.Error (204, lexer.Location, "yield
statement can only be used within a method, operator or property");
+ Report.Error (204, (Location)$3, "yield
statement can only be used within a method, operator or property");
$$ = null;
} else {
iterator_container.SetYields ();
- $$ = new YieldBreak (lexer.Location);
+ $$ = new YieldBreak ((Location)$3);
} */
}
;
@@ -3020,6 +3137,11 @@
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'");
@@ -3058,9 +3180,14 @@
_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(30441,try_top,"'Try' is not having a
matching 'End Try'");
+ Report.Error(30384,try_top,"'Try' is not having a
matching 'End Try'");
Parent=i;
}
if(i!=15)
@@ -3098,9 +3225,14 @@
_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(30441,try_top,"'Try' is not having a
matching 'End Try'");
+ Report.Error(30384,try_top,"'Try' is not having a
matching 'End Try'");
Parent=i;
}
if(i!=15)
@@ -3162,7 +3294,7 @@
;
catch_clause
- : CATCH opt_catch_args opt_when end_of_stmt
+ : CATCH opt_catch_args opt_when _mark_ end_of_stmt
{
Expression type = null;
string id = null;
@@ -3174,7 +3306,7 @@
if (id != null){
ArrayList one = new ArrayList ();
- Location loc = lexer.Location;
+ Location loc = (Location)$4;
one.Add (new VariableDeclaration (id, type,
loc));
@@ -3203,7 +3335,7 @@
current_block = current_block.Parent;
}
}
- $$ = new Catch (type, id , (Block) b_catch, (Expression) $3,
lexer.Location);
+ $$ = new Catch (type, id , (Block) b_catch, (Expression) $3,
(Location)$4);
}
;
@@ -3213,10 +3345,20 @@
;
catch_args
- : identifier AS type
+ : identifier AS _mark_ type
{
- $$ = new DictionaryEntry ($3, $1);
+ $$ = new DictionaryEntry ($4, $1);
}
+ | _mark_ AS type
+ {
+ Report.Error(30203, (Location)$1, "Identifier Expected");
+ $$ = null;
+ }
+ | identifier AS _mark_
+ {
+ Report.Error(30182, (Location)$3, "Type Expected");
+ $$ = null;
+ }
;
@@ -3229,14 +3371,19 @@
opt_end_block
{
int i = (int)$7;
- if (i!=20 && Parent!=20)
+ 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!=20)
+ if(i!=2)
Parent=i;
- if(Parent==20)
+ if(Parent==2)
Parent=0;
}
_mark_ opt_do_construct
@@ -3289,6 +3436,11 @@
{
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'");
@@ -3324,6 +3476,11 @@
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'");
@@ -3455,6 +3612,11 @@
{
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'");
@@ -3479,6 +3641,11 @@
{
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'");
@@ -3526,6 +3693,11 @@
{
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'");
@@ -3565,6 +3737,11 @@
{
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'");
@@ -3593,6 +3770,11 @@
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'");
@@ -3736,13 +3918,13 @@
;
object_creation_expression
- : NEW type OPEN_PARENS opt_argument_list CLOSE_PARENS
+ : NEW type OPEN_PARENS _mark_ opt_argument_list CLOSE_PARENS
{
- $$ = new New ((Expression) $2, (ArrayList) $4, lexer.Location);
+ $$ = new New ((Expression) $2, (ArrayList) $5, (Location)$4);
}
- | NEW type
+ | NEW type _mark_
{
- $$ = new New ((Expression) $2, new ArrayList(), lexer.Location);
+ $$ = new New ((Expression) $2, new ArrayList(), (Location)$3);
}
;
@@ -3796,7 +3978,7 @@
}
| local_constant_declaration
{
- if ($1 != null){
+ if ($1!= null){
DictionaryEntry de = (DictionaryEntry) $1;
$$ = declare_local_constant ((Expression) de.Key,
(ArrayList) de.Value);
@@ -4191,6 +4373,8 @@
//| element_access
| new_expression
| cast_expression
+ | /*empty*/ _mark_
+ {
Report.Error(30201,(Location)$1,"Expression expected"); }
;
literal
@@ -4220,7 +4404,7 @@
else if (v is long)
$$ = new LongLiteral ((Int64)v);
else
- Console.WriteLine ("OOPS. Unexpected result from
scanner");
+ Console.WriteLine ("Unexpected result from scanner");
}
;
@@ -4283,33 +4467,33 @@
;
invocation_expression
- : primary_expression OPEN_PARENS opt_argument_list CLOSE_PARENS
+ : primary_expression OPEN_PARENS opt_argument_list _mark_ CLOSE_PARENS
{
if ($1 == null) {
- Location l = lexer.Location;
+ Location l = (Location)$4;
Report.Error (1, l, "THIS IS CRAZY");
}
- $$ = new Invocation ((Expression) $1, (ArrayList) $3,
lexer.Location);
+ $$ = 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
CLOSE_PARENS
+ | primary_expression DOLAR_SIGN OPEN_PARENS opt_argument_list _mark_
CLOSE_PARENS
{
if ($1 == null) {
- Location l = lexer.Location;
+ Location l = (Location)$5;
Report.Error (1, l, "THIS IS CRAZY");
}
- $$ = new Invocation ((Expression) $1, (ArrayList) $4,
lexer.Location);
+ $$ = new Invocation ((Expression) $1, (ArrayList) $4,
(Location)$5);
// Console.WriteLine ("Invocation: {0} with {1} arguments", $1,
($4 != null) ? ((ArrayList) $4).Count : 0);
}
- | CALL primary_expression OPEN_PARENS opt_argument_list CLOSE_PARENS
+ | CALL primary_expression OPEN_PARENS opt_argument_list _mark_
CLOSE_PARENS
{
if ($2 == null) {
- Location l = lexer.Location;
+ Location l = (Location)$5;
Report.Error (1, l, "THIS IS CRAZY");
}
- $$ = new Invocation ((Expression) $2, (ArrayList) $3,
lexer.Location);
+ $$ = new Invocation ((Expression) $2, (ArrayList) $3,
(Location)$5);
// Console.WriteLine ("Invocation: {0} with {1} arguments", $2,
($3 != null) ? ((ArrayList) $3).Count : 0);
}
;
@@ -4388,7 +4572,9 @@
expression
- : conditional_xor_expression { $$ = $1; }
+ : conditional_xor_expression { $$ = $1; }
+ | /*empty*/ _mark_
+ {
Report.Error(30201,(Location)$1,"Expression expected"); }
/*| assignment_expression*/
;
@@ -4437,269 +4623,298 @@
| COBJ { $$ = TypeManager.system_object_expr; }
| CSHORT { $$ = TypeManager.system_int16_expr; }
| CSNG { $$ = TypeManager.system_single_expr; }
- | CSTR { $$ = TypeManager.system_string_expr; }
+ | CSTR { $$ = TypeManager.system_string_expr; }
;
get_type_expression
- : GETTYPE OPEN_PARENS type CLOSE_PARENS
+ : GETTYPE _mark_ OPEN_PARENS type CLOSE_PARENS
{
- $$ = new TypeOf ((Expression) $3, lexer.Location);
+ $$ = new TypeOf ((Expression) $4, (Location)$2);
}
+ | /*empty*/ _mark_
+ {
Report.Error(30201,(Location)$1,"Expression expected"); }
;
exponentiation_expression
: primary_expression
- | exponentiation_expression OP_EXP primary_expression
+ | exponentiation_expression OP_EXP _mark_ primary_expression
{
- $$ = new Exponentiation (lexer.Location, (Expression) $1,
(Expression) $3);
+ $$ = new Exponentiation ((Location)$3, (Expression) $1,
(Expression) $4);
}
+ | /*empty*/ _mark_
+ {
Report.Error(30201,(Location)$1,"Expression expected"); }
;
prefixed_unary_expression
: exponentiation_expression
- | PLUS prefixed_unary_expression
+ | PLUS _mark_ prefixed_unary_expression
{
//FIXME: Is this rule correctly defined ?
- $$ = new Unary (Unary.Operator.UnaryPlus, (Expression) $2,
lexer.Location);
+ $$ = new Unary (Unary.Operator.UnaryPlus, (Expression) $3,
(Location)$2);
}
- | MINUS prefixed_unary_expression
+ | MINUS _mark_ prefixed_unary_expression
{
//FIXME: Is this rule correctly defined ?
- $$ = new Unary (Unary.Operator.UnaryNegation, (Expression) $2,
lexer.Location);
+ $$ = 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 STAR prefixed_unary_expression
+ | multiplicative_expression _mark_ STAR prefixed_unary_expression
{
$$ = new Binary (Binary.Operator.Multiply,
- (Expression) $1, (Expression) $3,
lexer.Location);
+ (Expression) $1, (Expression) $4,
(Location)$2);
}
- | multiplicative_expression DIV prefixed_unary_expression
+ | multiplicative_expression _mark_ DIV prefixed_unary_expression
{
$$ = new Binary (Binary.Operator.Division,
- (Expression) $1, (Expression) $3,
lexer.Location);
+ (Expression) $1, (Expression) $4,
(Location)$2);
}
+ | /*empty*/ _mark_
+ {
Report.Error(30201,(Location)$1,"Expression expected"); }
;
integer_division_expression
: multiplicative_expression
- | integer_division_expression OP_IDIV multiplicative_expression
+ | integer_division_expression _mark_ OP_IDIV multiplicative_expression
{
//FIXME: Is this right ?
$$ = new Binary (Binary.Operator.Division,
- (Expression) $1, (Expression) $3, lexer.Location);
+ (Expression) $1, (Expression) $4, (Location)$2);
}
+ | /*empty*/ _mark_
+ {
Report.Error(30201,(Location)$1,"Expression expected"); }
;
mod_expression
: integer_division_expression
- | mod_expression MOD integer_division_expression
+ | mod_expression _mark_ MOD integer_division_expression
{
$$ = new Binary (Binary.Operator.Modulus,
- (Expression) $1, (Expression) $3,
lexer.Location);
+ (Expression) $1, (Expression) $4, (Location)$2);
}
+ | /*empty*/ _mark_
+ {
Report.Error(30201,(Location)$1,"Expression expected"); }
;
additive_expression
: mod_expression
- | additive_expression PLUS mod_expression
+ | additive_expression _mark_ PLUS mod_expression
{
$$ = new Binary (Binary.Operator.Addition,
- (Expression) $1, (Expression) $3,
lexer.Location);
+ (Expression) $1, (Expression) $4,
(Location)$2);
}
- | additive_expression MINUS mod_expression
+ | additive_expression _mark_ MINUS mod_expression
{
$$ = new Binary (Binary.Operator.Subtraction,
- (Expression) $1, (Expression) $3,
lexer.Location);
+ (Expression) $1, (Expression) $4,
(Location)$2);
}
+ | /*empty*/ _mark_
+ {
Report.Error(30201,(Location)$1,"Expression expected"); }
;
concat_expression
: additive_expression
- | concat_expression OP_CONCAT additive_expression
+ | concat_expression _mark_ OP_CONCAT additive_expression
{
// FIXME: This should only work for String expressions
// We probably need to use something from the runtime
- $$ = new StringConcat (lexer.Location,
- (Expression) $1, (Expression) $3);
+ $$ = new StringConcat((Location)$2,
+ (Expression) $1, (Expression) $4);
}
+ | /*empty*/ _mark_
+ {
Report.Error(30201,(Location)$1,"Expression expected"); }
;
+
shift_expression
: concat_expression
- | shift_expression OP_SHIFT_LEFT concat_expression
+ | shift_expression _mark_ OP_SHIFT_LEFT concat_expression
{
- $$ = new Binary(Binary.Operator.LeftShift, (Expression) $1,
(Expression) $3, lexer.Location);
+ $$ = new Binary(Binary.Operator.LeftShift, (Expression) $1,
(Expression) $4, (Location)$2);
}
- | shift_expression OP_SHIFT_RIGHT concat_expression
+ | shift_expression _mark_ OP_SHIFT_RIGHT concat_expression
{
- $$ = new Binary(Binary.Operator.RightShift, (Expression) $1,
(Expression) $3, lexer.Location);
+ $$ = new Binary(Binary.Operator.RightShift, (Expression) $1,
(Expression) $4, (Location)$2);
}
+ | /*empty*/ _mark_
+ {
Report.Error(30201,(Location)$1,"Expression expected"); }
;
relational_expression
: shift_expression
- | relational_expression ASSIGN shift_expression
+ | relational_expression _mark_ ASSIGN shift_expression
{
$$ = new Binary (Binary.Operator.Equality,
- (Expression) $1, (Expression) $3,
lexer.Location);
+ (Expression) $1, (Expression) $4,
(Location)$2);
}
- | relational_expression OP_NE shift_expression
+ | relational_expression _mark_ OP_NE shift_expression
{
$$ = new Binary (Binary.Operator.Inequality,
- (Expression) $1, (Expression) $3,
lexer.Location);
+ (Expression) $1, (Expression) $4,
(Location)$2);
}
- | relational_expression OP_LT shift_expression
+ | relational_expression _mark_ OP_LT shift_expression
{
$$ = new Binary (Binary.Operator.LessThan,
- (Expression) $1, (Expression) $3,
lexer.Location);
+ (Expression) $1, (Expression) $4,
(Location)$2);
}
- | relational_expression OP_GT shift_expression
+ | relational_expression _mark_ OP_GT shift_expression
{
$$ = new Binary (Binary.Operator.GreaterThan,
- (Expression) $1, (Expression) $3,
lexer.Location);
+ (Expression) $1, (Expression) $4,
(Location)$2);
}
- | relational_expression OP_LE shift_expression
+ | relational_expression _mark_ OP_LE shift_expression
{
$$ = new Binary (Binary.Operator.LessThanOrEqual,
- (Expression) $1, (Expression) $3,
lexer.Location);
+ (Expression) $1, (Expression) $4,
(Location)$2);
}
- | relational_expression OP_GE shift_expression
+ | relational_expression _mark_ OP_GE shift_expression
{
$$ = new Binary (Binary.Operator.GreaterThanOrEqual,
- (Expression) $1, (Expression) $3,
lexer.Location);
+ (Expression) $1, (Expression) $4,
(Location)$2);
}
- | relational_expression IS shift_expression
+ | relational_expression _mark_ IS shift_expression
{
$$ = new Binary (Binary.Operator.Is,
- (Expression) $1, (Expression) $3,
lexer.Location);
+ (Expression) $1, (Expression) $4,
(Location)$2);
}
- | TYPEOF shift_expression IS type
+ | TYPEOF _mark_ shift_expression IS type
{
//FIXME: Is this rule correctly defined ?
- $$ = new Is ((Expression) $2, (Expression) $4, lexer.Location);
+ $$ = new Is ((Expression) $3, (Expression) $5, (Location)$2);
}
+ | /*empty*/ _mark_
+ {
Report.Error(30201,(Location)$1,"Expression expected"); }
;
negation_expression
: relational_expression
- | NOT negation_expression
+ | NOT _mark_ negation_expression
{
//FIXME: Is this rule correctly defined ?
- $$ = new Unary (Unary.Operator.LogicalNot, (Expression) $2,
lexer.Location);
+ $$ = 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 AND negation_expression
+ | conditional_and_expression _mark_ AND negation_expression
{
$$ = new Binary (Binary.Operator.BitwiseAnd,
- (Expression) $1, (Expression) $3,
lexer.Location);
+ (Expression) $1, (Expression) $4,
(Location)$2);
}
- | conditional_and_expression ANDALSO negation_expression
+ | conditional_and_expression _mark_ ANDALSO negation_expression
{ // FIXME: this is likely to be broken
$$ = new Binary (Binary.Operator.LogicalAnd,
- (Expression) $1, (Expression) $3,
lexer.Location);
+ (Expression) $1, (Expression) $4,
(Location)$2);
}
+ | /*empty*/ _mark_
+ {
Report.Error(30201,(Location)$1,"Expression expected"); }
;
conditional_or_expression
: conditional_and_expression
- | conditional_or_expression OR conditional_and_expression
+ | conditional_or_expression _mark_ OR conditional_and_expression
{
$$ = new Binary (Binary.Operator.BitwiseOr,
- (Expression) $1, (Expression) $3,
lexer.Location);
+ (Expression) $1, (Expression) $4,
(Location)$2);
}
- | conditional_or_expression ORELSE conditional_and_expression
+ | conditional_or_expression _mark_ ORELSE conditional_and_expression
{ // FIXME: this is likely to be broken
$$ = new Binary (Binary.Operator.LogicalOr,
- (Expression) $1, (Expression) $3,
lexer.Location);
+ (Expression) $1, (Expression) $4,
(Location)$2);
}
+ | /*empty*/ _mark_
+ {
Report.Error(30201,(Location)$1,"Expression expected"); }
;
conditional_xor_expression
: conditional_or_expression
- | conditional_xor_expression XOR conditional_or_expression
+ | conditional_xor_expression _mark_ XOR conditional_or_expression
{
- $$ = new Binary (Binary.Operator.ExclusiveOr,
- (Expression) $1, (Expression) $3,
lexer.Location);
+ $$ = new Binary (Binary.Operator.ExclusiveOr,
+ (Expression) $1, (Expression) $4, (Location)$2);
}
+ | /* empty */ _mark_
+ {
Report.Error(30201,(Location)$1,"Expression expected"); }
;
assignment_expression
- : prefixed_unary_expression ASSIGN expression
+ : prefixed_unary_expression _mark_ ASSIGN expression
{
- $$ = new Assign ((Expression) $1, (Expression) $3,
lexer.Location);
+ $$ = new Assign ((Expression) $1, (Expression) $4,
(Location)$2);
}
- | prefixed_unary_expression STAR ASSIGN expression
+ | prefixed_unary_expression _mark_ STAR ASSIGN expression
{
- Location l = lexer.Location;
+ Location l = (Location)$2;
$$ = new CompoundAssign (
- Binary.Operator.Multiply, (Expression) $1, (Expression)
$4, l);
+ Binary.Operator.Multiply, (Expression) $1, (Expression)
$5, l);
}
- | prefixed_unary_expression DIV ASSIGN expression
+ | prefixed_unary_expression _mark_ DIV ASSIGN expression
{
- Location l = lexer.Location;
+ Location l = (Location)$2;
$$ = new CompoundAssign (
- Binary.Operator.Division, (Expression) $1, (Expression)
$4, l);
+ Binary.Operator.Division, (Expression) $1, (Expression)
$5, l);
}
- | prefixed_unary_expression PLUS ASSIGN expression
+ | prefixed_unary_expression _mark_ PLUS ASSIGN expression
{
- Location l = lexer.Location;
+ Location l = (Location)$2;
$$ = new CompoundAssign (
- Binary.Operator.Addition, (Expression) $1, (Expression)
$4, l);
+ Binary.Operator.Addition, (Expression) $1, (Expression)
$5, l);
}
- | prefixed_unary_expression MINUS ASSIGN expression
+ | prefixed_unary_expression _mark_ MINUS ASSIGN expression
{
- Location l = lexer.Location;
+ Location l = (Location)$2;
$$ = new CompoundAssign (
- Binary.Operator.Subtraction, (Expression) $1,
(Expression) $4, l);
+ Binary.Operator.Subtraction, (Expression) $1,
(Expression) $5, l);
}
- | prefixed_unary_expression OP_SHIFT_LEFT ASSIGN expression
+ | prefixed_unary_expression _mark_ OP_SHIFT_LEFT ASSIGN expression
{
- Location l = lexer.Location;
+ Location l = (Location)$2;
$$ = new CompoundAssign (
- Binary.Operator.LeftShift, (Expression) $1,
(Expression) $4, l);
+ Binary.Operator.LeftShift, (Expression) $1,
(Expression) $5, l);
}
- | prefixed_unary_expression OP_SHIFT_RIGHT ASSIGN expression
+ | prefixed_unary_expression _mark_ OP_SHIFT_RIGHT ASSIGN expression
{
- Location l = lexer.Location;
+ Location l = (Location)$2;
$$ = new CompoundAssign (
- Binary.Operator.RightShift, (Expression) $1,
(Expression) $4, l);
+ Binary.Operator.RightShift, (Expression) $1,
(Expression) $5, l);
}
- | prefixed_unary_expression OP_CONCAT ASSIGN expression
+ | prefixed_unary_expression _mark_ OP_CONCAT ASSIGN expression
{
- Location l = lexer.Location;
+ Location l = (Location)$2;
// FIXME should be strings only
$$ = new CompoundAssign (
- Binary.Operator.Addition, (Expression) $1, (Expression)
$4, l);
+ Binary.Operator.Addition, (Expression) $1, (Expression)
$5, l);
}
- | prefixed_unary_expression OP_EXP ASSIGN expression
+ | prefixed_unary_expression _mark_ OP_EXP ASSIGN expression
{
- /*Location l = lexer.Location;
+ /*Location l = (Location)$2;
TODO: $$ = new CompoundAssign (
- Binary.Operator.ExclusiveOr, (Expression) $1,
(Expression) $4, l); */
+ Binary.Operator.ExclusiveOr, (Expression) $1,
(Expression) $5, l); */
}
- | prefixed_unary_expression ASSIGN ADDRESSOF expression
+ | prefixed_unary_expression _mark_ ASSIGN ADDRESSOF expression
{
ArrayList args = new ArrayList();
- Argument arg = new Argument ((Expression) $4,
Argument.AType.Expression);
+ Argument arg = new Argument ((Expression) $5,
Argument.AType.Expression);
args.Add (arg);
- New n = new New ((Expression) $1, (ArrayList) args,
lexer.Location);
+ New n = new New ((Expression) $1, (ArrayList) args,
(Location)$2);
n.isDelegate = true;
- $$ = new Assign ((Expression) $1, (Expression) n,
lexer.Location);
+ $$ = new Assign ((Expression) $1, (Expression) n, (Location)$2);
}
;
@@ -4905,7 +5120,7 @@
// Utility rule to save location information
_mark_
: /* empty */
- { $$ = lexer.Location; }
+ { $$ = lexer.Location; if (yyToken == Token.EOL) { $$ = new Location
(lexer.Location.Row - 1, lexer.Location.Col); } }
;
// Changed to accept "Else If" also along with "ElseIf"
@@ -4923,7 +5138,7 @@
| NEXT
{$$ = 1;}
| LOOP
- {$$ = 20;}
+ {$$ = 2;}
| /* empty */
{$$ = 0;}
;
@@ -4931,40 +5146,39 @@
opt_block_types
: IF
{$$ = 1;}
+ | SUB
+ {$$ = 2;}
+ | MODULE
+ {$$ = 3;}
+ | NAMESPACE
+ {$$ = 4;}
+ | CLASS
+ {$$ = 5;}
+ | FUNCTION
+ {$$ = 6;}
+ | STRUCTURE
+ {$$ = 7;}
| ENUM
{$$ = 8;}
+ | INTERFACE
+ {$$ = 9;}
+ | PROPERTY
+ {$$ = 10;}
+ | WITH
+ {$$ = 11;}
+ | SYNCLOCK
+ {$$ = 12;}
| TRY
{$$ = 13;}
+ | WHILE
+ {$$ = 14;}
| SELECT
{$$ = 15;}
| SET
{$$ = 16;}
| GET
{$$ = 17;}
- | WHILE
- {$$ = 14;}
- | SUB
- {$$ = 2;}
- | FUNCTION
- {$$ = 6;}
- | INTERFACE
- {$$ = 9;}
- | PROPERTY
- {$$ = 10;}
- | SYNCLOCK
- {$$ = 12;}
- | WITH
- {$$ = 11;}
- | MODULE
- {$$ = 3;}
- | CLASS
- {$$ = 5;}
- | STRUCTURE
- {$$ = 7;}
- | NAMESPACE
- {$$ = 4;}
- | /* empty */
- {$$ = 0;}
+ ;
%%
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches