mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-11 19:28:58 +02:00
codetools: cfgscript: nicer error message if semicolon is missing
git-svn-id: trunk@37390 -
This commit is contained in:
parent
752c8adef7
commit
b88a39ccca
@ -30,7 +30,7 @@
|
||||
boolean operators: not, and, or, xor
|
||||
operators: =, <>, >, <, <=, >=, +
|
||||
variables
|
||||
constants: decimal, hex, octal, binary, string, #decimal
|
||||
constants: decimal, $hex, &octal, %binary, 'string', #character
|
||||
functions: string(), integer(), int64(), defined(), undefined()
|
||||
procedures: undefine()
|
||||
assignments: :=, +=
|
||||
@ -1328,7 +1328,7 @@ procedure TCTConfigScriptEngine.RunStatement(Skip: boolean);
|
||||
|
||||
procedure ErrorUnexpectedAtom;
|
||||
begin
|
||||
AddError(Format(ctsExpectedStatementButFound, [GetAtomOrNothing]))
|
||||
AddError(Format(ctsExpectedSemicolonOfStatementButFound, [GetAtomOrNothing]))
|
||||
end;
|
||||
|
||||
var
|
||||
@ -1505,7 +1505,7 @@ begin
|
||||
{$IFDEF VerboseCTCfgScript}
|
||||
debugln(['TCTConfigScriptEngine.RunAssignment Operator=',GetAtom]);
|
||||
{$ENDIF}
|
||||
// read :=
|
||||
// read := or +=
|
||||
if AtomStart^=#0 then begin
|
||||
AddError(ctsMissing);
|
||||
exit;
|
||||
@ -1530,7 +1530,7 @@ begin
|
||||
end;
|
||||
|
||||
{$IFDEF VerboseCTCfgScript}
|
||||
debugln(['TCTConfigScriptEngine.RunAssignment AFTER ',GetIdentifier(VarStart),' = ',dbgs(Variable)]);
|
||||
debugln(['TCTConfigScriptEngine.RunAssignment AFTER ',GetIdentifier(VarStart),' = ',dbgs(Variable),' Atom=',GetAtom]);
|
||||
{$ENDIF}
|
||||
end;
|
||||
// clean up stack
|
||||
@ -2296,6 +2296,12 @@ end;
|
||||
|
||||
function TCTConfigScriptEngine.Execute(const Source: string;
|
||||
StopAfterErrors: integer): boolean;
|
||||
|
||||
procedure ExpectedSemicolon;
|
||||
begin
|
||||
AddError(Format(ctsExpectedSemicolonOfStatementButFound, [GetAtomOrNothing]))
|
||||
end;
|
||||
|
||||
var
|
||||
Err: TCTCfgScriptError;
|
||||
begin
|
||||
@ -2319,6 +2325,8 @@ begin
|
||||
ReadRawNextPascalAtom(Src,AtomStart);
|
||||
while Src^<>#0 do begin
|
||||
RunStatement(false);
|
||||
if not (AtomStart^ in [#0,';']) then
|
||||
ExpectedSemicolon;
|
||||
ReadRawNextPascalAtom(Src,AtomStart);
|
||||
end;
|
||||
except
|
||||
|
@ -165,7 +165,7 @@ ResourceString
|
||||
ctsPropertyCurrentNotFound = 'property Current not found';
|
||||
ctsEnumerationType = 'enumeration type';
|
||||
ctsType = 'type';
|
||||
ctsExpectedStatementButFound = 'expected statement, but found %s';
|
||||
ctsExpectedSemicolonOfStatementButFound = 'expected ; of statement, but found %s';
|
||||
ctsUnexpectedKeyword2 = 'unexpected keyword %s';
|
||||
ctsBeginAtWithoutEnd = 'begin at %s without end';
|
||||
ctsThenExpectedButFound = 'then expected, but %s found';
|
||||
|
@ -355,8 +355,8 @@ msgstr ""
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
|
@ -356,8 +356,8 @@ msgstr ""
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
|
@ -357,9 +357,9 @@ msgstr ":= erwartet, aber %s gefunden"
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr "Bezeichner erwartet, aber %s gefunden"
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
msgstr "Anweisung erwartet, aber %s gefunden"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
msgid "exports clause only allowed in libraries"
|
||||
|
@ -355,8 +355,8 @@ msgstr ""
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
|
@ -348,8 +348,8 @@ msgstr ""
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
|
@ -356,8 +356,8 @@ msgstr ""
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
|
@ -355,9 +355,9 @@ msgstr "מחכה ל =:, אבל נמצא %s"
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr "מחכה למזהה, אבל נמצא %s"
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
msgstr "מחכה למשפט, אבל נמצא %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
msgid "exports clause only allowed in libraries"
|
||||
|
@ -356,8 +356,8 @@ msgstr ""
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
|
@ -353,8 +353,8 @@ msgstr "era atteso :=, ma è stato trovato %s"
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr "era atteso un identificatore, ma è stato trovato %s"
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
|
@ -356,8 +356,8 @@ msgstr ""
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
|
@ -355,8 +355,8 @@ msgstr ""
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
|
@ -359,8 +359,8 @@ msgstr ""
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
|
@ -348,8 +348,8 @@ msgstr ""
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
|
@ -355,9 +355,9 @@ msgstr "\":=\" esperado, mas %s encontrado"
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr "identificador esperado, mas encontrado %s"
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
msgstr "declaração esperada, mas encontrado %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
msgid "exports clause only allowed in libraries"
|
||||
|
@ -354,9 +354,9 @@ msgstr "\":=\" esperado, mas %s encontrado"
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr "identificador esperado, mas encontrado %s"
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
msgstr "declaração esperada, mas encontrado %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
msgid "exports clause only allowed in libraries"
|
||||
|
@ -354,9 +354,9 @@ msgstr "ожидается оператор :=, но найдено %s"
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr "ожидается идентификатор, но найдено %s"
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
msgstr "ожидается оператор, но найдено %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
msgid "exports clause only allowed in libraries"
|
||||
|
@ -354,8 +354,8 @@ msgstr ""
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
|
@ -356,9 +356,9 @@ msgstr "очікується :=, але знайдено %s"
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr "очікується ідентифікатор, але знайдено %s"
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
msgstr "очікується інструкція, але знайдено %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
msgid "exports clause only allowed in libraries"
|
||||
|
@ -358,8 +358,8 @@ msgstr ""
|
||||
msgid "expected identifier, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexpectedstatementbutfound
|
||||
msgid "expected statement, but found %s"
|
||||
#: codetoolsstrconsts.ctsexpectedsemicolonofstatementbutfound
|
||||
msgid "expected ; of statement, but found %s"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsexportsclauseonlyallowedinlibraries
|
||||
|
@ -2178,6 +2178,12 @@ begin
|
||||
s:=GetDefaultTargetCPU;
|
||||
Result.Values['TargetCPU']:=s;
|
||||
end;
|
||||
// IDE values
|
||||
{Result.Values['IDEOS']:=GetCompiledTargetOS;
|
||||
Result.Values['IDESrcOS']:=GetDefaultSrcOSForTargetOS(GetCompiledTargetOS);
|
||||
Result.Values['IDESrcOS2']:=GetDefaultSrcOS2ForTargetOS(GetCompiledTargetOS);
|
||||
Result.Values['IDECPU']:=GetCompiledTargetCPU;
|
||||
Result.Values['IDELCLWidgetType']:=LCLPlatformDirNames(GetDefaultLCLWidgetType);}
|
||||
|
||||
{$IFDEF VerboseBuildMacros}
|
||||
Result.WriteDebugReport('OnGetBuildMacroValues project values');
|
||||
|
@ -22,6 +22,7 @@ type
|
||||
TTestCodetoolsCfgScript = class(TTestCase)
|
||||
protected
|
||||
procedure TestResult(Script, ExpectedResult: string);
|
||||
procedure TestSyntaxError(Script, ExpectedError: string);
|
||||
published
|
||||
procedure TestCfgScript;
|
||||
end;
|
||||
@ -55,12 +56,31 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTestCodetoolsCfgScript.TestSyntaxError(Script, ExpectedError: string
|
||||
);
|
||||
var
|
||||
Engine: TCTConfigScriptEngine;
|
||||
begin
|
||||
Engine:=TCTConfigScriptEngine.Create;
|
||||
try
|
||||
Engine.MaxErrorCount:=1;
|
||||
if Engine.Execute(Script) then begin
|
||||
AssertEquals('Syntax error in script not recognized: "'+Script+'"',true,false);
|
||||
end else begin
|
||||
//writeln('TTestCodetoolsCfgScript.TestSyntaxError ',Engine.Errors[0].Msg);
|
||||
AssertEquals(Script,ExpectedError,Engine.Errors[0].Msg);
|
||||
end;
|
||||
finally
|
||||
Engine.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTestCodetoolsCfgScript.TestCfgScript;
|
||||
begin
|
||||
TestResult('Result:=2;','2');
|
||||
TestResult('a:=2; b:=a; Result:=b;','2');
|
||||
TestResult('Result:=1+2;','3');
|
||||
//TestResult('Result:=1+2*3;','7');
|
||||
TestSyntaxError('{invalid operator * }Result:=2*3;','expected ; of statement, but found *');
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
@ -120,6 +120,9 @@
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="$MakeExe(runtests)"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<OtherUnitFiles Value="bugs;lcltests;codetoolstests;lazutils"/>
|
||||
<UnitOutputDirectory Value="units\$(TargetCPU)-$(TargetOS)"/>
|
||||
|
Loading…
Reference in New Issue
Block a user