[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_grammar.y, 1.64, 1.65 cs_
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_grammar.y, 1.64, 1.65 cs_scanner.l, 1.11, 1.12 |
Date: |
Mon, 14 Jul 2003 05:41:14 -0400 |
Update of /cvsroot/dotgnu-pnet/pnet/cscc/csharp
In directory subversions:/tmp/cvs-serv11452/cscc/csharp
Modified Files:
cs_grammar.y cs_scanner.l
Log Message:
Introduce a flex scanner hack to distinguish between '<' used as
an operator and '<' used as a generic type parameter designator;
make "-fno-generics" the default, requiring "-fgenerics" to compile
C# code that uses generics.
Index: cs_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_grammar.y,v
retrieving revision 1.64
retrieving revision 1.65
diff -C2 -r1.64 -r1.65
*** cs_grammar.y 25 Jun 2003 13:03:34 -0000 1.64
--- cs_grammar.y 14 Jul 2003 09:41:12 -0000 1.65
***************
*** 864,867 ****
--- 864,868 ----
%token OR_ASSIGN_OP "`|='"
%token PTR_OP "`->'"
+ %token GENERIC_LT "`<'"
/*
***************
*** 898,902 ****
%type <node> InvocationExpression ExpressionList
%type <node> ObjectCreationExpression OptArgumentList ArgumentList
! %type <node> Argument PrefixedUnaryExpression /*GenericReference*/
%type <node> Statement EmbeddedStatement Block OptStatementList
--- 899,903 ----
%type <node> InvocationExpression ExpressionList
%type <node> ObjectCreationExpression OptArgumentList ArgumentList
! %type <node> Argument PrefixedUnaryExpression GenericReference
%type <node> Statement EmbeddedStatement Block OptStatementList
***************
*** 964,969 ****
%type <target> AttributeTarget
! /*%expect 25*/
! %expect 21
%start CompilationUnit
--- 965,969 ----
%type <target> AttributeTarget
! %expect 26
%start CompilationUnit
***************
*** 1111,1114 ****
--- 1111,1117 ----
MakeBinary(GenericReference, $1, $3);
}
+ | Identifier GENERIC_LT TypeActuals '>' {
+ MakeBinary(GenericReference, $1, $3);
+ }
;
***************
*** 1296,1299 ****
--- 1299,1305 ----
MakeBinary(GenericReference, $1, $3);
}
+ | Type GENERIC_LT TypeActuals '>' {
+ MakeBinary(GenericReference, $1, $3);
+ }
;
***************
*** 1312,1315 ****
--- 1318,1324 ----
MakeBinary(GenericReference, $1, $3);
}
+ | NonExpressionType GENERIC_LT TypeActuals '>' {
+ MakeBinary(GenericReference, $1, $3);
+ }
;
***************
*** 1332,1335 ****
--- 1341,1348 ----
MakeBinary(LocalVariableType, type, $5);
}
+ | PrimaryExpression GENERIC_LT TypeActuals '>' TypeSuffixes {
+ ILNode *type =
ILNode_GenericReference_create($1, $3);
+ MakeBinary(LocalVariableType, type, $5);
+ }
| BuiltinType TypeSuffixes {
MakeBinary(LocalVariableType, $1, $2);
***************
*** 1730,1734 ****
MakeBinary(AsUntyped, $1, $3);
}
- /*
| GenericReference
{
$$ = $1;
--- 1743,1746 ----
***************
*** 1737,1757 ****
$$ = CSInsertMethodInvocation($1, $3);
}
- */
;
- /*
GenericReference
! : RelationalExpression '<' ShiftExpression '>' {
$$ = CSInsertGenericReference($1, $3);
}
! | RelationalExpression '<' ShiftExpression TypeSuffixList '>' {
$$ = CSInsertGenericReference
($1,
ILNode_LocalVariableType_create($3, $4));
}
! | RelationalExpression '<' ShiftExpression ',' TypeActuals '>' {
$$ = CSInsertGenericReference
($1, ILNode_TypeActuals_create($3, $5));
}
! | RelationalExpression '<' ShiftExpression TypeSuffixList ','
TypeActuals '>' {
$$ = CSInsertGenericReference
--- 1749,1767 ----
$$ = CSInsertMethodInvocation($1, $3);
}
;
GenericReference
! : RelationalExpression GENERIC_LT ShiftExpression '>' {
$$ = CSInsertGenericReference($1, $3);
}
! | RelationalExpression GENERIC_LT ShiftExpression TypeSuffixList '>'
{
$$ = CSInsertGenericReference
($1,
ILNode_LocalVariableType_create($3, $4));
}
! | RelationalExpression GENERIC_LT ShiftExpression ',' TypeActuals '>'
{
$$ = CSInsertGenericReference
($1, ILNode_TypeActuals_create($3, $5));
}
! | RelationalExpression GENERIC_LT ShiftExpression TypeSuffixList ','
TypeActuals '>' {
$$ = CSInsertGenericReference
***************
*** 1759,1767 ****
(ILNode_LocalVariableType_create($3, $4), $6));
}
! | RelationalExpression '<' BuiltinType TypeSuffixes '>' {
$$ = CSInsertGenericReference
($1,
ILNode_LocalVariableType_create($3, $4));
}
! | RelationalExpression '<' BuiltinType TypeSuffixes ',' TypeActuals '>'
{
$$ = CSInsertGenericReference
($1, CSInsertTypeActuals
--- 1769,1778 ----
(ILNode_LocalVariableType_create($3, $4), $6));
}
! | RelationalExpression GENERIC_LT BuiltinType TypeSuffixes '>' {
$$ = CSInsertGenericReference
($1,
ILNode_LocalVariableType_create($3, $4));
}
! | RelationalExpression GENERIC_LT BuiltinType TypeSuffixes ','
! TypeActuals '>' {
$$ = CSInsertGenericReference
($1, CSInsertTypeActuals
***************
*** 1769,1773 ****
}
;
- */
EqualityExpression
--- 1780,1783 ----
***************
*** 2698,2703 ****
TypeFormals
! : /* empty */ { $$ = 0; }
! | '<' TypeFormalList '>' { $$ = $2; }
;
--- 2708,2714 ----
TypeFormals
! : /* empty */ { $$ = 0; }
! | '<' TypeFormalList '>' { $$ = $2; }
! | GENERIC_LT TypeFormalList '>' { $$ = $2; }
;
Index: cs_scanner.l
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_scanner.l,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** cs_scanner.l 21 Jun 2003 17:33:51 -0000 1.11
--- cs_scanner.l 14 Jul 2003 09:41:12 -0000 1.12
***************
*** 962,965 ****
--- 962,976 ----
WHITE [ \t\r\f\v\032]
+ /* The following mess tries to determine if the characters that follow a
+ "<" look like they may be part of a generic type reference. This is
+ to disambiguate "<" used as an operator or as a generic parameter start.
+ Do not change this unless you know what you are doing */
+ GIDENT {IDALPHA}({IDALPHA}|{DIGIT})*
+ GQUALIDENT {GIDENT}({WHITE}*"."{WHITE}*{GIDENT})*
+ GTYPESUFFIX ({WHITE}*"["(",")*"]"|{WHITE}*"*")
+ GTYPE {GQUALIDENT}{GTYPESUFFIX}*
+ GTYPELIST {GTYPE}(","{WHITE}*{GTYPE})*
+ GENERICPREFIX {WHITE}*{GTYPELIST}{WHITE}*("<"|">")
+
%%
***************
*** 1138,1141 ****
--- 1149,1167 ----
"///"[^\n]*\n { yylval.string = ILInternString(yytext + 3, -1);
RETURNTOK(DOC_COMMENT); }
+
+ "<"/{GENERICPREFIX} {
+ /* This looks like it may be a generic type reference
+ rather than a less than sign within an expression.
+ We return a different token code so that the parser
+ can properly distinguish generic types in
expressions */
+ if(CSNoGenerics)
+ {
+ return '<';
+ }
+ else
+ {
+ return GENERIC_LT;
+ }
+ }
. { RETURNTOK(((int)(yytext[0])) & 0xFF);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_grammar.y, 1.64, 1.65 cs_scanner.l, 1.11, 1.12,
Rhys Weatherley <address@hidden> <=