MG: fixed nested record parsing

git-svn-id: trunk@1459 -
This commit is contained in:
lazarus 2002-02-25 18:46:06 +00:00
parent fbfb9e8cbf
commit 386a8e08f4
4 changed files with 23 additions and 9 deletions

View File

@ -1740,7 +1740,8 @@ end;
function TDefinePool.CreateLazarusSrcTemplate(
const LazarusSrcDir, WidgetType: string): TDefineTemplate;
const ds: char = PathDelim;
const
ds: char = PathDelim;
var MainDir, DirTempl, SubDirTempl: TDefineTemplate;
TargetOS, SrcPath: string;
begin
@ -1790,12 +1791,12 @@ begin
+'include',da_Define));
MainDir.AddChild(DirTempl);
// Widget Directory
// lcl/interfaces
SubDirTempl:=TDefineTemplate.Create('Widget Directory','Widget Directory',
'','interfaces'+ds+WidgetType,da_Directory);
'','interfaces',da_Directory);
SubDirTempl.AddChild(TDefineTemplate.Create('LCL Path',
'adds lcl to SrcPath','SrcPath',
'..'+ds+'..;'+SrcPath,da_Define));
'adds lcl to SrcPath',ExternalMacroStart+'SrcPath',
LazarusSrcDir+ds+'lcl;'+SrcPath,da_DefineAll));
DirTempl.AddChild(SubDirTempl);
// components

View File

@ -41,7 +41,7 @@ interface
{ $DEFINE CTDEBUG}
{ $DEFINE ShowSearchPaths}
{ $DEFINE ShowTriedFiles}
{$DEFINE ShowTriedFiles}
{ $DEFINE ShowTriedContexts}
{ $DEFINE ShowExprEval}
{ $DEFINE ShowFoundIdentifier}

View File

@ -1279,7 +1279,7 @@ var
ExpFilename:=APath+AFilename;
if not FilenameIsAbsolute(ExpFilename) then
ExpFilename:=ExtractFilePath(FMainSourceFilename)+ExpFilename;
NewCode:=LoadSourceCaseSensitive(ExpFilename);
NewCode:=LoadSourceCaseSensitive(ExpandFilename(ExpFilename));
Result:=NewCode<>nil;
end;
@ -1300,7 +1300,8 @@ var
// filename is relative
// first search file in the directory of the main source
if FilenameIsAbsolute(FMainSourceFilename) then begin
ExpFilename:=ExtractFilePath(FMainSourceFilename)+AFilename;
ExpFilename:=
ExpandFilename(ExtractFilePath(FMainSourceFilename)+AFilename);
NewCode:=LoadSourceCaseSensitive(ExpFilename);
if NewCode<>nil then exit;
end;

View File

@ -2713,6 +2713,7 @@ begin
end;
function TPascalParserTool.KeyWordFuncTypeRecordCase: boolean;
var s: string;
begin
if not UpAtomIs('CASE') then
RaiseException('[TPascalParserTool.KeyWordFuncTypeRecordCase] '
@ -2721,6 +2722,8 @@ begin
CurNode.Desc:=ctnRecordCase;
ReadNextAtom; // read ordinal type
AtomIsIdentifier(true);
s:=GetAtom;
writeln('TPascalParserTool.KeyWordFuncTypeRecordCase ',s);
ReadNextAtom;
if AtomIsChar(':') then begin
ReadNextAtom;
@ -2732,7 +2735,8 @@ begin
// read all variants
repeat
ReadNextAtom; // read constant (variant identifier)
if UpAtomIs('END') then break;
writeln('%%%%% Variant=',GetAtom);
if AtomIsChar(')') or UpAtomIs('END') then break;
CreateChildNode;
CurNode.Desc:=ctnRecordVariant;
repeat
@ -2750,14 +2754,18 @@ begin
ReadNextAtom; // read first variable name
repeat
if AtomIsChar(')') then begin
writeln('%%%%% End of Variant ',GetAtom);
// end of variant record
break;
end else if UpAtomIs('CASE') then begin
// sub record variant
writeln('%%%%% SubCase ',GetAtom);
KeyWordFuncTypeRecordCase();
writeln('%%%%% Return from SubCase ',GetAtom);
break;
end else begin
// sub identifier
writeln('%%%%% SubIdentifier ',GetAtom);
repeat
AtomIsIdentifier(true);
CreateChildNode;
@ -2774,6 +2782,7 @@ begin
ReadNextAtom; // read type
Result:=TypeKeyWordFuncList.DoItUpperCase(UpperSrc,CurPos.StartPos,
CurPos.EndPos-CurPos.StartPos);
writeln('%%%%% End of Type ',GetAtom);
if not Result then exit;
CurNode.EndPos:=CurPos.EndPos;
EndChildNode; // close variable definition
@ -2782,10 +2791,12 @@ begin
if not AtomIsChar(';') then
RaiseException('; expected, but '+GetAtom+' found');
ReadNextAtom;
writeln('%%%%% C ',GetAtom);
until false;
if not AtomIsChar(')') then
RaiseException(') expected, but '+GetAtom+' found');
ReadNextAtom;
writeln('%%%%% CloseVariant ',GetAtom);
if UpAtomIs('END') or AtomIsChar(')') then begin
CurNode.EndPos:=CurPos.StartPos;
EndChildNode; // close variant
@ -2799,6 +2810,7 @@ begin
until false;
CurNode.EndPos:=CurPos.EndPos;
EndChildNode; // close case
writeln('TPascalParserTool.KeyWordFuncTypeRecordCase END ',s);
Result:=true;
end;