mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-18 01:48:16 +02:00
codetools: parse record case with enum, bug #18368
git-svn-id: trunk@30769 -
This commit is contained in:
parent
620d81dfe3
commit
a70872ae5b
@ -3800,7 +3800,7 @@ begin
|
|||||||
ReadGUID;
|
ReadGUID;
|
||||||
// parse till "end" of class/object
|
// parse till "end" of class/object
|
||||||
repeat
|
repeat
|
||||||
//DebugLn(['TPascalParserTool.BuildSubTreeForClass Atom=',GetAtom,' ',CurPos.StartPos>=ClassNode.EndPos]);
|
//DebugLn(['TPascalParserTool.KeyWordFuncTypeClass Atom=',GetAtom,' ',CurPos.StartPos>=ClassNode.EndPos]);
|
||||||
if not ParseInnerClass(CurPos.StartPos,CurPos.EndPos-CurPos.StartPos) then
|
if not ParseInnerClass(CurPos.StartPos,CurPos.EndPos-CurPos.StartPos) then
|
||||||
begin
|
begin
|
||||||
if CurPos.Flag<>cafEnd then
|
if CurPos.Flag<>cafEnd then
|
||||||
@ -3844,7 +3844,7 @@ begin
|
|||||||
// place cursor on atom behind
|
// place cursor on atom behind
|
||||||
if CurPos.Flag<>cafSemicolon then
|
if CurPos.Flag<>cafSemicolon then
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
//debugln(['TPascalParserTool.KeyWordFuncTypeClass END ',GetAtom,' ',CleanPosToStr(CurPos.StartPos)]);
|
//debugln(['TPascalParserTool.KeyWordFuncTypeClass END ',GetAtom,' ',CleanPosToStr(CurPos.StartPos),' CurNode=',CurNode.DescAsString]);
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -3940,7 +3940,7 @@ begin
|
|||||||
CurNode.Desc:=ctnRangeType;
|
CurNode.Desc:=ctnRangeType;
|
||||||
ReadSubRange(true);
|
ReadSubRange(true);
|
||||||
CurNode.EndPos:=LastAtoms.GetValueAt(0).EndPos;
|
CurNode.EndPos:=LastAtoms.GetValueAt(0).EndPos;
|
||||||
EndChildNode;
|
EndChildNode; // close ctnRangeType
|
||||||
if (CurPos.Flag=cafEdgedBracketClose) then break;
|
if (CurPos.Flag=cafEdgedBracketClose) then break;
|
||||||
if (CurPos.Flag<>cafComma) then
|
if (CurPos.Flag<>cafComma) then
|
||||||
RaiseCharExpectedButAtomFound(']');
|
RaiseCharExpectedButAtomFound(']');
|
||||||
@ -3952,7 +3952,8 @@ begin
|
|||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
Result:=ParseType(CurPos.StartPos,CurPos.EndPos-CurPos.StartPos);
|
Result:=ParseType(CurPos.StartPos,CurPos.EndPos-CurPos.StartPos);
|
||||||
CurNode.EndPos:=CurPos.StartPos;
|
CurNode.EndPos:=CurPos.StartPos;
|
||||||
EndChildNode;
|
EndChildNode; // close array
|
||||||
|
//debugln(['TPascalParserTool.KeyWordFuncTypeArray END Atom=',GetAtom,' CurNode=',CurNode.DescAsString]);
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -4259,13 +4260,15 @@ function TPascalParserTool.KeyWordFuncTypeRecordCase: boolean;
|
|||||||
11: (y: byte);
|
11: (y: byte);
|
||||||
end; );
|
end; );
|
||||||
4: (e: integer;
|
4: (e: integer;
|
||||||
case z of
|
case enum:(one, two, three) of
|
||||||
8: (f: integer)
|
one:(F: Integer);
|
||||||
|
two:(D: Byte);
|
||||||
|
three:(Z:PChar);
|
||||||
);
|
);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
{off $DEFINE VerboseRecordCase}
|
||||||
procedure RaiseCaseOnlyAllowedInRecords;
|
procedure RaiseCaseOnlyAllowedInRecords;
|
||||||
begin
|
begin
|
||||||
//debugln(['RaiseCaseOnlyAllowedInRecords ',CurNode.DescAsString]);
|
//debugln(['RaiseCaseOnlyAllowedInRecords ',CurNode.DescAsString]);
|
||||||
@ -4286,30 +4289,64 @@ begin
|
|||||||
end;
|
end;
|
||||||
CreateChildNode;
|
CreateChildNode;
|
||||||
CurNode.Desc:=ctnRecordCase;
|
CurNode.Desc:=ctnRecordCase;
|
||||||
|
{$IFDEF VerboseRecordCase}
|
||||||
|
debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase START case="',GetAtom,'"']);
|
||||||
|
{$ENDIF}
|
||||||
ReadNextAtom; // read ordinal type
|
ReadNextAtom; // read ordinal type
|
||||||
{ case a of
|
{ case a of
|
||||||
case a:b of
|
case a:b of
|
||||||
case a:b.c of
|
case a:b.c of
|
||||||
|
case a:(b,c) of
|
||||||
}
|
}
|
||||||
AtomIsIdentifier(true);
|
AtomIsIdentifier(true);
|
||||||
//debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase START ',GetAtom]);
|
{$IFDEF VerboseRecordCase}
|
||||||
|
debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase case name="',GetAtom,'"']);
|
||||||
|
{$ENDIF}
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
if (CurPos.Flag=cafColon) then begin
|
if (CurPos.Flag=cafColon) then begin
|
||||||
|
// has type
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
AtomIsIdentifier(true);
|
if CurPos.Flag=cafRoundBracketOpen then begin
|
||||||
ReadNextAtom;
|
CreateChildNode;
|
||||||
end;
|
CurNode.Desc:=ctnEnumerationType;
|
||||||
if CurPos.Flag=cafPoint then begin
|
ReadNextAtom;
|
||||||
ReadNextAtom; // unit.type
|
if CurPos.Flag<>cafRoundBracketClose then begin
|
||||||
AtomIsIdentifier(true);
|
repeat
|
||||||
ReadNextAtom;
|
// read enum
|
||||||
|
AtomIsIdentifier(true);
|
||||||
|
CreateChildNode;
|
||||||
|
CurNode.Desc:=ctnEnumIdentifier;
|
||||||
|
CurNode.EndPos:=CurPos.EndPos;
|
||||||
|
EndChildNode;
|
||||||
|
ReadNextAtom;
|
||||||
|
if CurPos.Flag=cafRoundBracketClose then break;
|
||||||
|
if CurPos.Flag<>cafComma then
|
||||||
|
RaiseCharExpectedButAtomFound(',');
|
||||||
|
ReadNextAtom;
|
||||||
|
until false;
|
||||||
|
end;
|
||||||
|
CurNode.EndPos:=CurPos.EndPos;
|
||||||
|
EndChildNode; // close ctnEnumerationType
|
||||||
|
ReadNextAtom;
|
||||||
|
end else begin
|
||||||
|
// identifier
|
||||||
|
AtomIsIdentifier(true);
|
||||||
|
ReadNextAtom;
|
||||||
|
if CurPos.Flag=cafPoint then begin
|
||||||
|
ReadNextAtom; // unit.type
|
||||||
|
AtomIsIdentifier(true);
|
||||||
|
ReadNextAtom;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
if not UpAtomIs('OF') then // read 'of'
|
if not UpAtomIs('OF') then // read 'of'
|
||||||
RaiseStringExpectedButAtomFound('"of"');
|
RaiseStringExpectedButAtomFound('"of"');
|
||||||
// read all variants
|
// read all variants
|
||||||
repeat
|
repeat
|
||||||
ReadNextAtom; // read constant (variant identifier)
|
ReadNextAtom; // read constant (variant identifier)
|
||||||
//debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase variant start=',GetAtom]);
|
{$IFDEF VerboseRecordCase}
|
||||||
|
debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase variant start="',GetAtom,'"']);
|
||||||
|
{$ENDIF}
|
||||||
if (CurPos.Flag in [cafRoundBracketClose,cafEnd]) then break;
|
if (CurPos.Flag in [cafRoundBracketClose,cafEnd]) then break;
|
||||||
CreateChildNode;
|
CreateChildNode;
|
||||||
CurNode.Desc:=ctnRecordVariant;
|
CurNode.Desc:=ctnRecordVariant;
|
||||||
@ -4326,7 +4363,9 @@ begin
|
|||||||
// read all variables
|
// read all variables
|
||||||
ReadNextAtom; // read first variable name
|
ReadNextAtom; // read first variable name
|
||||||
repeat
|
repeat
|
||||||
//debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase variable=',GetAtom]);
|
{$IFDEF VerboseRecordCase}
|
||||||
|
debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase variable="',GetAtom,'"']);
|
||||||
|
{$ENDIF}
|
||||||
if (CurPos.Flag=cafRoundBracketClose) then begin
|
if (CurPos.Flag=cafRoundBracketClose) then begin
|
||||||
// end of variant record
|
// end of variant record
|
||||||
end else if UpAtomIs('CASE') then begin
|
end else if UpAtomIs('CASE') then begin
|
||||||
@ -4358,7 +4397,9 @@ begin
|
|||||||
CurNode.EndPos:=CurPos.EndPos;
|
CurNode.EndPos:=CurPos.EndPos;
|
||||||
EndChildNode; // close variable definition
|
EndChildNode; // close variable definition
|
||||||
end;
|
end;
|
||||||
//debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase variable end=',GetAtom]);
|
{$IFDEF VerboseRecordCase}
|
||||||
|
debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase variable end="',GetAtom,'"']);
|
||||||
|
{$ENDIF}
|
||||||
if (CurPos.Flag=cafRoundBracketClose) then begin
|
if (CurPos.Flag=cafRoundBracketClose) then begin
|
||||||
// end of variant record
|
// end of variant record
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
@ -4369,7 +4410,9 @@ begin
|
|||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
until false;
|
until false;
|
||||||
CurNode.EndPos:=CurPos.StartPos;
|
CurNode.EndPos:=CurPos.StartPos;
|
||||||
//debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase variant end=',GetAtom,' ',CurNode.DescAsString,' ',dbgstr(copy(Src,CurNode.StartPos,CurNode.EndPos-CurNode.StartPos))]);
|
{$IFDEF VerboseRecordCase}
|
||||||
|
debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase variant end="',GetAtom,'" ',CurNode.DescAsString,' ',dbgstr(copy(Src,CurNode.StartPos,CurNode.EndPos-CurNode.StartPos))]);
|
||||||
|
{$ENDIF}
|
||||||
EndChildNode; // close variant
|
EndChildNode; // close variant
|
||||||
if (CurPos.Flag in [cafEnd,cafRoundBracketClose]) then
|
if (CurPos.Flag in [cafEnd,cafRoundBracketClose]) then
|
||||||
break;
|
break;
|
||||||
@ -4377,11 +4420,16 @@ begin
|
|||||||
RaiseCharExpectedButAtomFound(';');
|
RaiseCharExpectedButAtomFound(';');
|
||||||
// read next variant
|
// read next variant
|
||||||
until false;
|
until false;
|
||||||
//debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase CLOSE ',GetAtom]);
|
{$IFDEF VerboseRecordCase}
|
||||||
|
debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase CLOSE "',GetAtom,'" at ',CleanPosToStr(CurPos.StartPos)]);
|
||||||
|
{$ENDIF}
|
||||||
if CurPos.Flag=cafEND then
|
if CurPos.Flag=cafEND then
|
||||||
UndoReadNextAtom;
|
UndoReadNextAtom;
|
||||||
CurNode.EndPos:=CurPos.EndPos;
|
CurNode.EndPos:=CurPos.EndPos;
|
||||||
EndChildNode; // close case
|
EndChildNode; // close case
|
||||||
|
{$IFDEF VerboseRecordCase}
|
||||||
|
debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase END CurNode=',CurNode.DescAsString,' Atom="',GetAtom,'" at ',CleanPosToStr(CurPos.StartPos)]);
|
||||||
|
{$ENDIF}
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user