Browse Source

Updated mcs.

newNRvisualizers
Mike Krüger 13 years ago
parent
commit
7478e22d60
  1. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs
  2. 9607
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs
  3. 267
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay

2
ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs

@ -1453,7 +1453,7 @@ namespace Mono.CSharp {
} }
} }
protected ParametersBlock block; protected readonly ParametersBlock block;
public TypeSpec ReturnType; public TypeSpec ReturnType;

9607
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs

File diff suppressed because it is too large Load Diff

267
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay

@ -3255,7 +3255,13 @@ invocation_expression
$$ = new Invocation ((Expression) $1, (Arguments) $3); $$ = new Invocation ((Expression) $1, (Arguments) $3);
lbag.AddLocation ($$, GetLocation ($2)); lbag.AddLocation ($$, GetLocation ($2));
} }
| primary_expression open_parens_any error
{
Error_SyntaxError (yyToken);
$$ = new Invocation ((Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
; ;
opt_object_or_collection_initializer opt_object_or_collection_initializer
@ -3857,6 +3863,13 @@ sizeof_expression
$$ = new SizeOf ((Expression) $3, GetLocation ($1)); $$ = new SizeOf ((Expression) $3, GetLocation ($1));
lbag.AddLocation ($$, GetLocation ($2), GetLocation ($4)); lbag.AddLocation ($$, GetLocation ($2), GetLocation ($4));
} }
| SIZEOF open_parens_any type error
{
Error_SyntaxError (yyToken);
$$ = new SizeOf ((Expression) $3, GetLocation ($1));
lbag.AddLocation ($$, GetLocation ($2));
}
; ;
checked_expression checked_expression
@ -3865,6 +3878,12 @@ checked_expression
$$ = new CheckedExpr ((Expression) $3, GetLocation ($1)); $$ = new CheckedExpr ((Expression) $3, GetLocation ($1));
lbag.AddLocation ($$, GetLocation ($2), GetLocation ($4)); lbag.AddLocation ($$, GetLocation ($2), GetLocation ($4));
} }
| CHECKED error
{
Error_SyntaxError (yyToken);
$$ = new CheckedExpr (null, GetLocation ($1));
}
; ;
unchecked_expression unchecked_expression
@ -3873,6 +3892,12 @@ unchecked_expression
$$ = new UnCheckedExpr ((Expression) $3, GetLocation ($1)); $$ = new UnCheckedExpr ((Expression) $3, GetLocation ($1));
lbag.AddLocation ($$, GetLocation ($2), GetLocation ($4)); lbag.AddLocation ($$, GetLocation ($2), GetLocation ($4));
} }
| UNCHECKED error
{
Error_SyntaxError (yyToken);
$$ = new UnCheckedExpr (null, GetLocation ($1));
}
; ;
pointer_member_access pointer_member_access
@ -3980,6 +4005,31 @@ unary_expression
$$ = new Await ((Expression) $2, GetLocation ($1)); $$ = new Await ((Expression) $2, GetLocation ($1));
} }
| BANG error
{
Error_SyntaxError (yyToken);
$$ = new Unary (Unary.Operator.LogicalNot, null, GetLocation ($1));
}
| TILDE error
{
Error_SyntaxError (yyToken);
$$ = new Unary (Unary.Operator.OnesComplement, null, GetLocation ($1));
}
| OPEN_PARENS_CAST type CLOSE_PARENS error
{
Error_SyntaxError (yyToken);
$$ = new Cast ((FullNamedExpression) $2, null, GetLocation ($1));
lbag.AddLocation ($$, GetLocation ($3));
}
| AWAIT error
{
Error_SyntaxError (yyToken);
$$ = new Await (null, GetLocation ($1));
}
; ;
// //
@ -4012,6 +4062,42 @@ prefixed_unary_expression
{ {
$$ = new Unary (Unary.Operator.AddressOf, (Expression) $2, GetLocation ($1)); $$ = new Unary (Unary.Operator.AddressOf, (Expression) $2, GetLocation ($1));
} }
| PLUS error
{
Error_SyntaxError (yyToken);
$$ = new Unary (Unary.Operator.UnaryPlus, null, GetLocation ($1));
}
| MINUS error
{
Error_SyntaxError (yyToken);
$$ = new Unary (Unary.Operator.UnaryNegation, null, GetLocation ($1));
}
| OP_INC error
{
Error_SyntaxError (yyToken);
$$ = new UnaryMutator (UnaryMutator.Mode.PreIncrement, null, GetLocation ($1));
}
| OP_DEC error
{
Error_SyntaxError (yyToken);
$$ = new UnaryMutator (UnaryMutator.Mode.PreDecrement, null, GetLocation ($1));
}
| STAR error
{
Error_SyntaxError (yyToken);
$$ = new Indirection (null, GetLocation ($1));
}
| BITWISE_AND error
{
Error_SyntaxError (yyToken);
$$ = new Unary (Unary.Operator.AddressOf, null, GetLocation ($1));
}
; ;
multiplicative_expression multiplicative_expression
@ -4031,6 +4117,27 @@ multiplicative_expression
$$ = new Binary (Binary.Operator.Modulus, (Expression) $1, (Expression) $3); $$ = new Binary (Binary.Operator.Modulus, (Expression) $1, (Expression) $3);
lbag.AddLocation ($$, GetLocation ($2)); lbag.AddLocation ($$, GetLocation ($2));
} }
| multiplicative_expression STAR error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.Multiply, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
| multiplicative_expression DIV error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.Division, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
| multiplicative_expression PERCENT error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.Modulus, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
; ;
additive_expression additive_expression
@ -4053,6 +4160,32 @@ additive_expression
{ {
$$ = new Is ((Expression) $1, (Expression) $3, GetLocation ($2)); $$ = new Is ((Expression) $1, (Expression) $3, GetLocation ($2));
} }
| additive_expression PLUS error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.Addition, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
| additive_expression MINUS error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.Subtraction, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
| additive_expression AS error
{
Error_SyntaxError (yyToken);
$$ = new As ((Expression) $1, null, GetLocation ($2));
}
| additive_expression IS error
{
Error_SyntaxError (yyToken);
$$ = new Is ((Expression) $1, null, GetLocation ($2));
}
; ;
shift_expression shift_expression
@ -4067,6 +4200,20 @@ shift_expression
$$ = new Binary (Binary.Operator.RightShift, (Expression) $1, (Expression) $3); $$ = new Binary (Binary.Operator.RightShift, (Expression) $1, (Expression) $3);
lbag.AddLocation ($$, GetLocation ($2)); lbag.AddLocation ($$, GetLocation ($2));
} }
| shift_expression OP_SHIFT_LEFT error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.LeftShift, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
| shift_expression OP_SHIFT_RIGHT error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.RightShift, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
; ;
relational_expression relational_expression
@ -4091,6 +4238,34 @@ relational_expression
$$ = new Binary (Binary.Operator.GreaterThanOrEqual, (Expression) $1, (Expression) $3); $$ = new Binary (Binary.Operator.GreaterThanOrEqual, (Expression) $1, (Expression) $3);
lbag.AddLocation ($$, GetLocation ($2)); lbag.AddLocation ($$, GetLocation ($2));
} }
| relational_expression OP_LT error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.LessThan, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
| relational_expression OP_GT error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.GreaterThan, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
| relational_expression OP_LE error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.LessThanOrEqual, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
| relational_expression OP_GE error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.GreaterThanOrEqual, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
; ;
equality_expression equality_expression
@ -4105,6 +4280,20 @@ equality_expression
$$ = new Binary (Binary.Operator.Inequality, (Expression) $1, (Expression) $3); $$ = new Binary (Binary.Operator.Inequality, (Expression) $1, (Expression) $3);
lbag.AddLocation ($$, GetLocation ($2)); lbag.AddLocation ($$, GetLocation ($2));
} }
| equality_expression OP_EQ error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.Equality, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
| equality_expression OP_NE error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.Inequality, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
; ;
and_expression and_expression
@ -4114,6 +4303,13 @@ and_expression
$$ = new Binary (Binary.Operator.BitwiseAnd, (Expression) $1, (Expression) $3); $$ = new Binary (Binary.Operator.BitwiseAnd, (Expression) $1, (Expression) $3);
lbag.AddLocation ($$, GetLocation ($2)); lbag.AddLocation ($$, GetLocation ($2));
} }
| and_expression BITWISE_AND error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.BitwiseAnd, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
; ;
exclusive_or_expression exclusive_or_expression
@ -4123,6 +4319,13 @@ exclusive_or_expression
$$ = new Binary (Binary.Operator.ExclusiveOr, (Expression) $1, (Expression) $3); $$ = new Binary (Binary.Operator.ExclusiveOr, (Expression) $1, (Expression) $3);
lbag.AddLocation ($$, GetLocation ($2)); lbag.AddLocation ($$, GetLocation ($2));
} }
| exclusive_or_expression CARRET error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.ExclusiveOr, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
; ;
inclusive_or_expression inclusive_or_expression
@ -4132,6 +4335,13 @@ inclusive_or_expression
$$ = new Binary (Binary.Operator.BitwiseOr, (Expression) $1, (Expression) $3); $$ = new Binary (Binary.Operator.BitwiseOr, (Expression) $1, (Expression) $3);
lbag.AddLocation ($$, GetLocation ($2)); lbag.AddLocation ($$, GetLocation ($2));
} }
| inclusive_or_expression BITWISE_OR error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.BitwiseOr, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
; ;
conditional_and_expression conditional_and_expression
@ -4141,6 +4351,13 @@ conditional_and_expression
$$ = new Binary (Binary.Operator.LogicalAnd, (Expression) $1, (Expression) $3); $$ = new Binary (Binary.Operator.LogicalAnd, (Expression) $1, (Expression) $3);
lbag.AddLocation ($$, GetLocation ($2)); lbag.AddLocation ($$, GetLocation ($2));
} }
| conditional_and_expression OP_AND error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.LogicalAnd, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
; ;
conditional_or_expression conditional_or_expression
@ -4150,6 +4367,13 @@ conditional_or_expression
$$ = new Binary (Binary.Operator.LogicalOr, (Expression) $1, (Expression) $3); $$ = new Binary (Binary.Operator.LogicalOr, (Expression) $1, (Expression) $3);
lbag.AddLocation ($$, GetLocation ($2)); lbag.AddLocation ($$, GetLocation ($2));
} }
| conditional_or_expression OP_OR error
{
Error_SyntaxError (yyToken);
$$ = new Binary (Binary.Operator.LogicalOr, (Expression) $1, null);
lbag.AddLocation ($$, GetLocation ($2));
}
; ;
null_coalescing_expression null_coalescing_expression
@ -4166,7 +4390,7 @@ null_coalescing_expression
conditional_expression conditional_expression
: null_coalescing_expression : null_coalescing_expression
| null_coalescing_expression INTERR expression COLON expression_or_error | null_coalescing_expression INTERR expression COLON expression
{ {
$$ = new Conditional (new BooleanExpression ((Expression) $1), (Expression) $3, (Expression) $5, GetLocation ($2)); $$ = new Conditional (new BooleanExpression ((Expression) $1), (Expression) $3, (Expression) $5, GetLocation ($2));
lbag.AddLocation ($$, GetLocation ($4)); lbag.AddLocation ($$, GetLocation ($4));
@ -4174,7 +4398,15 @@ conditional_expression
| null_coalescing_expression INTERR expression error | null_coalescing_expression INTERR expression error
{ {
Error_SyntaxError (yyToken); Error_SyntaxError (yyToken);
$$ = new Conditional (new BooleanExpression ((Expression) $1), (Expression) $3, null, GetLocation ($2));
}
| null_coalescing_expression INTERR expression COLON error
{
Error_SyntaxError (yyToken);
$$ = new Conditional (new BooleanExpression ((Expression) $1), (Expression) $3, null, GetLocation ($2)); $$ = new Conditional (new BooleanExpression ((Expression) $1), (Expression) $3, null, GetLocation ($2));
lbag.AddLocation ($$, GetLocation ($4));
} }
; ;
@ -4289,32 +4521,36 @@ opt_lambda_parameter_list
; ;
lambda_expression_body lambda_expression_body
: lambda_expression_body_simple
| block
;
lambda_expression_body_simple
: { : {
start_block (Location.Null); start_block (Location.Null);
} }
expression_or_error // Have to close block when error occurs expression // All expressions must handle error or current block won't be restored and breaking ast completely
{ {
Block b = end_block (Location.Null); Block b = end_block (Location.Null);
b.IsCompilerGenerated = true; b.IsCompilerGenerated = true;
b.AddStatement (new ContextualReturn ((Expression) $2)); b.AddStatement (new ContextualReturn ((Expression) $2));
$$ = b; $$ = b;
} }
| block
| error
{
// Handles only cases like foo = x.FirstOrDefault (l => );
// where we must restore current_variable
Error_SyntaxError (yyToken);
$$ = null;
}
; ;
expression_or_error expression_or_error
: expression : expression
| error | error
{ {
Error_SyntaxError (yyToken); Error_SyntaxError (yyToken);
$$ = EmptyExpression.Null; $$ = null;
} }
; ;
lambda_expression lambda_expression
: IDENTIFIER ARROW : IDENTIFIER ARROW
{ {
@ -5871,6 +6107,8 @@ catch_clause
{ {
Error_SyntaxError (yyToken); Error_SyntaxError (yyToken);
// Required otherwise missing block could not be detected because
// start_block is run early
var c = new Catch (null, GetLocation ($1)); var c = new Catch (null, GetLocation ($1));
c.TypeExpression = (FullNamedExpression) $3; c.TypeExpression = (FullNamedExpression) $3;
@ -5879,6 +6117,11 @@ catch_clause
c.Variable = new LocalVariable (current_block, lt.Value, lt.Location); c.Variable = new LocalVariable (current_block, lt.Value, lt.Location);
} }
if ($4 != null) {
var lt = (Tokenizer.LocatedToken) $4;
c.Variable = new LocalVariable (current_block, lt.Value, lt.Location);
}
lbag.AddLocation (c, GetLocation ($2), GetLocation ($5)); lbag.AddLocation (c, GetLocation ($2), GetLocation ($5));
$$ = c; $$ = c;

Loading…
Cancel
Save