New tokens for new management operators: Initialize, Finalize, AddRef and Copy. Small code adjustment for parser (pdecobj.pas, pstatmnt.pas, psub.pas, ptype.pas) was required because few of old token has from now value which is outside range of set: _CONSTRUCTOR, _FINALIZATION.

New tokens for operators:
  * _OP_INITIALIZE, _OP_FINALIZE, _OP_ADDREF, _OP_COPY

New tokens:
  * _INITIALIZE, _FINALIZE, _ADDREF, _COPY

git-svn-id: trunk@35438 -
This commit is contained in:
maciej-izak 2017-02-18 18:12:45 +00:00
parent 3f8f7bc04a
commit 48b149acd4
6 changed files with 25 additions and 5 deletions

View File

@ -1060,7 +1060,7 @@ implementation
consume(_CLASS);
{ class modifier is only allowed for procedures, functions, }
{ constructors, destructors, fields and properties }
if not(token in [_FUNCTION,_PROCEDURE,_PROPERTY,_VAR,_CONSTRUCTOR,_DESTRUCTOR]) then
if not((token in [_FUNCTION,_PROCEDURE,_PROPERTY,_VAR,_DESTRUCTOR]) or (token=_CONSTRUCTOR)) then
Message(parser_e_procedure_or_function_expected);
{ Java interfaces can contain final class vars }

View File

@ -1355,7 +1355,7 @@ implementation
filepos:=current_tokenpos;
consume(starttoken);
while not(token in [_END,_FINALIZATION]) do
while not((token=_END) or (token=_FINALIZATION)) do
begin
if first=nil then
begin
@ -1367,7 +1367,7 @@ implementation
tstatementnode(last).right:=cstatementnode.create(statement,nil);
last:=tstatementnode(last).right;
end;
if (token in [_END,_FINALIZATION]) then
if ((token=_END) or (token=_FINALIZATION)) then
break
else
begin

View File

@ -2420,7 +2420,7 @@ implementation
begin
{ class modifier is only allowed for procedures, functions, }
{ constructors, destructors }
if not(token in [_FUNCTION,_PROCEDURE,_CONSTRUCTOR,_DESTRUCTOR,_OPERATOR]) and
if not((token in [_FUNCTION,_PROCEDURE,_DESTRUCTOR,_OPERATOR]) or (token=_CONSTRUCTOR)) and
not((token=_ID) and (idtoken=_OPERATOR)) then
Message(parser_e_procedure_or_function_expected);

View File

