|
|
@ -125,7 +125,7 @@ bool IsQualident(ref Token pt, out string qualident) |
|
|
|
if (pt.kind == Tokens.Identifier) { |
|
|
|
if (pt.kind == Tokens.Identifier) { |
|
|
|
qualidentBuilder.Length = 0; qualidentBuilder.Append(pt.val); |
|
|
|
qualidentBuilder.Length = 0; qualidentBuilder.Append(pt.val); |
|
|
|
pt = Peek(); |
|
|
|
pt = Peek(); |
|
|
|
while (pt.kind == Tokens.Dot) { |
|
|
|
while (pt.kind == Tokens.Dot || pt.kind == Tokens.DoubleColon) { |
|
|
|
pt = Peek(); |
|
|
|
pt = Peek(); |
|
|
|
if (pt.kind != Tokens.Identifier) { |
|
|
|
if (pt.kind != Tokens.Identifier) { |
|
|
|
qualident = String.Empty; |
|
|
|
qualident = String.Empty; |
|
|
@ -703,7 +703,7 @@ NamespaceMemberDecl |
|
|
|
TypeDecl<Modifiers m, List<AttributeSection> attributes> |
|
|
|
TypeDecl<Modifiers m, List<AttributeSection> attributes> |
|
|
|
(. |
|
|
|
(. |
|
|
|
TypeReference type; |
|
|
|
TypeReference type; |
|
|
|
ArrayList names; |
|
|
|
List<TypeReference> names; |
|
|
|
List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>(); |
|
|
|
List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>(); |
|
|
|
string name; |
|
|
|
string name; |
|
|
|
List<TemplateDefinition> templates; |
|
|
|
List<TemplateDefinition> templates; |
|
|
@ -780,9 +780,7 @@ TypeDecl<Modifiers m, List<AttributeSection> attributes> |
|
|
|
newType.Type = Types.Enum; |
|
|
|
newType.Type = Types.Enum; |
|
|
|
.) |
|
|
|
.) |
|
|
|
ident (. newType.Name = t.val; .) |
|
|
|
ident (. newType.Name = t.val; .) |
|
|
|
[ ":" IntegralType<out name> (. newType.BaseTypes = new ArrayList(); |
|
|
|
[ ":" IntegralType<out name> (. newType.BaseTypes.Add(new TypeReference(name)); .) |
|
|
|
newType.BaseTypes.Add(name); |
|
|
|
|
|
|
|
.) |
|
|
|
|
|
|
|
] (. newType.StartLocation = t.EndLocation; .) |
|
|
|
] (. newType.StartLocation = t.EndLocation; .) |
|
|
|
EnumBody |
|
|
|
EnumBody |
|
|
|
[ ";" ] (. newType.EndLocation = t.Location; |
|
|
|
[ ";" ] (. newType.EndLocation = t.Location; |
|
|
@ -822,15 +820,14 @@ Qualident<out string qualident> |
|
|
|
} (. qualident = qualidentBuilder.ToString(); .) |
|
|
|
} (. qualident = qualidentBuilder.ToString(); .) |
|
|
|
. |
|
|
|
. |
|
|
|
|
|
|
|
|
|
|
|
ClassBase<out ArrayList names> |
|
|
|
ClassBase<out List<TypeReference> names> |
|
|
|
(. |
|
|
|
(. |
|
|
|
string qualident; |
|
|
|
TypeReference typeRef; |
|
|
|
names = new ArrayList(); |
|
|
|
names = new List<TypeReference>(); |
|
|
|
List<TypeReference> types; |
|
|
|
|
|
|
|
.) |
|
|
|
.) |
|
|
|
= |
|
|
|
= |
|
|
|
":" ClassType<out qualident, out types> (. names.Add(qualident); // TODO: enter the types .) |
|
|
|
":" ClassType<out typeRef> (. if (typeRef != null) { names.Add(typeRef); } .) |
|
|
|
{ "," Qualident<out qualident> (. names.Add(qualident); .) } |
|
|
|
{ "," TypeName<out typeRef> (. if (typeRef != null) { names.Add(typeRef); } .) } |
|
|
|
. |
|
|
|
. |
|
|
|
|
|
|
|
|
|
|
|
ClassBody |
|
|
|
ClassBody |
|
|
@ -847,14 +844,14 @@ ClassBody |
|
|
|
"}" |
|
|
|
"}" |
|
|
|
. |
|
|
|
. |
|
|
|
|
|
|
|
|
|
|
|
StructInterfaces<out ArrayList names> |
|
|
|
StructInterfaces<out List<TypeReference> names> |
|
|
|
(. |
|
|
|
(. |
|
|
|
string qualident; |
|
|
|
TypeReference typeRef; |
|
|
|
names = new ArrayList(); |
|
|
|
names = new List<TypeReference>(); |
|
|
|
.) |
|
|
|
.) |
|
|
|
= |
|
|
|
= |
|
|
|
":" Qualident<out qualident> (. names.Add(qualident); .) |
|
|
|
":" TypeName<out typeRef> (. if (typeRef != null) { names.Add(typeRef); } .) |
|
|
|
{ "," Qualident<out qualident> (. names.Add(qualident); .) } |
|
|
|
{ "," TypeName<out typeRef> (. if (typeRef != null) { names.Add(typeRef); } .) } |
|
|
|
. |
|
|
|
. |
|
|
|
|
|
|
|
|
|
|
|
StructBody |
|
|
|
StructBody |
|
|
@ -871,14 +868,14 @@ StructBody |
|
|
|
"}" |
|
|
|
"}" |
|
|
|
. |
|
|
|
. |
|
|
|
|
|
|
|
|
|
|
|
InterfaceBase<out ArrayList names> |
|
|
|
InterfaceBase<out List<TypeReference> names> |
|
|
|
(. |
|
|
|
(. |
|
|
|
string qualident; |
|
|
|
TypeReference typeRef; |
|
|
|
names = new ArrayList(); |
|
|
|
names = new List<TypeReference>(); |
|
|
|
.) |
|
|
|
.) |
|
|
|
= |
|
|
|
= |
|
|
|
":" Qualident<out qualident> (. names.Add(qualident); .) |
|
|
|
":" TypeName<out typeRef> (. if (typeRef != null) { names.Add(typeRef); } .) |
|
|
|
{ "," Qualident<out qualident> (. names.Add(qualident); .) } |
|
|
|
{ "," TypeName<out typeRef> (. if (typeRef != null) { names.Add(typeRef); } .) } |
|
|
|
. |
|
|
|
. |
|
|
|
|
|
|
|
|
|
|
|
InterfaceBody |
|
|
|
InterfaceBody |
|
|
@ -894,43 +891,42 @@ EnumBody (. FieldDeclaration f; .) |
|
|
|
|
|
|
|
|
|
|
|
Type<out TypeReference type> |
|
|
|
Type<out TypeReference type> |
|
|
|
(. |
|
|
|
(. |
|
|
|
string name = ""; |
|
|
|
string name; |
|
|
|
int pointer = 0; |
|
|
|
int pointer = 0; |
|
|
|
List<TypeReference> types = null; |
|
|
|
|
|
|
|
type = null; |
|
|
|
type = null; |
|
|
|
.) |
|
|
|
.) |
|
|
|
= |
|
|
|
= |
|
|
|
( ClassType<out name, out types> |
|
|
|
( ClassType<out type> |
|
|
|
| SimpleType<out name> |
|
|
|
| SimpleType<out name> (. type = new TypeReference(name); .) |
|
|
|
| "void" "*" (. pointer = 1; name = "void"; .) |
|
|
|
| "void" "*" (. pointer = 1; type = new TypeReference("void"); .) |
|
|
|
) (. ArrayList r = new ArrayList(); .) |
|
|
|
) (. List<int> r = new List<int>(); .) |
|
|
|
|
|
|
|
|
|
|
|
{ IF (IsPointerOrDims()) (. int i = 0; .) |
|
|
|
{ IF (IsPointerOrDims()) (. int i = 0; .) |
|
|
|
( "*" (. ++pointer; .) |
|
|
|
( "*" (. ++pointer; .) |
|
|
|
| "[" { "," (. ++i; .) } "]" (. r.Add(i); .) |
|
|
|
| "[" { "," (. ++i; .) } "]" (. r.Add(i); .) |
|
|
|
) |
|
|
|
) |
|
|
|
} (. int[] rank = new int[r.Count]; r.CopyTo(rank); |
|
|
|
} |
|
|
|
type = new TypeReference(name, pointer, rank, types); |
|
|
|
(. type.RankSpecifier = r.ToArray(); |
|
|
|
|
|
|
|
type.PointerNestingLevel = pointer; |
|
|
|
.) |
|
|
|
.) |
|
|
|
. |
|
|
|
. |
|
|
|
|
|
|
|
|
|
|
|
NonArrayType<out TypeReference type> |
|
|
|
NonArrayType<out TypeReference type> |
|
|
|
(. |
|
|
|
(. |
|
|
|
string name = ""; |
|
|
|
string name; |
|
|
|
int pointer = 0; |
|
|
|
int pointer = 0; |
|
|
|
List<TypeReference> genericTypes = null; |
|
|
|
type = null; |
|
|
|
.) |
|
|
|
.) |
|
|
|
= |
|
|
|
= |
|
|
|
( ClassType<out name, out genericTypes> |
|
|
|
( ClassType<out type> |
|
|
|
| SimpleType<out name> |
|
|
|
| SimpleType<out name> (. type = new TypeReference(name); .) |
|
|
|
| "void" "*" (. pointer = 1; name = "void"; .) |
|
|
|
| "void" "*" (. pointer = 1; type = new TypeReference("void"); .) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
{ IF (IsPointer()) |
|
|
|
{ IF (IsPointer()) |
|
|
|
"*" (. ++pointer; .) |
|
|
|
"*" (. ++pointer; .) |
|
|
|
} (. |
|
|
|
} |
|
|
|
type = new TypeReference(name, pointer, null, genericTypes); |
|
|
|
(. type.PointerNestingLevel = pointer; .) |
|
|
|
.) |
|
|
|
|
|
|
|
. |
|
|
|
. |
|
|
|
|
|
|
|
|
|
|
|
SimpleType<out string name> |
|
|
|
SimpleType<out string name> |
|
|
@ -1003,15 +999,12 @@ TypeModifier<Modifiers m> |
|
|
|
| ident (. if (t.val == "partial") { m.Add(Modifier.Partial); } .) |
|
|
|
| ident (. if (t.val == "partial") { m.Add(Modifier.Partial); } .) |
|
|
|
. |
|
|
|
. |
|
|
|
|
|
|
|
|
|
|
|
ClassType<out string name, out List<TypeReference> types> |
|
|
|
ClassType<out TypeReference typeRef> |
|
|
|
(. string qualident; name = ""; |
|
|
|
(. TypeReference r; typeRef = null; .) |
|
|
|
List<TypeReference> t; |
|
|
|
|
|
|
|
types = null; |
|
|
|
|
|
|
|
.) |
|
|
|
|
|
|
|
= |
|
|
|
= |
|
|
|
TypeName<out qualident, out t> (. name = qualident; types = t; .) |
|
|
|
TypeName<out r> (. typeRef = r; .) |
|
|
|
| "object" (. name = "object"; .) |
|
|
|
| "object" (. typeRef = new TypeReference("object"); .) |
|
|
|
| "string" (. name = "string"; .) |
|
|
|
| "string" (. typeRef = new TypeReference("string"); .) |
|
|
|
. |
|
|
|
. |
|
|
|
|
|
|
|
|
|
|
|
IntegralType<out string name> (. name = ""; .) |
|
|
|
IntegralType<out string name> (. name = ""; .) |
|
|
@ -1793,17 +1786,22 @@ CatchClauses<out ArrayList catchClauses> |
|
|
|
catchClauses = new ArrayList(); |
|
|
|
catchClauses = new ArrayList(); |
|
|
|
.) |
|
|
|
.) |
|
|
|
= |
|
|
|
= |
|
|
|
"catch" (. string name; |
|
|
|
"catch" (. string identifier; |
|
|
|
string identifier; |
|
|
|
|
|
|
|
Statement stmt; |
|
|
|
Statement stmt; |
|
|
|
List<TypeReference> types; |
|
|
|
TypeReference typeRef; |
|
|
|
.) |
|
|
|
.) |
|
|
|
/*--- general catch clause (as only catch clause) */ |
|
|
|
/*--- general catch clause (as only catch clause) */ |
|
|
|
( |
|
|
|
( |
|
|
|
Block<out stmt> (. catchClauses.Add(new CatchClause(stmt)); .) |
|
|
|
Block<out stmt> (. catchClauses.Add(new CatchClause(stmt)); .) |
|
|
|
/*--- specific catch clause */ |
|
|
|
/*--- specific catch clause */ |
|
|
|
| "(" ClassType<out name, out types> (. identifier = null; .) [ ident (. identifier = t.val; .) ] ")" Block<out stmt> (. catchClauses.Add(new CatchClause(new TypeReference(name, 0, null, types), identifier, stmt)); .) |
|
|
|
| "(" ClassType<out typeRef> (. identifier = null; .) |
|
|
|
{ IF (IsTypedCatch()) "catch" "(" ClassType<out name, out types> (. identifier = null; .) [ ident (. identifier = t.val; .) ] ")" Block<out stmt> (. catchClauses.Add(new CatchClause(new TypeReference(name, 0, null, types), identifier, stmt)); .) } |
|
|
|
[ ident (. identifier = t.val; .) ] |
|
|
|
|
|
|
|
")" Block<out stmt> |
|
|
|
|
|
|
|
(. catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); .) |
|
|
|
|
|
|
|
{ IF (IsTypedCatch()) "catch" "(" ClassType<out typeRef> (. identifier = null; .) |
|
|
|
|
|
|
|
[ ident (. identifier = t.val; .) ] |
|
|
|
|
|
|
|
")" Block<out stmt> |
|
|
|
|
|
|
|
(. catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); .) } |
|
|
|
/*--- general catch clause (after specific catch clauses, optional) */ |
|
|
|
/*--- general catch clause (after specific catch clauses, optional) */ |
|
|
|
[ "catch" Block<out stmt> (. catchClauses.Add(new CatchClause(stmt)); .) ] |
|
|
|
[ "catch" Block<out stmt> (. catchClauses.Add(new CatchClause(stmt)); .) ] |
|
|
|
) |
|
|
|
) |
|
|
@ -1929,6 +1927,8 @@ PrimaryExpr<out Expression pexpr> |
|
|
|
| "false" (.pexpr = new PrimitiveExpression(false, "false"); .) |
|
|
|
| "false" (.pexpr = new PrimitiveExpression(false, "false"); .) |
|
|
|
| "null" (.pexpr = new PrimitiveExpression(null, "null"); .) /* from literal token */ |
|
|
|
| "null" (.pexpr = new PrimitiveExpression(null, "null"); .) /* from literal token */ |
|
|
|
| Literal (.pexpr = new PrimitiveExpression(t.literalValue, t.val); .) |
|
|
|
| Literal (.pexpr = new PrimitiveExpression(t.literalValue, t.val); .) |
|
|
|
|
|
|
|
| IF (la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) |
|
|
|
|
|
|
|
TypeName<out type> (. pexpr = new TypeReferenceExpression(type); .) |
|
|
|
/*--- simple name: */ |
|
|
|
/*--- simple name: */ |
|
|
|
| ident (. pexpr = new IdentifierExpression(t.val); .) |
|
|
|
| ident (. pexpr = new IdentifierExpression(t.val); .) |
|
|
|
/*--- parenthesized expression: */ |
|
|
|
/*--- parenthesized expression: */ |
|
|
@ -2021,6 +2021,16 @@ PrimaryExpr<out Expression pexpr> |
|
|
|
/*--- member access */ |
|
|
|
/*--- member access */ |
|
|
|
| "->" ident (. pexpr = new PointerReferenceExpression(pexpr, t.val); .) |
|
|
|
| "->" ident (. pexpr = new PointerReferenceExpression(pexpr, t.val); .) |
|
|
|
| "." ident (. pexpr = new FieldReferenceExpression(pexpr, t.val);.) |
|
|
|
| "." ident (. pexpr = new FieldReferenceExpression(pexpr, t.val);.) |
|
|
|
|
|
|
|
/*| "::" ident (. |
|
|
|
|
|
|
|
if (pexpr is IdentifierExpression) { |
|
|
|
|
|
|
|
if (((IdentifierExpression)pexpr).Identifier == "global") { |
|
|
|
|
|
|
|
pexpr = new GlobalReferenceExpression(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Error("expression before :: must be an identifier"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
pexpr = new FieldReferenceExpression(pexpr, t.val); |
|
|
|
|
|
|
|
.) */ |
|
|
|
/* member access on generic type */ |
|
|
|
/* member access on generic type */ |
|
|
|
| ( IF (IsGenericFollowedBy(Tokens.Dot) && IsTypeReferenceExpression(pexpr)) |
|
|
|
| ( IF (IsGenericFollowedBy(Tokens.Dot) && IsTypeReferenceExpression(pexpr)) |
|
|
|
TypeArgumentList<out typeList> ) |
|
|
|
TypeArgumentList<out typeList> ) |
|
|
@ -2191,11 +2201,28 @@ MultiplicativeExpr<ref Expression outExpr> |
|
|
|
|
|
|
|
|
|
|
|
/* .NET 2.0 rules */ |
|
|
|
/* .NET 2.0 rules */ |
|
|
|
|
|
|
|
|
|
|
|
TypeName<out string qualident, out List<TypeReference> types> |
|
|
|
TypeName<out TypeReference typeRef> |
|
|
|
(. List<TypeReference> t; types = new List<TypeReference>(); .) |
|
|
|
(. List<TypeReference> typeArguments = null; |
|
|
|
|
|
|
|
string alias = null; |
|
|
|
|
|
|
|
string qualident; |
|
|
|
|
|
|
|
.) |
|
|
|
= |
|
|
|
= |
|
|
|
|
|
|
|
[ IF (la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) |
|
|
|
|
|
|
|
ident (. alias = t.val; .) |
|
|
|
|
|
|
|
"::" |
|
|
|
|
|
|
|
] |
|
|
|
Qualident<out qualident> |
|
|
|
Qualident<out qualident> |
|
|
|
[ TypeArgumentList<out t> (. types = t; .)] |
|
|
|
[ TypeArgumentList<out typeArguments> ] |
|
|
|
|
|
|
|
(. |
|
|
|
|
|
|
|
if (alias == null) { |
|
|
|
|
|
|
|
typeRef = new TypeReference(qualident, typeArguments); |
|
|
|
|
|
|
|
} else if (alias == "global") { |
|
|
|
|
|
|
|
typeRef = new TypeReference(qualident, typeArguments); |
|
|
|
|
|
|
|
typeRef.IsGlobal = true; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
typeRef = new TypeReference(alias + "." + qualident, typeArguments); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.) |
|
|
|
. |
|
|
|
. |
|
|
|
|
|
|
|
|
|
|
|
TypeArgumentList<out List<TypeReference> types> |
|
|
|
TypeArgumentList<out List<TypeReference> types> |
|
|
|