From b5a26a3c72f5ef4d865d3d2f1290640e95ef8f44 Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 28 Sep 2010 17:12:12 +0000 Subject: [PATCH] codetools: fixed stack pop git-svn-id: trunk@27511 - --- components/codetools/codetoolscfgscript.pas | 14 +++++++++++--- components/codetools/examples/runcfgscript.lpi | 6 +----- components/codetools/examples/runcfgscript.lpr | 1 + 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/components/codetools/codetoolscfgscript.pas b/components/codetools/codetoolscfgscript.pas index 18190d65aa..4a52995b17 100644 --- a/components/codetools/codetoolscfgscript.pas +++ b/components/codetools/codetoolscfgscript.pas @@ -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); diff --git a/components/codetools/examples/runcfgscript.lpi b/components/codetools/examples/runcfgscript.lpi index 4fd2585924..69246c7762 100644 --- a/components/codetools/examples/runcfgscript.lpi +++ b/components/codetools/examples/runcfgscript.lpi @@ -1,7 +1,7 @@ - + @@ -11,12 +11,8 @@ - </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)"/> diff --git a/components/codetools/examples/runcfgscript.lpr b/components/codetools/examples/runcfgscript.lpr index 8e1a57bb10..d9ec316f98 100644 --- a/components/codetools/examples/runcfgscript.lpr +++ b/components/codetools/examples/runcfgscript.lpr @@ -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