codetools: fixed stack pop

git-svn-id: trunk@27511 -
This commit is contained in:
mattias 2010-09-28 17:12:12 +00:00
parent 0f2583abfe
commit b5a26a3c72
3 changed files with 13 additions and 8 deletions

View File

@ -1273,6 +1273,9 @@ procedure TCTConfigScriptEngine.AddError(const aMsg: string; ErrorPos: PChar);
var
Err: TCTCfgScriptError;
begin
{$IFDEF VerboseCTCfgScript}
WriteDebugReportStack('ERROR: '+aMsg);
{$ENDIF}
Err:=TCTCfgScriptError.Create(aMsg,ErrorPos);
FErrors.Add(Err);
if ErrorCount>=MaxErrorCount then
@ -1369,12 +1372,12 @@ begin
FStack.Push(ctcssBegin,AtomStart);
repeat
ReadRawNextPascalAtom(Src,AtomStart);
//debugln(['TCTConfigScriptEngine.RunBegin ',GetAtom]);
if (AtomStart^=#0) then begin
ErrorMissingEnd;
break;
end else if CompareIdentifiers('END',AtomStart)=0 then begin
FStack.Pop;
ReadRawNextPascalAtom(Src,AtomStart);
break;
end else if AtomStart=';' then begin
// skip
@ -1444,6 +1447,7 @@ begin
exit;
end;
Variables.Undefine(VarStart);
ReadRawNextPascalAtom(Src,AtomStart);
end;
procedure TCTConfigScriptEngine.RunAssignment(Skip: boolean);
@ -1751,7 +1755,9 @@ function TCTConfigScriptEngine.RunExpression: boolean;
ctcssExpression,ctcssOperator,ctcssRoundBracketOpen:
Result:=true;
else
{$IFDEF VerboseCTCfgScript}
debugln(['TCTConfigScriptEngine.RunExpression.OperandAllowed no']);
{$ENDIF}
AddError('operator expected but '+GetAtom+' found');
Result:=false;
end;
@ -1763,7 +1769,9 @@ function TCTConfigScriptEngine.RunExpression: boolean;
ctcssOperand:
Result:=true;
else
{$IFDEF VerboseCTCfgScript}
debugln(['TCTConfigScriptEngine.RunExpression.BinaryOperatorAllowed no']);
{$ENDIF}
AddError('operand expected but '+GetAtom+' found');
Result:=false;
end;
@ -2188,7 +2196,7 @@ begin
begin
if (FStack.Top>=2) then begin
LeftOperandItem:=@FStack.Items[FStack.Top-2];
// add right operand to left oprerand on stack
// add right operand to left operand on stack
AddCTCSVariables(@OperandItem^.Operand,@LeftOperandItem^.Operand);
// remove right operand and +
FStack.Pop(2);
@ -2465,7 +2473,7 @@ begin
ReAllocMem(Item^.Operand.Name,0);
dec(Top);
if Top>=0 then
TopTyp:=Items[0].Typ
TopTyp:=Items[Top].Typ
else
TopTyp:=ctcssNone;
dec(Count);

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="8"/>
<Version Value="9"/>
<General>
<Flags>
<MainUnitHasUsesSectionForAllUnits Value="False"/>
@ -11,12 +11,8 @@
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<TargetFileExt Value=""/>
<Title Value="runcfgscript"/>
</General>
<VersionInfo>
<StringTable Comments="" CompanyName="" FileDescription="" FileVersion="0.0.0.0" InternalName="" LegalCopyright="" LegalTrademarks="" OriginalFilename="" ProductName="" ProductVersion="0.0.0.0"/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>

View File

@ -60,6 +60,7 @@ begin
Engine:=TCTConfigScriptEngine.Create;
try
//Engine.MaxErrorCount:=0;
if not Engine.Execute(Src) then begin
writeln('Script failed to run:');
for i:=0 to Engine.ErrorCount-1 do