/// 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");
;
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);
catch_args
: OPEN_PARENS type opt_identifier CLOSE_PARENS
{
- if ($2 is ATypeNameExpression || $2 == TypeManager.system_object_expr || $2 == TypeManager.system_string_expr) {
- $$ = new DictionaryEntry ($2, $3);
- } else {
- Error_InvalidCatchType (GetLocation ($2));
- }
+ $$ = new DictionaryEntry ($2, $3);
}
| OPEN_PARENS CLOSE_PARENS
{
- Error_InvalidCatchType (GetLocation ($1));
+ Report.Error (1015, GetLocation ($1), "A type that derives from `System.Exception', `object', or `string' expected");
}
;
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);
- }
}
}
}
}
-static void Error_InvalidCatchType (Location loc)
-{
- Report.Error (1015, loc, "A type that derives from `System.Exception', `object', or `string' expected");
-}
-
static void Error_ParameterModifierNotValid (string modifier, Location loc)
{
Report.Error (631, loc, "The parameter modifier `{0}' is not valid in this context",
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;
}