accessor_body
{
if (has_get) {
- Report.Error (1007, (Location) $3, "Property accessor already defined");
+ Report.Error (1007, GetLocation ($3), "Property accessor already defined");
break;
}
Accessor accessor = new Accessor ((ToplevelBlock) $5, (int) $2, (Attributes) $1, current_local_parameters, (Location) $3);
accessor_body
{
if (has_set) {
- Report.Error (1007, ((LocatedToken) $3).Location, "Property accessor already defined");
+ Report.Error (1007, GetLocation ($3), "Property accessor already defined");
break;
}
Accessor accessor = new Accessor ((ToplevelBlock) $5, (int) $2, (Attributes) $1, current_local_parameters, (Location) $3);
}
| IMPLICIT error
{
- syntax_error ((Location) $1, "'operator' expected");
+ Error_SyntaxError (yyToken);
+ $$ = new OperatorDeclaration (Operator.OpType.Implicit, null, GetLocation ($1));
}
| EXPLICIT error
{
- syntax_error ((Location) $1, "'operator' expected");
+ Error_SyntaxError (yyToken);
+ $$ = new OperatorDeclaration (Operator.OpType.Explicit, null, GetLocation ($1));
}
;
/*
* replaces all the productions for isolating the various
- * simple types, but we need this to reuse it easily in local_variable_type
+ * simple types, but we need this to reuse it easily in variable_type
*/
builtin_types
: OBJECT { $$ = TypeManager.system_object_expr; }
post_increment_expression
: primary_expression OP_INC
{
- $$ = new UnaryMutator (UnaryMutator.Mode.PostIncrement,
- (Expression) $1, (Location) $2);
+ $$ = new UnaryMutator (UnaryMutator.Mode.PostIncrement, (Expression) $1);
}
;
post_decrement_expression
: primary_expression OP_DEC
{
- $$ = new UnaryMutator (UnaryMutator.Mode.PostDecrement,
- (Expression) $1, (Location) $2);
+ $$ = new UnaryMutator (UnaryMutator.Mode.PostDecrement, (Expression) $1);
}
;
}
block
{
- $$ = end_anonymous ((ToplevelBlock) $4, (Location) $1);
+ $$ = end_anonymous ((ToplevelBlock) $4);
}
;
: primary_expression
| BANG prefixed_unary_expression
{
- $$ = new Unary (Unary.Operator.LogicalNot, (Expression) $2, (Location) $1);
+ $$ = new Unary (Unary.Operator.LogicalNot, (Expression) $2);
}
| TILDE prefixed_unary_expression
{
- $$ = new Unary (Unary.Operator.OnesComplement, (Expression) $2, (Location) $1);
+ $$ = new Unary (Unary.Operator.OnesComplement, (Expression) $2);
}
| cast_expression
;
: unary_expression
| PLUS prefixed_unary_expression
{
- $$ = new Unary (Unary.Operator.UnaryPlus, (Expression) $2, (Location) $1);
+ $$ = new Unary (Unary.Operator.UnaryPlus, (Expression) $2);
}
| MINUS prefixed_unary_expression
{
- $$ = new Unary (Unary.Operator.UnaryNegation, (Expression) $2, (Location) $1);
+ $$ = new Unary (Unary.Operator.UnaryNegation, (Expression) $2);
}
| OP_INC prefixed_unary_expression
{
- $$ = new UnaryMutator (UnaryMutator.Mode.PreIncrement,
- (Expression) $2, (Location) $1);
+ $$ = new UnaryMutator (UnaryMutator.Mode.PreIncrement, (Expression) $2);
}
| OP_DEC prefixed_unary_expression
{
- $$ = new UnaryMutator (UnaryMutator.Mode.PreDecrement,
- (Expression) $2, (Location) $1);
+ $$ = new UnaryMutator (UnaryMutator.Mode.PreDecrement, (Expression) $2);
}
| STAR prefixed_unary_expression
{
- $$ = new Indirection ((Expression) $2, (Location) $1);
+ $$ = new Indirection ((Expression) $2, GetLocation ($1));
}
| BITWISE_AND prefixed_unary_expression
{
- $$ = new Unary (Unary.Operator.AddressOf, (Expression) $2, (Location) $1);
+ $$ = new Unary (Unary.Operator.AddressOf, (Expression) $2);
}
;
{
LocatedToken lt = (LocatedToken) $1;
Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location);
- start_anonymous (true, new Parameters (p), (Location) $2);
+ start_anonymous (true, new Parameters (p), GetLocation ($1));
}
lambda_expression_body
{
- $$ = end_anonymous ((ToplevelBlock) $4, (Location) $2);
+ $$ = end_anonymous ((ToplevelBlock) $4);
}
| OPEN_PARENS_LAMBDA opt_lambda_parameter_list CLOSE_PARENS ARROW
{
- start_anonymous (true, (Parameters) $2, (Location) $4);
+ start_anonymous (true, (Parameters) $2, GetLocation ($1));
}
lambda_expression_body
{
- $$ = end_anonymous ((ToplevelBlock) $6, (Location) $4);
+ $$ = end_anonymous ((ToplevelBlock) $6);
}
;
* > expressions to prevent reduce/reduce errors in the grammar.
* > The expressions are converted into types during semantic analysis.
*/
-local_variable_type
+variable_type
: primary_expression_no_array_creation opt_rank_specifier_or_nullable
{
// FIXME: Do something smart here regarding the composition of the type.
}
| builtin_types STAR
{
- $$ = new ComposedCast ((FullNamedExpression) $1, "*", lexer.Location);
+ $$ = new ComposedCast ((FullNamedExpression) $1, "*", GetLocation ($1));
}
| VOID STAR
{
}
;
+local_variable_type
+ : variable_type
+ | local_variable_pointer_type opt_rank_specifier
+ {
+ if ($1 != null){
+ string rank = (string)$2;
+
+ if (rank == "")
+ $$ = $1;
+ else
+ $$ = current_array_type = new ComposedCast ((FullNamedExpression) $1, rank);
+ } else {
+ $$ = null;
+ }
+ }
+ ;
+
local_variable_declaration
: local_variable_type local_variable_declarators
{
} else
$$ = null;
}
- | local_variable_pointer_type opt_rank_specifier local_variable_declarators
- {
- if ($1 != null){
- Expression t;
-
- if ((string) $2 == "")
- t = (Expression) $1;
- else
- t = new ComposedCast ((FullNamedExpression) $1, (string) $2);
- $$ = new DictionaryEntry (t, $3);
- } else
- $$ = null;
- }
;
local_constant_declaration
- : CONST local_variable_type constant_declarators
+ : CONST variable_type constant_declarators
{
if ($2 != null)
$$ = new DictionaryEntry ($2, $3);
if (s == null) {
expr.Error_InvalidExpressionStatement ();
- $$ = null;
- } else {
- $$ = new StatementExpression (s);
}
+
+ $$ = new StatementExpression (s);
}
| error
{
void
start_anonymous (bool lambda, Parameters parameters, Location loc)
{
+ if (RootContext.Version == LanguageVersion.ISO_1){
+ Report.FeatureIsNotAvailable (loc, "anonymous methods");
+ }
+
oob_stack.Push (current_anonymous_method);
oob_stack.Push (current_local_parameters);
* 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)
{
AnonymousMethodExpression retval;
- if (RootContext.Version == LanguageVersion.ISO_1){
- Report.FeatureIsNotAvailable (loc, "anonymous methods");
- retval = null;
- } else {
- current_anonymous_method.Block = anon_block;
- retval = current_anonymous_method;
- }
+ current_anonymous_method.Block = anon_block;
+ retval = current_anonymous_method;
current_local_parameters = (Parameters) oob_stack.Pop ();
current_anonymous_method = (AnonymousMethodExpression) oob_stack.Pop ();