@ -859,7 +859,7 @@ implementation
{ class modifier is only allowed for procedures, functions, }
{ constructors, destructors, fields and properties }
if (hadgeneric and not (token in [_FUNCTION,_PROCEDURE])) or
(not hadgeneric and (not (token in [_FUNCTION,_PROCEDURE,_PROPERTY,_VAR,_CONSTRUCTOR,_DESTRUCTOR,_OPERATOR]) and
(not hadgeneric and (not ((token in [_FUNCTION,_PROCEDURE,_PROPERTY,_VAR,_DESTRUCTOR,_OPERATOR]) or (token=_CONSTRUCTOR)) and
not((token=_ID) and (idtoken=_OPERATOR)))) then
Message(parser_e_procedure_or_function_expected);

View File

@ -423,6 +423,10 @@ interface
{ _ASSIGNMENT } 'assign',
{ _OP_EXPLICIT } 'explicit',
{ _OP_ENUMERATOR } 'enumerator',
{ _OP_INITIALIZE } 'initialize',
{ _OP_FINALIZE } 'finalize',
{ _OP_ADDREF } 'addref',
{ _OP_COPY } 'copy',
{ _OP_INC } 'inc',
{ _OP_DEC } 'dec');

View File

@ -56,6 +56,10 @@ type
_ASSIGNMENT,
_OP_EXPLICIT,
_OP_ENUMERATOR,
_OP_INITIALIZE,
_OP_FINALIZE,
_OP_ADDREF,
_OP_COPY,
_OP_INC,
_OP_DEC,
{ special chars }
@ -129,6 +133,7 @@ type
_VAR,
_XOR,
_CASE,
_COPY,
_CVAR,
_ELSE,
_EXIT,
@ -164,6 +169,7 @@ type
_UNTIL,
_WHILE,
_WRITE,
_ADDREF,
_DISPID,
_DIVIDE,
_DOWNTO,
@ -222,6 +228,7 @@ type
_CPPCLASS,
_EXPLICIT,
_EXTERNAL,
_FINALIZE,
_FUNCTION,
_IMPLICIT,
_LESSTHAN,
@ -273,6 +280,7 @@ type
_DESTRUCTOR,
_ENUMERATOR,
_IMPLEMENTS,
_INITIALIZE,
_INTERNPROC,
_LOGICALAND,
_LOGICALNOT,
@ -385,6 +393,10 @@ const
(str:':=' ;special:true ;keyword:[m_none];op:NOTOKEN),
(str:'explicit' ;special:true ;keyword:[m_none];op:NOTOKEN),
(str:'enumerator' ;special:true ;keyword:[m_none];op:NOTOKEN),
(str:'initialize' ;special:true ;keyword:[m_none];op:NOTOKEN),
(str:'finalize' ;special:true ;keyword:[m_none];op:NOTOKEN),
(str:'addref' ;special:true ;keyword:[m_none];op:NOTOKEN),
(str:'copy' ;special:true ;keyword:[m_none];op:NOTOKEN),
(str:'inc' ;special:true ;keyword:[m_none];op:NOTOKEN),
(str:'dec' ;special:true ;keyword:[m_none];op:NOTOKEN),
{ Special chars }
@ -458,6 +470,7 @@ const
(str:'VAR' ;special:false;keyword:alllanguagemodes;op:NOTOKEN),
(str:'XOR' ;special:false;keyword:alllanguagemodes;op:_OP_XOR),
(str:'CASE' ;special:false;keyword:alllanguagemodes;op:NOTOKEN),
(str:'COPY' ;special:false;keyword:[m_none];op:NOTOKEN),
(str:'CVAR' ;special:false;keyword:[m_none];op:NOTOKEN),
(str:'ELSE' ;special:false;keyword:alllanguagemodes;op:NOTOKEN),
(str:'EXIT' ;special:false;keyword:[m_none];op:NOTOKEN),
@ -493,6 +506,7 @@ const
(str:'UNTIL' ;special:false;keyword:alllanguagemodes;op:NOTOKEN),
(str:'WHILE' ;special:false;keyword:alllanguagemodes;op:NOTOKEN),
(str:'WRITE' ;special:false;keyword:[m_none];op:NOTOKEN),
(str:'ADDREF' ;special:false;keyword:[m_none];op:NOTOKEN),
(str:'DISPID' ;special:false;keyword:[m_none];op:NOTOKEN),
(str:'DIVIDE' ;special:false;keyword:[m_none];op:NOTOKEN), { delphi operator name }
(str:'DOWNTO' ;special:false;keyword:alllanguagemodes;op:NOTOKEN),
@ -551,6 +565,7 @@ const
(str:'CPPCLASS' ;special:false;keyword:[m_fpc];op:NOTOKEN),
(str:'EXPLICIT' ;special:false;keyword:[m_none];op:NOTOKEN), { delphi operator name }
(str:'EXTERNAL' ;special:false;keyword:[m_none];op:NOTOKEN),
(str:'FINALIZE' ;special:false;keyword:[m_none];op:NOTOKEN),
(str:'FUNCTION' ;special:false;keyword:alllanguagemodes;op:NOTOKEN),
(str:'IMPLICIT' ;special:false;keyword:[m_none];op:NOTOKEN), { delphi operator name }
(str:'LESSTHAN' ;special:false;keyword:[m_none];op:NOTOKEN), { delphi operator name }
@ -602,6 +617,7 @@ const
(str:'DESTRUCTOR' ;special:false;keyword:alllanguagemodes-[m_iso,m_extpas];op:NOTOKEN),
(str:'ENUMERATOR' ;special:false;keyword:[m_none];op:_OP_ENUMERATOR),
(str:'IMPLEMENTS' ;special:false;keyword:[m_none];op:NOTOKEN),
(str:'INITIALIZE' ;special:false;keyword:[m_none];op:NOTOKEN),
(str:'INTERNPROC' ;special:false;keyword:[m_none];op:NOTOKEN),
(str:'LOGICALAND' ;special:false;keyword:[m_none];op:NOTOKEN), { delphi operator name }
(str:'LOGICALNOT' ;special:false;keyword:[m_none];op:NOTOKEN), { delphi operator name }