/// This is used by the unary_expression code to resolve
/// a name against a parameter.
/// </summary>
+
+ // FIXME: This is very ugly and it's very hard to reset it correctly
+ // on all places, especially when some parameters are autogenerated.
Parameters current_local_parameters;
/// <summary>
///
/// The current file.
///
- SourceFile file;
+ CompilationUnit file;
///
/// Temporary Xml documentation cache.
current_local_parameters = new Parameters (args);
lexer.EventParsing = false;
}
- block
+ block
{
$$ = new Accessor ((ToplevelBlock) $4, 0, (Attributes) $1, (Location) $2);
lexer.EventParsing = true;
+ current_local_parameters = null;
}
| opt_attributes REMOVE error {
Report.Error (73, (Location) $2, "An add or remove accessor must have a body");
if ((bool) $2) {
$$ = new ComposedCast (name.GetTypeExpression (), "?", lexer.Location);
} else {
- if (RootContext.Version > LanguageVersion.ISO_2 && name.Name == "var")
+ if (RootContext.Version > LanguageVersion.ISO_2 && name.Left == null && name.Name == "var")
$$ = new VarExpr (name.Location);
else
$$ = name.GetTypeExpression ();
;
anonymous_type_expression
- : NEW OPEN_BRACE anonymous_type_parameters CLOSE_BRACE
+ : NEW OPEN_BRACE anonymous_type_parameters_opt_comma CLOSE_BRACE
{
if (RootContext.Version <= LanguageVersion.ISO_2)
Report.FeatureIsNotAvailable (GetLocation ($1), "anonymous types");
}
;
-anonymous_type_parameters
+anonymous_type_parameters_opt_comma
+ : anonymous_type_parameters_opt
+ | anonymous_type_parameters COMMA
+ ;
+
+anonymous_type_parameters_opt
: { $$ = null; }
- | anonymous_type_parameter
+ | anonymous_type_parameters
+ ;
+
+anonymous_type_parameters
+ : anonymous_type_parameter
{
ArrayList a = new ArrayList (4);
a.Add ($1);
assignment_expression
: prefixed_unary_expression ASSIGN expression
{
- $$ = new Assign ((Expression) $1, (Expression) $3);
+ $$ = new SimpleAssign ((Expression) $1, (Expression) $3);
}
| prefixed_unary_expression OP_MULT_ASSIGN expression
{
var = new LocalVariableReference (assign_block, decl.identifier, l);
if (expr != null) {
- Assign a = new Assign (var, expr, decl.Location);
+ Assign a = new SimpleAssign (var, expr, decl.Location);
assign_block.AddStatement (new StatementExpression (a));
}
opt_catch_args
: /* empty */ { $$ = null; }
- | catch_args
+ | catch_args
;
catch_args
- : open_parens type opt_identifier CLOSE_PARENS
- {
+ : OPEN_PARENS type opt_identifier CLOSE_PARENS
+ {
$$ = new DictionaryEntry ($2, $3);
}
- ;
-
+ | OPEN_PARENS CLOSE_PARENS
+ {
+ Report.Error (1015, GetLocation ($1), "A type that derives from `System.Exception', `object', or `string' expected");
+ }
+ ;
checked_statement
: CHECKED block
vars.Push (new DictionaryEntry (var, expr));
- // Assign a = new Assign (var, expr, decl.Location);
+ // Assign a = new SimpleAssign (var, expr, decl.Location);
// assign_block.AddStatement (new StatementExpression (a));
}
public static readonly SimpleAnonymousHost Simple = new SimpleAnonymousHost ();
bool yields;
- ArrayList anonymous_methods;
public static SimpleAnonymousHost GetSimple () {
Simple.yields = false;
- Simple.anonymous_methods = null;
return Simple;
}
{
yields = true;
}
-
- public void AddAnonymousMethod (AnonymousMethodExpression anonymous)
- {
- if (anonymous_methods == null)
- anonymous_methods = new ArrayList ();
- anonymous_methods.Add (anonymous);
- }
-
+
public void Propagate (IAnonymousHost real_host)
{
if (yields)
real_host.SetYields ();
- if (anonymous_methods != null) {
- foreach (AnonymousMethodExpression ame in anonymous_methods)
- real_host.AddAnonymousMethod (ame);
- }
}
}
LocalVariableReference var;
var = new LocalVariableReference (implicit_block, decl.identifier, loc);
- assign = new Assign (var, expr, decl.Location);
+ assign = new SimpleAssign (var, expr, decl.Location);
implicit_block.AddStatement (new StatementExpression (assign));
}
oob_stack = new Stack ();
}
-public CSharpParser (SeekableStreamReader reader, SourceFile file, ArrayList defines)
+public CSharpParser (SeekableStreamReader reader, CompilationUnit file, ArrayList defines)
{
this.file = file;
current_namespace = new NamespaceEntry (null, file, null);
current_local_parameters = parameters;
- ToplevelBlock top_current_block = current_block == null ? null : current_block.Toplevel;
-
current_anonymous_method = lambda
- ? new LambdaExpression (
- current_anonymous_method, current_generic_method, current_container,
- parameters, top_current_block, loc)
- : new AnonymousMethodExpression (
- current_anonymous_method, current_generic_method, current_container,
- parameters, top_current_block, loc);
+ ? new LambdaExpression (current_container, parameters, loc)
+ : new AnonymousMethodExpression (current_container, parameters, loc);
// Force the next block to be created as a ToplevelBlock
parsing_anonymous_method = true;
* Completes the anonymous method processing, if lambda_expr is null, this
* means that we have a Statement instead of an Expression embedded
*/
-AnonymousMethodExpression
-end_anonymous (ToplevelBlock anon_block, Location loc)
+AnonymousMethodExpression end_anonymous (ToplevelBlock anon_block, Location loc)
{
AnonymousMethodExpression retval;
retval = null;
} else {
current_anonymous_method.Block = anon_block;
- if ((anonymous_host != null) && (current_anonymous_method.Parent == null))
- anonymous_host.AddAnonymousMethod (current_anonymous_method);
-
retval = current_anonymous_method;
}