passrc: added parsing label marks in the code blocks

git-svn-id: trunk@15903 -
This commit is contained in:
dmitry 2010-08-25 13:55:24 +00:00
parent 1530872629
commit 9b9a3ec725
2 changed files with 48 additions and 6 deletions

View File

@ -759,6 +759,7 @@ type
TPasImplTry = class;
TPasImplExceptOn = class;
TPasImplRaise = class;
TPasImplLabelMark = class;
{ TPasImplBlock }
@ -782,6 +783,7 @@ type
function AddTry: TPasImplTry;
function AddExceptOn(const VarName, TypeName: string): TPasImplExceptOn;
function AddRaise: TPasImplRaise;
function AddLabelMark(const Id: string): TPasImplLabelMark;
function CloseOnSemicolon: boolean; virtual;
public
Elements: TList; // TPasImplElement objects
@ -958,6 +960,11 @@ type
procedure Visit(obj: TPasElement); virtual;
end;
TPasImplLabelMark = class(TPasImplElement)
public
LabelId: AnsiString;
end;
const
AccessNames: array[TArgumentAccess] of string[6] = ('', 'const ', 'var ', 'out ');
AllVisibilities: TPasMemberVisibilities =
@ -1681,6 +1688,13 @@ begin
AddElement(Result);
end;
function TPasImplBlock.AddLabelMark(const Id: string): TPasImplLabelMark;
begin
Result:=TPasIMplLabelMark.Create('', Self);
Result.LabelId:=Id;
AddElement(Result);
end;
function TPasImplBlock.CloseOnSemicolon: boolean;
begin
Result:=false;

View File

@ -2912,13 +2912,41 @@ begin
end;
else
UngetToken;
Command:=ParseCommand;
//WriteLn(i,'COMMAND="',Command,'" Token=',CurTokenString);
Command:='';
NextToken;
// testing for label mark
if CurToken=tkIdentifier then
begin
Command:=CurTokenText;
NextToken;
// testing for the goto mark
if CurToken=tkColon then
begin
CurBlock.AddLabelMark(Command);
end
else
begin
Command:='';
UngetToken;
UngetToken;
end;
end else
UngetToken;
if Command='' then
ParseExc(SParserSyntaxError);
CmdElem:=CurBlock.AddCommand(Command);
if NewImplElement=nil then NewImplElement:=CmdElem;
if CloseStatement(false) then break;
begin
// parsing the assignment statement or call expression
Command:=ParseCommand;
//WriteLn(i,'COMMAND="',Command,'" Token=',CurTokenString);
if Command='' then
ParseExc(SParserSyntaxError);
CmdElem:=CurBlock.AddCommand(Command);
if NewImplElement=nil then NewImplElement:=CmdElem;
if CloseStatement(false) then break;
end;
end;
end;
end;