@ -362,7 +362,9 @@ TypeDecl<ModifierList m, List<AttributeSection> attributes>
{ TypeParameterConstraintsClause<templates> }
{ TypeParameterConstraintsClause<templates> }
(. newType.BodyStartLocation = t.EndLocation; .)
(. newType.BodyStartLocation = t.EndLocation; .)
"{" ClassBody "}"
"{"
ClassBody
"}"
[ ";" ] (. newType.EndLocation = t.Location;
[ ";" ] (. newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
compilationUnit.BlockEnd();
.)
.)
@ -478,6 +480,7 @@ ClassBody
{ (.List<AttributeSection> attributes = new List<AttributeSection>();
{ (.List<AttributeSection> attributes = new List<AttributeSection>();
ModifierList m = new ModifierList();
ModifierList m = new ModifierList();
.)
.)
SYNC
{ AttributeSection<out section> (. attributes.Add(section); .) }
{ AttributeSection<out section> (. attributes.Add(section); .) }
MemberModifiers<m>
MemberModifiers<m>
ClassMemberDecl<m, attributes>
ClassMemberDecl<m, attributes>
@ -520,7 +523,7 @@ InterfaceBase<out List<TypeReference> names>
InterfaceBody
InterfaceBody
= "{"
= "{"
{ InterfaceMemberDecl }
{ SYNC InterfaceMemberDecl }
"}"
"}"
.
.
@ -531,7 +534,8 @@ EnumBody (. FieldDeclaration f; .)
{ IF (NotFinalComma()) ","
{ IF (NotFinalComma()) ","
EnumMemberDecl<out f> (. compilationUnit.AddChild(f); .)
EnumMemberDecl<out f> (. compilationUnit.AddChild(f); .)
}
}
[","] ] "}"
[","] ]
"}"
.
.
Type<out TypeReference type>
Type<out TypeReference type>
@ -1326,7 +1330,8 @@ Argument<out Expression argumentexpr>
"ref" (. fd = FieldDirection.Ref; .)
"ref" (. fd = FieldDirection.Ref; .)
| "out" (. fd = FieldDirection.Out; .)
| "out" (. fd = FieldDirection.Out; .)
]
]
Expr<out expr> (. argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; .)
Expr<out expr>
(. argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; .)
.
.
AssignmentOperator<out AssignmentOperatorType op>
AssignmentOperator<out AssignmentOperatorType op>
@ -1415,7 +1420,8 @@ LocalVariableDecl<out Statement stmt>
LocalVariableDeclarator<out VariableDeclaration var>
LocalVariableDeclarator<out VariableDeclaration var>
(. Expression expr = null; .)
(. Expression expr = null; .)
=
=
Identifier (. var = new VariableDeclaration(t.val); .) [ "=" VariableInitializer<out expr> (. var.Initializer = expr; .) ]
Identifier (. var = new VariableDeclaration(t.val); .)
[ "=" VariableInitializer<out expr> (. var.Initializer = expr; .) ]
.
.
Statement
Statement
@ -1426,6 +1432,7 @@ Statement
Location startPos = la.Location;
Location startPos = la.Location;
.)
.)
=
=
SYNC
(
(
/*--- labeled statement: */
/*--- labeled statement: */
IF (IsLabel()) Identifier (. compilationUnit.AddChild(new LabelStatement(t.val)); .)
IF (IsLabel()) Identifier (. compilationUnit.AddChild(new LabelStatement(t.val)); .)
@ -1436,8 +1443,10 @@ Statement
"=" Expr<out expr> (. var.Variables.Add(new VariableDeclaration(ident, expr)); .)
"=" Expr<out expr> (. var.Variables.Add(new VariableDeclaration(ident, expr)); .)
{ "," Identifier (. ident = t.val; .) "=" Expr<out expr> (. var.Variables.Add(new VariableDeclaration(ident, expr)); .) }
{ "," Identifier (. ident = t.val; .) "=" Expr<out expr> (. var.Variables.Add(new VariableDeclaration(ident, expr)); .) }
";" (. compilationUnit.AddChild(var); .)
";" (. compilationUnit.AddChild(var); .)
/*--- local variable declaration: */
/*--- local variable declaration: */
| IF (IsLocalVarDecl()) LocalVariableDecl<out stmt> ";" (. compilationUnit.AddChild(stmt); .)
| IF (IsLocalVarDecl()) LocalVariableDecl<out stmt> ";" (. compilationUnit.AddChild(stmt); .)
| EmbeddedStatement<out stmt> (. compilationUnit.AddChild(stmt); .)
| EmbeddedStatement<out stmt> (. compilationUnit.AddChild(stmt); .)
/* LL(1) confict: LocalVariableDecl *
/* LL(1) confict: LocalVariableDecl *
* <-> StatementExpr *
* <-> StatementExpr *
@ -1459,68 +1468,75 @@ EmbeddedStatement<out Statement statement>
statement = null;
statement = null;
.)
.)
=
=
(. Location startLocation = la.Location; .)
(
Block<out statement>
Block<out statement>
/*--- empty statement: */
/*--- empty statement: */
| ";" (. statement = new EmptyStatement(); .)
| ";" (. statement = new EmptyStatement(); .)
/*--- checked / unchecked statement: */
/*--- checked / unchecked statement: */
| IF (UnCheckedAndLBrace()) (. Statement block; bool isChecked = true; .)
| IF (UnCheckedAndLBrace()) (. Statement block; bool isChecked = true; .)
("checked" | "unchecked" (. isChecked = false;.) )
("checked" | "unchecked" (. isChecked = false;.) )
Block<out block> (. statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); .)
Block<out block> (. statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); .)
/*--- selection statements (if, switch): */
/*--- selection statements (if, switch): */
| "if" (. Statement elseStatement = null; .)
| IfStatement<out statement>
"(" Expr<out expr> ")"
EmbeddedStatement<out embeddedStatement>
[ "else" EmbeddedStatement<out elseStatement> ]
(. statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); .)
(. if (elseStatement is IfElseStatement && (elseStatement as IfElseStatement).TrueStatement.Count == 1) {
/* else if-section (otherwise we would have a BlockStatment) */
(statement as IfElseStatement).ElseIfSections.Add(
new ElseIfSection((elseStatement as IfElseStatement).Condition,
(elseStatement as IfElseStatement).TrueStatement[0]));
(statement as IfElseStatement).ElseIfSections.AddRange((elseStatement as IfElseStatement).ElseIfSections);
(statement as IfElseStatement).FalseStatement = (elseStatement as IfElseStatement).FalseStatement;
} .)
| "switch" (. List<SwitchSection> switchSections = new List<SwitchSection>(); .)
| "switch" (. List<SwitchSection> switchSections = new List<SwitchSection>(); .)
"(" Expr<out expr> ")"
"(" Expr<out expr> ")"
"{" SwitchSections<switchSections>
"{" SwitchSections<switchSections>
"}" (. statement = new SwitchStatement(expr, switchSections); .)
"}" (. statement = new SwitchStatement(expr, switchSections); .)
/*--- iteration statements (while, do, for, foreach): */
/*--- iteration statements (while, do, for, foreach): */
| "while" "(" Expr<out expr> ")"
| "while" "(" Expr<out expr> ")"
EmbeddedStatement<out embeddedStatement>
(. statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start);.)
EmbeddedStatement<out embeddedStatement> (. statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start);.)
| "do" EmbeddedStatement<out embeddedStatement> "while"
| "do" EmbeddedStatement<out embeddedStatement> "while"
"(" Expr<out expr> ")" ";" (. statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); .)
"(" Expr<out expr> ")" ";"
(. statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); .)
| "for" (. List<Statement> initializer = null; List<Statement> iterator = null; .)
| "for" (. List<Statement> initializer = null; List<Statement> iterator = null; .)
"(" [ ForInitializer<out initializer> ] ";"
"(" [ ForInitializer<out initializer> ] ";"
[ Expr<out expr> ] ";"
[ Expr<out expr> ] ";"
[ ForIterator<out iterator> ] ")"
[ ForIterator<out iterator> ] ")"
EmbeddedStatement<out embeddedStatement> (. statement = new ForStatement(initializer, expr, iterator, embeddedStatement); .)
EmbeddedStatement<out embeddedStatement> (. statement = new ForStatement(initializer, expr, iterator, embeddedStatement); .)
| "foreach" "(" Type<out type> Identifier (. string varName = t.val; Location start = t.Location;.)
| "foreach" "(" Type<out type> Identifier (. string varName = t.val; .)
"in" Expr<out expr> ")"
"in" Expr<out expr> ")"
EmbeddedStatement<out embeddedStatement> (. statement = new ForeachStatement(type, varName , expr, embeddedStatement);
EmbeddedStatement<out embeddedStatement>
statement.EndLocation = t.EndLocation;
(. statement = new ForeachStatement(type, varName , expr, embeddedStatement); .)
.)
/*--- jump statements (break, contine, goto, return, throw): */
/*--- jump statements (break, contine, goto, return, throw): */
| "break" ";" (. statement = new BreakStatement(); .)
| "break" ";" (. statement = new BreakStatement(); .)
| "continue" ";" (. statement = new ContinueStatement(); .)
| "continue" ";" (. statement = new ContinueStatement(); .)
| GotoStatement<out statement>
| GotoStatement<out statement>
| IF (IsYieldStatement()) "yield" ( "return" Expr<out expr> (. statement = new YieldStatement(new ReturnStatement(expr)); .)
| "break" (. statement = new YieldStatement(new BreakStatement()); .) ) ";"
| IF (IsYieldStatement()) "yield"
( "return" Expr<out expr> (. statement = new YieldStatement(new ReturnStatement(expr)); .)
| "break" (. statement = new YieldStatement(new BreakStatement()); .) )
";"
| "return" [ Expr<out expr> ] ";" (. statement = new ReturnStatement(expr); .)
| "return" [ Expr<out expr> ] ";" (. statement = new ReturnStatement(expr); .)
| "throw" [ Expr<out expr> ] ";" (. statement = new ThrowStatement(expr); .)
| "throw" [ Expr<out expr> ] ";" (. statement = new ThrowStatement(expr); .)
/*--- expression statement: */
/*--- expression statement: */
| StatementExpr<out statement> ";"
| StatementExpr<out statement> SYNC ";"
/*--- try statement: */
/*--- try statement: */
| TryStatement<out statement>
| TryStatement<out statement>
/*--- lock satement: */
/*--- lock satement: */
| "lock" "(" Expr<out expr> ")"
| "lock" "(" Expr<out expr> ")"
EmbeddedStatement<out embeddedStatement> (. statement = new LockStatement(expr, embeddedStatement); .)
EmbeddedStatement<out embeddedStatement> (. statement = new LockStatement(expr, embeddedStatement); .)
/*--- using statement: */
/*--- using statement: */
| (.Statement resourceAcquisitionStmt = null; .)
| (.Statement resourceAcquisitionStmt = null; .)
"using" "("
"using" "("
ResourceAcquisition<out resourceAcquisitionStmt> ")"
ResourceAcquisition<out resourceAcquisitionStmt> ")"
EmbeddedStatement<out embeddedStatement> (. statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); .)
EmbeddedStatement<out embeddedStatement> (. statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); .)
/*--- unsafe statement: */
/*--- unsafe statement: */
| "unsafe" Block<out embeddedStatement> (. statement = new UnsafeStatement(embeddedStatement); .)
| "unsafe" Block<out embeddedStatement> (. statement = new UnsafeStatement(embeddedStatement); .)
/*--- fixed statement: */
/*--- fixed statement: */
@ -1535,6 +1551,36 @@ EmbeddedStatement<out Statement statement>
"=" Expr<out expr> (. pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); .)
"=" Expr<out expr> (. pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); .)
}
}
")" EmbeddedStatement<out embeddedStatement> (. statement = new FixedStatement(type, pointerDeclarators, embeddedStatement); .)
")" EmbeddedStatement<out embeddedStatement> (. statement = new FixedStatement(type, pointerDeclarators, embeddedStatement); .)
)
(. if (statement != null) {
statement.StartLocation = startLocation;
statement.EndLocation = t.EndLocation;
}
.)
.
IfStatement<out Statement statement>
(.
Expression expr = null;
Statement embeddedStatement = null;
statement = null;
.)
=
"if"
"(" Expr<out expr> ")"
EmbeddedStatement<out embeddedStatement>
(. Statement elseStatement = null; .)
[ "else" EmbeddedStatement<out elseStatement> ]
(. statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); .)
(. if (elseStatement is IfElseStatement && (elseStatement as IfElseStatement).TrueStatement.Count == 1) {
/* else if-section (otherwise we would have a BlockStatment) */
(statement as IfElseStatement).ElseIfSections.Add(
new ElseIfSection((elseStatement as IfElseStatement).Condition,
(elseStatement as IfElseStatement).TrueStatement[0]));
(statement as IfElseStatement).ElseIfSections.AddRange((elseStatement as IfElseStatement).ElseIfSections);
(statement as IfElseStatement).FalseStatement = (elseStatement as IfElseStatement).FalseStatement;
}
.)
.
.
ForInitializer<out List<Statement> initializer>
ForInitializer<out List<Statement> initializer>
@ -1670,6 +1716,7 @@ StatementExpr<out Statement stmt>
Expr<out Expression expr>
Expr<out Expression expr>
(. expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; .)
(. expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; .)
=
=
(. Location startLocation = la.Location; .)
UnaryExpr<out expr>
UnaryExpr<out expr>
/*--- conditional expression: */
/*--- conditional expression: */
(
(
@ -1682,6 +1729,11 @@ Expr<out Expression expr>
[ "?" Expr<out expr1> ":" Expr<out expr2> (. expr = new ConditionalExpression(expr, expr1, expr2); .) ]
[ "?" Expr<out expr1> ":" Expr<out expr2> (. expr = new ConditionalExpression(expr, expr1, expr2); .) ]
)
)
)
)
(. if (expr != null) {
expr.StartLocation = startLocation;
expr.EndLocation = t.EndLocation;
}
.)
.
.
@ -1752,6 +1804,7 @@ PrimaryExpr<out Expression pexpr>
pexpr = null;
pexpr = null;
.)
.)
=
=
(. Location startLocation = la.Location; .)
(
(
"true" (.pexpr = new PrimitiveExpression(true, "true"); .)
"true" (.pexpr = new PrimitiveExpression(true, "true"); .)
| "false" (.pexpr = new PrimitiveExpression(false, "false"); .)
| "false" (.pexpr = new PrimitiveExpression(false, "false"); .)
@ -1763,10 +1816,10 @@ PrimaryExpr<out Expression pexpr>
Identifier (. type = new TypeReference(t.val); .)
Identifier (. type = new TypeReference(t.val); .)
"::" (. pexpr = new TypeReferenceExpression(type); .)
"::" (. pexpr = new TypeReferenceExpression(type); .)
Identifier (. if (type.Type == "global") { type.IsGlobal = true; type.Type = (t.val ?? "?"); } else type.Type += "." + (t.val ?? "?"); .)
Identifier (. if (type.Type == "global") { type.IsGlobal = true; type.Type = (t.val ?? "?"); } else type.Type += "." + (t.val ?? "?"); .)
/*--- simple name (IdentifierExpression): */
/*--- simple name (IdentifierExpression): */
| Identifier
| Identifier
(. pexpr = new IdentifierExpression(t.val); .)
(. pexpr = new IdentifierExpression(t.val); .)
(. pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; .)
[ ShortedLambdaExpression<(IdentifierExpression)pexpr, out pexpr>
[ ShortedLambdaExpression<(IdentifierExpression)pexpr, out pexpr>
| IF (IsGenericInSimpleNameOrMemberAccess())
| IF (IsGenericInSimpleNameOrMemberAccess())
@ -1776,12 +1829,13 @@ PrimaryExpr<out Expression pexpr>
]
]
| IF (IsLambdaExpression()) /* Lambda expression */
| IF (IsLambdaExpression()) /* Lambda expression */
LambdaExpression<out pexpr>
LambdaExpression<out pexpr>
/*--- parenthesized expression: */
/*--- parenthesized expression: */
| "(" Expr<out expr> ")" (. pexpr = new ParenthesizedExpression(expr); .)
| "(" Expr<out expr> ")" (. pexpr = new ParenthesizedExpression(expr); .)
| /*--- predefined type member access: */
| /*--- predefined type member access: */
(. string val = null; .)
(. string val = null; .)
(
( "bool" (. val = "bool"; .)
"bool" (. val = "bool"; .)
| "byte" (. val = "byte"; .)
| "byte" (. val = "byte"; .)
| "char" (. val = "char"; .)
| "char" (. val = "char"; .)
| "decimal" (. val = "decimal"; .)
| "decimal" (. val = "decimal"; .)
@ -1798,25 +1852,21 @@ PrimaryExpr<out Expression pexpr>
| "ushort" (. val = "ushort"; .)
| "ushort" (. val = "ushort"; .)
)
)
MemberAccess<out pexpr, new TypeReferenceExpression(val)>
MemberAccess<out pexpr, new TypeReferenceExpression(val)>
/*--- this access: */
/*--- this access: */
| "this" (. pexpr = new ThisReferenceExpression(); .)
| "this" (. pexpr = new ThisReferenceExpression(); .)
/*--- base access: */
/*--- base access: */
| "base" (. Expression retExpr = new BaseReferenceExpression(); .)
| "base" (. pexpr = new BaseReferenceExpression(); .)
(
MemberAccess<out retExpr, retExpr>
| "[" Expr<out expr> (. List<Expression> indices = new List<Expression>(); if (expr != null) { indices.Add(expr); } .)
{ "," Expr<out expr> (. if (expr != null) { indices.Add(expr); } .) }
"]" (. retExpr = new IndexerExpression(retExpr, indices); .)
) (. pexpr = retExpr; .)
/* new ... - ObjectCreationExpression or ArrayCreateExpression */
/* new ... - ObjectCreationExpression or ArrayCreateExpression */
| NewExpression<out expr> (.pexpr = expr; .)
| NewExpression<out pexpr>
| "typeof" "("
| "typeof" "("
(
(
IF (NotVoidPointer()) "void" (. type = new TypeReference("void"); .)
IF (NotVoidPointer()) "void" (. type = new TypeReference("void"); .)
| TypeWithRestriction<out type, true, true>
| TypeWithRestriction<out type, true, true>
) ")" (. pexpr = new TypeOfExpression(type); .)
)
")" (. pexpr = new TypeOfExpression(type); .)
| "default" "(" Type<out type> ")" (. pexpr = new DefaultValueExpression(type); .)
| "default" "(" Type<out type> ")" (. pexpr = new DefaultValueExpression(type); .)
| "sizeof" "(" Type<out type> ")" (. pexpr = new SizeOfExpression(type); .)
| "sizeof" "(" Type<out type> ")" (. pexpr = new SizeOfExpression(type); .)
@ -1824,7 +1874,13 @@ PrimaryExpr<out Expression pexpr>
| "unchecked" "(" Expr<out expr> ")" (. pexpr = new UncheckedExpression(expr); .)
| "unchecked" "(" Expr<out expr> ")" (. pexpr = new UncheckedExpression(expr); .)
| "delegate" AnonymousMethodExpr<out expr> (. pexpr = expr; .)
| "delegate" AnonymousMethodExpr<out expr> (. pexpr = expr; .)
)
)
(. if (pexpr != null) {
pexpr.StartLocation = startLocation;
pexpr.EndLocation = t.EndLocation;
}
.)
{
{
(. startLocation = la.Location; .)
(
(
"++" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); .)
"++" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); .)
| "--" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); .)
| "--" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); .)
@ -1837,7 +1893,9 @@ PrimaryExpr<out Expression pexpr>
| "(" (. List<Expression> parameters = new List<Expression>(); .)
| "(" (. List<Expression> parameters = new List<Expression>(); .)
[ Argument<out expr> (. if (expr != null) {parameters.Add(expr);} .)
[ Argument<out expr> (. if (expr != null) {parameters.Add(expr);} .)
{ "," Argument<out expr> (. if (expr != null) {parameters.Add(expr);} .)
{ "," Argument<out expr> (. if (expr != null) {parameters.Add(expr);} .)
} ] ")" (. pexpr = new InvocationExpression(pexpr, parameters); .)
}
]
")" (. pexpr = new InvocationExpression(pexpr, parameters); .)
/*--- element access */
/*--- element access */
| (. /*if (isArrayCreation) Error("element access not allow on array creation");*/
| (. /*if (isArrayCreation) Error("element access not allow on array creation");*/
List<Expression> indices = new List<Expression>();
List<Expression> indices = new List<Expression>();
@ -1845,6 +1903,12 @@ PrimaryExpr<out Expression pexpr>
"[" Expr<out expr> (. if (expr != null) { indices.Add(expr); } .)
"[" Expr<out expr> (. if (expr != null) { indices.Add(expr); } .)
{ "," Expr<out expr> (. if (expr != null) { indices.Add(expr); } .)
{ "," Expr<out expr> (. if (expr != null) { indices.Add(expr); } .)
} "]" (. pexpr = new IndexerExpression(pexpr, indices); .)
} "]" (. pexpr = new IndexerExpression(pexpr, indices); .)
(. if (pexpr != null) {
pexpr.StartLocation = startLocation;
pexpr.EndLocation = t.EndLocation;
}
.)
}
}
.
.