Expression implicit_value_parameter_type;
Parameters indexer_parameters;
+ /// <summary>
+ /// Hack to help create non-typed array initializer
+ /// </summary>
+ public static Expression current_array_type;
+
/// <summary>
/// Used to determine if we are parsing the get/set pair
/// of an indexer or a property
%token INTERR "?"
/* C# multi-character operators. */
+%token DOUBLE_COLON "::"
%token OP_INC "++"
%token OP_DEC "--"
%token OP_SHIFT_LEFT "<<"
;
outer_declaration
- : using_directive
+ : extern_alias_directive
+ | using_directive
| namespace_member_declaration
;
-
+
+extern_alias_directives
+ : extern_alias_directive
+ | extern_alias_directives extern_alias_directive;
+
+extern_alias_directive
+ : EXTERN IDENTIFIER IDENTIFIER SEMICOLON
+ {
+ LocatedToken lt = (LocatedToken) $2;
+ string s = lt.Value;
+ if (s != "alias"){
+ Report.Error (1003, lt.Location, "'alias' expected");
+ } else if (RootContext.Version == LanguageVersion.ISO_1) {
+ Report.FeatureIsNotStandardized (lt.Location, "external alias");
+ } else {
+ lt = (LocatedToken) $3;
+ current_namespace.UsingExternalAlias (lt.Value, lt.Location);
+ }
+ }
+ ;
+
using_directives
: using_directive
| using_directives using_directive
if (RootContext.Documentation != null)
Lexer.doc_state = XmlCommentState.Allowed;
}
+ opt_extern_alias_directives
opt_using_directives
opt_namespace_member_declarations
CLOSE_BRACE
| using_directives
;
+opt_extern_alias_directives
+ : /* empty */
+ | extern_alias_directives
+ ;
+
opt_namespace_member_declarations
: /* empty */
| namespace_member_declarations
if (current_attr_target == "assembly" || current_attr_target == "module")
// FIXME: supply "nameEscaped" parameter here.
- $$ = new GlobalAttribute (current_class, current_attr_target,
+ $$ = new GlobalAttribute (current_namespace, current_attr_target,
left_expr, identifier, arguments, mname.Location, lexer.IsEscapedIdentifier (mname.Location));
else
$$ = new Attribute (current_attr_target, left_expr, identifier, arguments, mname.Location, lexer.IsEscapedIdentifier (mname.Location));
foreach (VariableDeclaration var in (ArrayList) $4){
Field field = new Field (current_class, type, mod, var.identifier,
- var.expression_or_array_initializer,
(Attributes) $1, var.Location);
+ field.Initializer = var.expression_or_array_initializer;
+
if (RootContext.Documentation != null) {
field.DocComment = Lexer.consume_doc_comment ();
Lexer.doc_state = XmlCommentState.Allowed;
{
$$ = new VariableDeclaration ((LocatedToken) $1, $3);
}
+ | IDENTIFIER OPEN_BRACKET CLOSE_BRACKET
+ {
+ Report.Error (443, lexer.Location, "Value or constant expected");
+ $$ = new VariableDeclaration ((LocatedToken) $1, null);
+ }
;
variable_declarators
Parameter [] pars = new Parameter [pars_list.Count];
pars_list.CopyTo (pars);
- $$ = new Parameters (pars, null);
+ $$ = new Parameters (pars);
}
| fixed_parameters COMMA parameter_array
{
ArrayList pars_list = (ArrayList) $1;
+ pars_list.Add ($3);
Parameter [] pars = new Parameter [pars_list.Count];
pars_list.CopyTo (pars);
- $$ = new Parameters (pars, (Parameter) $3);
+ $$ = new Parameters (pars);
}
| fixed_parameters COMMA ARGLIST
{
ArrayList pars_list = (ArrayList) $1;
+ //pars_list.Add (new ArglistParameter (GetLocation ($3)));
Parameter [] pars = new Parameter [pars_list.Count];
pars_list.CopyTo (pars);
}
| parameter_array
{
- $$ = new Parameters (null, (Parameter) $1);
+ $$ = new Parameters (new Parameter[] { (Parameter) $1 } );
}
| ARGLIST
{
- $$ = new Parameters (null, true);
+ $$ = new Parameters (new Parameter[0], true);
}
;
;
parameter_modifier
- : REF { $$ = Parameter.Modifier.REF | Parameter.Modifier.ISBYREF; }
- | OUT { $$ = Parameter.Modifier.OUT | Parameter.Modifier.ISBYREF; }
+ : REF { $$ = Parameter.Modifier.REF; }
+ | OUT { $$ = Parameter.Modifier.OUT; }
;
parameter_array
: opt_attributes PARAMS type IDENTIFIER
{
LocatedToken lt = (LocatedToken) $4;
- $$ = new Parameter ((Expression) $3, lt.Value, Parameter.Modifier.PARAMS, (Attributes) $1, lt.Location);
+ $$ = new ParamsParameter ((Expression) $3, lt.Value, (Attributes) $1, lt.Location);
note ("type must be a single-dimension array type");
}
| opt_attributes PARAMS parameter_modifier type IDENTIFIER
if (parsing_indexer == false) {
args = new Parameter [1];
args [0] = implicit_value_parameter;
- current_local_parameters = new Parameters (args, null);
+ current_local_parameters = new Parameters (args);
} else {
Parameter [] fpars = indexer_parameters.FixedParameters;
} else
args = null;
current_local_parameters = new Parameters (
- args, indexer_parameters.ArrayParameter);
+ args);
}
lexer.PropertyParsing = false;
type IDENTIFIER
OPEN_BRACE
{ lexer.PropertyParsing = true; }
- interface_accessors
- { lexer.PropertyParsing = false; }
+ accessor_declarations
+ {
+ has_get = has_set = false;
+ lexer.PropertyParsing = false;
+ }
CLOSE_BRACE
{
LocatedToken lt = (LocatedToken) $4;
MemberName name = new MemberName (lt.Value, lt.Location);
if ($3 == TypeManager.system_void_expr) {
- Report.Error (547, lt.Location, "`{0}': property or indexer cannot have void type", $4);
+ Report.Error (547, lt.Location, "`{0}': property or indexer cannot have void type", lt.Value);
break;
}
+ Property p = null;
if ($7 == null) {
- Property p = new Property (current_class, (Expression) $3, (int) $2, true,
+ p = new Property (current_class, (Expression) $3, (int) $2, true,
name, (Attributes) $1,
null, null);
- Report.Error (548, lexer.Location, "`{0}': property or indexer must have at least one accessor", p.GetSignatureForError ());
+ Report.Error (548, p.Location, "`{0}': property or indexer must have at least one accessor", p.GetSignatureForError ());
break;
}
- InterfaceAccessorInfo pinfo = (InterfaceAccessorInfo) $7;
-
- $$ = new Property (current_class, (Expression) $3, (int) $2, true,
+ Pair pair = (Pair) $7;
+ p = new Property (current_class, (Expression) $3, (int) $2, true,
name, (Attributes) $1,
- pinfo.Get, pinfo.Set);
+ (Accessor)pair.First, (Accessor)pair.Second);
+
+ if (pair.First != null && ((Accessor)(pair.First)).Block != null) {
+ Report.Error (531, p.Location, "`{0}.get': interface members cannot have a definition", p.GetSignatureForError ());
+ $$ = null;
+ break;
+ }
+
+ if (pair.Second != null && ((Accessor)(pair.Second)).Block != null) {
+ Report.Error (531, p.Location, "`{0}.set': interface members cannot have a definition", p.GetSignatureForError ());
+ $$ = null;
+ break;
+ }
+
if (RootContext.Documentation != null)
- ((Property) $$).DocComment = Lexer.consume_doc_comment ();
+ p.DocComment = Lexer.consume_doc_comment ();
+
+ $$ = p;
}
| opt_attributes
opt_new
}
;
-interface_accessors
- : opt_attributes opt_modifiers GET SEMICOLON
- {
- $$ = new InterfaceAccessorInfo (true, false, (Attributes) $1, null, (int) $2, 0, (Location) $3, (Location) $3);
- }
- | opt_attributes opt_modifiers GET OPEN_BRACE
- {
- Report.Error (531, (Location) $3, "`{0}': interface members cannot have a definition", ".get");
- $$ = new InterfaceAccessorInfo (true, false, (Attributes) $1, null, (int) $2, 0, (Location) $3, (Location) $3);
- }
- | opt_attributes opt_modifiers SET SEMICOLON
- {
- $$ = new InterfaceAccessorInfo (false, true, null, (Attributes) $1, 0, (int) $2, (Location) $3, (Location) $3);
- }
- | opt_attributes opt_modifiers GET SEMICOLON opt_attributes opt_modifiers SET SEMICOLON
- {
- $$ = new InterfaceAccessorInfo (true, true, (Attributes) $1, (Attributes) $5, (int) $2, (int) $6, (Location) $3, (Location) $7);
- }
- | opt_attributes opt_modifiers SET SEMICOLON opt_attributes opt_modifiers GET SEMICOLON
- {
- $$ = new InterfaceAccessorInfo (true, true, (Attributes) $5, (Attributes) $1, (int) $6, (int) $2, (Location) $3, (Location) $3);
- }
- |
- {
- $$ = null;
- }
- ;
interface_event_declaration
: opt_attributes opt_new EVENT type IDENTIFIER SEMICOLON
{
LocatedToken lt = (LocatedToken) $5;
$$ = new EventField (current_class, (Expression) $4, (int) $2, true,
- new MemberName (lt.Value, lt.Location), null,
+ new MemberName (lt.Value, lt.Location),
(Attributes) $1);
if (RootContext.Documentation != null)
((EventField) $$).DocComment = Lexer.consume_doc_comment ();
$$ = null;
}
| opt_attributes opt_new EVENT type IDENTIFIER ASSIGN {
- Report.Error (68, (Location) $3, "`{0}.{1}': event in interface cannot have initializer", current_container.Name, $5);
+ LocatedToken lt = (LocatedToken) $5;
+ Report.Error (68, lt.Location, "`{0}.{1}': event in interface cannot have initializer", current_container.Name, lt.Value);
$$ = null;
}
| opt_attributes opt_new EVENT type IDENTIFIER OPEN_BRACE
OPEN_BRACKET formal_parameter_list CLOSE_BRACKET
OPEN_BRACE
{ lexer.PropertyParsing = true; }
- interface_accessors
- { lexer.PropertyParsing = false; }
+ accessor_declarations
+ {
+ has_get = has_set = false;
+ lexer.PropertyParsing = false;
+ }
CLOSE_BRACE
{
+ Indexer i = null;
if ($10 == null) {
- Indexer i = new Indexer (current_class, (Expression) $3,
- new MemberName (TypeContainer.DefaultIndexerName),
+ i = new Indexer (current_class, (Expression) $3,
+ new MemberName (TypeContainer.DefaultIndexerName, (Location) $4),
(int) $2, true, (Parameters) $6, (Attributes) $1,
null, null);
- Report.Error (548, lexer.Location, "`{0}': property or indexer must have at least one accessor", i.GetSignatureForError ());
+ Report.Error (548, i.Location, "`{0}': property or indexer must have at least one accessor", i.GetSignatureForError ());
break;
}
- InterfaceAccessorInfo info = (InterfaceAccessorInfo) $10;
-
- $$ = new Indexer (current_class, (Expression) $3,
+ Pair pair = (Pair) $10;
+ i = new Indexer (current_class, (Expression) $3,
new MemberName (TypeContainer.DefaultIndexerName, (Location) $4),
(int) $2, true, (Parameters) $6, (Attributes) $1,
- info.Get, info.Set);
+ (Accessor)pair.First, (Accessor)pair.Second);
+
+ if (pair.First != null && ((Accessor)(pair.First)).Block != null) {
+ Report.Error (531, i.Location, "`{0}.get': interface members cannot have a definition", i.GetSignatureForError ());
+ $$ = null;
+ break;
+ }
+
+ if (pair.Second != null && ((Accessor)(pair.Second)).Block != null) {
+ Report.Error (531, i.Location, "`{0}.set': interface members cannot have a definition", i.GetSignatureForError ());
+ $$ = null;
+ break;
+ }
+
if (RootContext.Documentation != null)
- ((Indexer) $$).DocComment = ConsumeStoredComment ();
+ i.DocComment = ConsumeStoredComment ();
+
+ $$ = i;
}
;
Operator op = new Operator (
current_class, decl.optype, decl.ret_type, (int) $2,
- new Parameters (param_list, null),
+ new Parameters (param_list),
(ToplevelBlock) $5, (Attributes) $1, decl.location);
if (RootContext.Documentation != null) {
pars [0] = new Parameter (type, lt.Value, Parameter.Modifier.NONE, null, lt.Location);
- current_local_parameters = new Parameters (pars, null);
+ current_local_parameters = new Parameters (pars);
if (RootContext.Documentation != null) {
tmpComment = Lexer.consume_doc_comment ();
pars [0] = new Parameter (typeL, ltParam1.Value, Parameter.Modifier.NONE, null, ltParam1.Location);
pars [1] = new Parameter (typeR, ltParam2.Value, Parameter.Modifier.NONE, null, ltParam2.Location);
- current_local_parameters = new Parameters (pars, null);
+ current_local_parameters = new Parameters (pars);
if (RootContext.Documentation != null) {
tmpComment = Lexer.consume_doc_comment ();
pars [0] = new Parameter ((Expression) $5, lt.Value, Parameter.Modifier.NONE, null, lt.Location);
- current_local_parameters = new Parameters (pars, null);
+ current_local_parameters = new Parameters (pars);
if (RootContext.Documentation != null) {
tmpComment = Lexer.consume_doc_comment ();
pars [0] = new Parameter ((Expression) $5, lt.Value, Parameter.Modifier.NONE, null, lt.Location);
- current_local_parameters = new Parameters (pars, null);
+ current_local_parameters = new Parameters (pars);
if (RootContext.Documentation != null) {
tmpComment = Lexer.consume_doc_comment ();
Method d = new Destructor (
current_class, TypeManager.system_void_expr, m, "Finalize",
- new Parameters (null, null), (Attributes) $1, l);
+ Parameters.EmptyReadOnlyParameters, (Attributes) $1, l);
if (RootContext.Documentation != null)
d.DocComment = ConsumeStoredComment ();
MemberName name = new MemberName (var.identifier,
var.Location);
- Event e = new EventField (
+ EventField e = new EventField (
current_class, (Expression) $4, (int) $2, false, name,
- var.expression_or_array_initializer, (Attributes) $1);
+ (Attributes) $1);
+
+ e.Initializer = var.expression_or_array_initializer;
current_container.AddEvent (e);
if ($8 == null){
Report.Error (65, (Location) $3, "`{0}.{1}': event property must have both add and remove accessors",
- current_container.Name, name);
+ current_container.Name, name.ToString ());
$$ = null;
} else {
Pair pair = (Pair) $8;
$$ = null;
else {
Event e = new EventProperty (
- current_class, (Expression) $4, (int) $2, false, name, null,
+ current_class, (Expression) $4, (int) $2, false, name,
(Attributes) $1, (Accessor) pair.First, (Accessor) pair.Second);
if (RootContext.Documentation != null) {
e.DocComment = Lexer.consume_doc_comment ();
args [0] = implicit_value_parameter;
- current_local_parameters = new Parameters (args, null);
+ current_local_parameters = new Parameters (args);
lexer.EventParsing = false;
}
block
args [0] = implicit_value_parameter;
- current_local_parameters = new Parameters (args, null);
+ current_local_parameters = new Parameters (args);
lexer.EventParsing = false;
}
block
MemberName name;
if (decl.interface_type != null)
- name = new MemberName (decl.interface_type,
- TypeContainer.DefaultIndexerName, decl.location);
+ name = new MemberName (decl.interface_type, TypeContainer.DefaultIndexerName, loc);
else
- name = new MemberName (TypeContainer.DefaultIndexerName, decl.location);
+ name = new MemberName (TypeContainer.DefaultIndexerName, loc);
indexer = new Indexer (current_class, decl.type, name,
(int) $2, false, decl.param_list, (Attributes) $1,
if (pars.HasArglist) {
// "__arglist is not valid in this context"
Report.Error (1669, (Location) $2, "__arglist is not valid in this context");
- } else if (pars.FixedParameters == null && pars.ArrayParameter == null){
+ } else if (pars.Empty){
Report.Error (1551, (Location) $2, "Indexers must have at least one parameter");
}
if (RootContext.Documentation != null) {
if (pars.HasArglist) {
// "__arglist is not valid in this context"
Report.Error (1669, (Location) $4, "__arglist is not valid in this context");
- } else if (pars.FixedParameters == null && pars.ArrayParameter == null){
+ } else if (pars.Empty){
Report.Error (1551, (Location) $4, "Indexers must have at least one parameter");
}
if (RootContext.Documentation != null)
e.DocComment = enumTypeComment;
+
+ EnumMember em = null;
foreach (VariableDeclaration ev in (ArrayList) $8) {
- e.AddEnumMember (ev.identifier,
- (Expression) ev.expression_or_array_initializer,
- ev.Location, ev.OptAttributes,
- ev.DocComment);
+ em = new EnumMember (e, em, (Expression) ev.expression_or_array_initializer,
+ new MemberName (ev.identifier, ev.Location), ev.OptAttributes);
+
+// if (RootContext.Documentation != null)
+ em.DocComment = ev.DocComment;
+
+ e.AddEnumMember (em);
}
current_container.AddEnum (e);
namespace_or_type_name
: member_name
+ | IDENTIFIER DOUBLE_COLON IDENTIFIER {
+ LocatedToken lt1 = (LocatedToken) $1;
+ LocatedToken lt2 = (LocatedToken) $3;
+ $$ = new MemberName (lt1.Value, lt2.Value, lt2.Location);
+ }
| namespace_or_type_name DOT IDENTIFIER {
LocatedToken lt = (LocatedToken) $3;
$$ = new MemberName ((MemberName) $1, lt.Value);
// can't perform checks during this phase - we do it during
// semantic analysis.
//
- $$ = new ComposedCast ((Expression) $1, "*");
+ $$ = new ComposedCast ((Expression) $1, "*", Lexer.Location);
}
| VOID STAR
{
: builtin_types
| non_expression_type rank_specifier
{
- $$ = new ComposedCast ((Expression) $1, (string) $2);
+ Location loc = GetLocation ($1);
+ if (loc.IsNull)
+ loc = lexer.Location;
+ $$ = new ComposedCast ((Expression) $1, (string) $2, loc);
}
| non_expression_type STAR
{
- $$ = new ComposedCast ((Expression) $1, "*");
+ Location loc = GetLocation ($1);
+ if (loc.IsNull)
+ loc = lexer.Location;
+ $$ = new ComposedCast ((Expression) $1, "*", loc);
}
| expression rank_specifiers
{
array_type
: type rank_specifiers
{
- $$ = new ComposedCast ((Expression) $1, (string) $2);
+ $$ = current_array_type = new ComposedCast ((Expression) $1, (string) $2);
}
;
MemberName mn = (MemberName) $1;
$$ = mn.GetTypeExpression ();
}
+ | IDENTIFIER DOUBLE_COLON IDENTIFIER
+ {
+ LocatedToken lt1 = (LocatedToken) $1;
+ LocatedToken lt2 = (LocatedToken) $3;
+ $$ = new QualifiedAliasMember (lt1.Value, lt2.Value, lt2.Location);
+ }
| parenthesized_expression
| member_access
| invocation_expression
: boolean_literal
| integer_literal
| real_literal
- | LITERAL_CHARACTER { $$ = new CharLiteral ((char) lexer.Value); }
- | LITERAL_STRING { $$ = new StringLiteral ((string) lexer.Value); }
- | NULL { $$ = NullLiteral.Null; }
+ | LITERAL_CHARACTER { $$ = new CharLiteral ((char) lexer.Value, lexer.Location); }
+ | LITERAL_STRING { $$ = new StringLiteral ((string) lexer.Value, lexer.Location); }
+ | NULL { $$ = new NullLiteral (lexer.Location); }
;
real_literal
- : LITERAL_FLOAT { $$ = new FloatLiteral ((float) lexer.Value); }
- | LITERAL_DOUBLE { $$ = new DoubleLiteral ((double) lexer.Value); }
- | LITERAL_DECIMAL { $$ = new DecimalLiteral ((decimal) lexer.Value); }
+ : LITERAL_FLOAT { $$ = new FloatLiteral ((float) lexer.Value, lexer.Location); }
+ | LITERAL_DOUBLE { $$ = new DoubleLiteral ((double) lexer.Value, lexer.Location); }
+ | LITERAL_DECIMAL { $$ = new DecimalLiteral ((decimal) lexer.Value, lexer.Location); }
;
integer_literal
object v = lexer.Value;
if (v is int){
- int i = (int) v;
-
- if (i == 0)
- $$ = IntLiteral.Zero;
- else if (i == 1)
- $$ = IntLiteral.One;
- else
- $$ = new IntLiteral (i);
+ $$ = new IntLiteral ((int) v, lexer.Location);
} else if (v is uint)
- $$ = new UIntLiteral ((UInt32) v);
+ $$ = new UIntLiteral ((UInt32) v, lexer.Location);
else if (v is long)
- $$ = new LongLiteral ((Int64) v);
+ $$ = new LongLiteral ((Int64) v, lexer.Location);
else if (v is ulong)
- $$ = new ULongLiteral ((UInt64) v);
+ $$ = new ULongLiteral ((UInt64) v, lexer.Location);
else
Console.WriteLine ("OOPS. Unexpected result from scanner");
}
;
boolean_literal
- : TRUE { $$ = new BoolLiteral (true); }
- | FALSE { $$ = new BoolLiteral (false); }
+ : TRUE { $$ = new BoolLiteral (true, lexer.Location); }
+ | FALSE { $$ = new BoolLiteral (false, lexer.Location); }
;
parenthesized_expression_0
Expression expr = (Expression) $1;
if (expr is ComposedCast){
$$ = new ComposedCast (expr, (string) $2);
- } else if (!(expr is SimpleName || expr is MemberAccess)){
+ } else if (!(expr is SimpleName || expr is MemberAccess || expr is QualifiedAliasMember)){
Error_ExpectingTypeName (expr);
$$ = TypeManager.system_object_expr;
} else {
//
$$ = new ComposedCast (expr, (string) $2);
}
+ current_array_type = (Expression)$$;
}
;
ArrayList par_list = (ArrayList) $2;
Parameter [] pars = new Parameter [par_list.Count];
par_list.CopyTo (pars);
- $$ = new Parameters (pars, null);
+ $$ = new Parameters (pars);
}
}
;
: cast_list
| OPEN_PARENS non_expression_type CLOSE_PARENS prefixed_unary_expression
{
- $$ = new Cast ((Expression) $2, (Expression) $4);
+ // TODO: wrong location
+ $$ = new Cast ((Expression) $2, (Expression) $4, lexer.Location);
}
;
// Blah i;
Expression expr = (Expression) $1;
- if (!(expr is SimpleName || expr is MemberAccess || expr is ComposedCast)) {
+ if (!(expr is SimpleName || expr is MemberAccess || expr is ComposedCast || expr is QualifiedAliasMember)) {
Error_ExpectingTypeName (expr);
$$ = null;
} else {
if ((string) $2 == "")
$$ = $1;
else
- $$ = new ComposedCast ((Expression) $1, (string) $2);
+ $$ = current_array_type = new ComposedCast ((Expression) $1, (string) $2, lexer.Location);
}
;
{
Expression expr = (Expression) $1;
- if (!(expr is SimpleName || expr is MemberAccess || expr is ComposedCast)) {
+ if (!(expr is SimpleName || expr is MemberAccess || expr is ComposedCast || expr is QualifiedAliasMember)) {
Error_ExpectingTypeName (expr);
$$ = null;
}
| builtin_types STAR
{
- $$ = new ComposedCast ((Expression) $1, "*");
+ $$ = new ComposedCast ((Expression) $1, "*", lexer.Location);
}
| VOID STAR
{
$$ = new If ((Expression) $3, (Statement) $5, l);
- if (RootContext.WarningLevel >= 4){
- if ($5 == EmptyStatement.Value)
- Report.Warning (642, l, "Possible mistaken empty statement");
- }
+ // FIXME: location for warning should be loc property of $5.
+ if ($5 == EmptyStatement.Value)
+ Report.Warning (642, 3, l, "Possible mistaken empty statement");
}
| IF OPEN_PARENS boolean_expression CLOSE_PARENS
Location l = (Location) $1;
$$ = new If ((Expression) $3, (Statement) $5, (Statement) $7, l);
+
+ // FIXME: location for warning should be loc property of $5 and $7.
+ if ($5 == EmptyStatement.Value)
+ Report.Warning (642, 3, l, "Possible mistaken empty statement");
+ if ($7 == EmptyStatement.Value)
+ Report.Warning (642, 3, l, "Possible mistaken empty statement");
}
;
{
Location l = (Location) $1;
$$ = new While ((Expression) $3, (Statement) $5, l);
-
- if (RootContext.WarningLevel >= 4){
- if ($5 == EmptyStatement.Value)
- Report.Warning (642, l, "Possible mistaken empty statement");
- }
}
;
continue;
Location l = lexer.Location;
- Expression expr;
- if (decl.expression_or_array_initializer is Expression){
- expr = (Expression) decl.expression_or_array_initializer;
- } else if (decl.expression_or_array_initializer == null) {
- expr = null;
- } else {
- ArrayList init = (ArrayList) decl.expression_or_array_initializer;
- expr = new ArrayCreation (type, "", init, decl.Location);
- }
+ Expression expr = decl.expression_or_array_initializer;
LocalVariableReference var;
var = new LocalVariableReference (assign_block, decl.identifier, l);
For f = new For ((Statement) $5, (Expression) $6, (Statement) $8, (Statement) $10, l);
- if (RootContext.WarningLevel >= 4){
- if ($10 == EmptyStatement.Value)
- Report.Warning (642, (Location) $4, "Possible mistaken empty statement");
- }
-
current_block.AddStatement (f);
while (current_block.Implicit)
current_block = current_block.Parent;
: statement_expression
{
// CHANGE: was `null'
- Block b = new Block (current_block, Block.Flags.Implicit);
+ Statement s = (Statement) $1;
+ Block b = new Block (current_block, Block.Flags.Implicit, s.loc, lexer.Location);
- b.AddStatement ((Statement) $1);
+ b.AddStatement (s);
$$ = b;
}
| statement_expression_list COMMA statement_expression
: CATCH opt_catch_args
{
Expression type = null;
- string id = null;
if ($2 != null) {
DictionaryEntry cc = (DictionaryEntry) $2;
Fixed f = new Fixed ((Expression) $3, (ArrayList) $4, (Statement) $7, l);
- if (RootContext.WarningLevel >= 4){
- if ($7 == EmptyStatement.Value)
- Report.Warning (642, l, "Possible mistaken empty statement");
- }
-
current_block.AddStatement (f);
while (current_block.Implicit)
current_block = current_block.Parent;
continue;
vi.SetReadOnlyContext (LocalInfo.ReadOnlyContext.Using);
- Expression expr;
- if (decl.expression_or_array_initializer is Expression){
- expr = (Expression) decl.expression_or_array_initializer;
- } else {
- ArrayList init = (ArrayList) decl.expression_or_array_initializer;
- if (init == null) {
- Report.Error (210, l, "You must provide an initializer in a fixed or using statement declaration");
- }
-
- expr = new ArrayCreation (type, "", init, decl.Location);
+ Expression expr = decl.expression_or_array_initializer;
+ if (expr == null) {
+ Report.Error (210, l, "You must provide an initializer in a fixed or using statement declaration");
}
LocalVariableReference var;
// </summary>
public class VariableDeclaration {
public string identifier;
- public object expression_or_array_initializer;
+ public Expression expression_or_array_initializer;
public Location Location;
public Attributes OptAttributes;
public string DocComment;
public VariableDeclaration (LocatedToken lt, object eoai, Attributes opt_attrs)
{
this.identifier = lt.Value;
- this.expression_or_array_initializer = eoai;
+ if (eoai is ArrayList) {
+ if (CSharpParser.current_array_type == null)
+ Report.Error (622, lt.Location,
+ "Can only use array initializer expressions to assign to array types. Try using a new expression instead.");
+ this.expression_or_array_initializer = new ArrayCreation (CSharpParser.current_array_type, "", (ArrayList)eoai, lt.Location);
+ } else {
+ this.expression_or_array_initializer = (Expression)eoai;
+ }
+ CSharpParser.current_array_type = null;
this.Location = lt.Location;
this.OptAttributes = opt_attrs;
}
}
}
-/// <summary>
-/// Used to pass around interface property information
-/// </summary>
-public class InterfaceAccessorInfo {
-
- public readonly Accessor Get, Set;
-
- public InterfaceAccessorInfo (bool has_get, bool has_set,
- Attributes get_attrs, Attributes set_attrs, int get_mod, int set_mod, Location get_loc, Location set_loc)
- {
- if (has_get)
- Get = new Accessor (null, get_mod, get_attrs, get_loc);
- if (has_set)
- Set = new Accessor (null, set_mod, set_attrs, set_loc);
- }
-
-}
-
-
// <summary>
// A class used to hold info about an indexer declarator
// </summary>
if (expr is Invocation){
Report.Error (1002, expr.Location, "Expecting `;'");
} else {
- Report.Error (-1, expr.Location, "Invalid Type definition");
+ Report.Error (201, expr.Location, "Only assignment, call, increment, decrement, and new object expressions can be used as a statement");
}
}
{
TypeContainer retval = current_class;
- current_class = current_class.Parent;
- current_container = current_container.Parent;
-
+ current_class = (TypeContainer) current_class.Parent;
+ current_container = (TypeContainer) current_container.Parent;
+
if (current_class != current_container) {
- if (!(current_class is ClassPart) ||
- ((ClassPart) current_class).PartialContainer != current_container)
- throw new InternalErrorException ();
+ if (((ClassPart) current_class).PartialContainer != current_container)
+ throw new InternalErrorException ("current_container and current_class are out of sync");
} else if (current_container is ClassPart)
current_container = ((ClassPart) current_class).PartialContainer;
foreach (VariableDeclaration decl in inits){
Assign assign;
- Expression expr;
+ Expression expr = decl.expression_or_array_initializer;
- if (decl.expression_or_array_initializer is Expression){
- expr = (Expression) decl.expression_or_array_initializer;
-
- } else {
- ArrayList init = (ArrayList) decl.expression_or_array_initializer;
-
- expr = new ArrayCreation (type, "", init, decl.Location);
- }
-
LocalVariableReference var;
var = new LocalVariableReference (implicit_block, decl.identifier, loc);