summaryrefslogtreecommitdiff
path: root/compiler/ptype.pas
diff options
context:
space:
mode:
authorpeter <peter@3ad0048d-3df7-0310-abae-a5850022a9f2>2005-12-21 09:13:15 +0000
committerpeter <peter@3ad0048d-3df7-0310-abae-a5850022a9f2>2005-12-21 09:13:15 +0000
commitb5c147d0f72c7194b1c742669e604837930a8597 (patch)
treee6a30cd481ccf876682989dbf4e99e1f22004686 /compiler/ptype.pas
parent7a50655c2515e26cb0f287e7a580f518c3bf7e8a (diff)
downloadfpc-generics.tar.gz
* new syntax with generic and specialize keywordgenerics
git-svn-id: http://svn.freepascal.org/svn/fpc/branches/generics@2018 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/ptype.pas')
-rw-r--r--compiler/ptype.pas17
1 files changed, 16 insertions, 1 deletions
diff --git a/compiler/ptype.pas b/compiler/ptype.pas
index ac06e46166..c9494501a5 100644
--- a/compiler/ptype.pas
+++ b/compiler/ptype.pas
@@ -91,15 +91,24 @@ implementation
Comment(V_Error,'Specialization is only supported for generic types');
pt1.resulttype:=generrortype;
{ recover }
+{$ifdef GENERICSHARPBRACKET}
consume(_LSHARPBRACKET);
+{$endif GENERICSHARPBRACKET}
+ consume(_LKLAMMER);
repeat
pt2:=factor(false);
pt2.free;
until not try_to_consume(_COMMA);
+{$ifdef GENERICSHARPBRACKET}
consume(_RSHARPBRACKET);
+{$endif GENERICSHARPBRACKET}
+ consume(_RKLAMMER);
exit;
end;
+{$ifdef GENERICSHARPBRACKET}
consume(_LSHARPBRACKET);
+{$endif GENERICSHARPBRACKET}
+ consume(_LKLAMMER);
{ Parse generic parameters, for each undefineddef in the symtable of
the genericdef we need to have a new def }
err:=false;
@@ -151,7 +160,10 @@ implementation
try_to_consume(_SEMICOLON);
end;
generictypelist.free;
+{$ifdef GENERICSHARPBRACKET}
consume(_RSHARPBRACKET);
+{$endif GENERICSHARPBRACKET}
+ consume(_RKLAMMER);
end;
@@ -346,6 +358,7 @@ implementation
var
pt1,pt2 : tnode;
lv,hv : TConstExprInt;
+ ispecialization : boolean;
begin
{ use of current parsed object ? }
if (token=_ID) and (testcurobject=2) and (curobjectname=pattern) then
@@ -361,6 +374,8 @@ implementation
consume(_ID);
exit;
end;
+ { Generate a specialization? }
+ ispecialization:=try_to_consume(_SPECIALIZE);
{ we can't accept a equal in type }
pt1:=comp_expr(not(ignore_equal));
if (token=_POINTPOINT) then
@@ -411,7 +426,7 @@ implementation
{ a simple type renaming or generic specialization }
if (pt1.nodetype=typen) then
begin
- if token=_LSHARPBRACKET then
+ if ispecialization then
generate_specialization(pt1,name);
tt:=ttypenode(pt1).resulttype;
end