1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-25 02:32:19 -05:00

Simba/PS: Added ERROR directive. Renamed FIXME

to WARNING. The ERROR directive stops the script and jumps to the directive, the
WARNING directive will only print a warning.
This commit is contained in:
Merlijn Wajer 2011-02-21 15:03:42 +01:00
parent 8558ae66d5
commit d7d2491f60

View File

@ -448,7 +448,6 @@ var
begin begin
Result := False; Result := False;
writeln('ProcessDirective called');
if CompareText(DirectiveName,'LOADLIB') = 0 then if CompareText(DirectiveName,'LOADLIB') = 0 then
begin begin
if DirectiveArgs <> '' then if DirectiveArgs <> '' then
@ -465,24 +464,51 @@ begin
else else
psWriteln('Your LoadLib directive has no params, thus cannot find the plugin'); psWriteln('Your LoadLib directive has no params, thus cannot find the plugin');
end end
else if CompareText(DirectiveName,'FIXME') = 0 then else if CompareText(DirectiveName,'WARNING') = 0 then
begin begin
if (sender = nil) or (parser = nil) then if (sender = nil) or (parser = nil) then
begin begin
psWriteln('ERROR: FIXME directive not supported for this interpreter'); psWriteln('ERROR: WARNING directive not supported for this interpreter');
exit(False); exit(False);
end; end;
if (DirectiveArgs <> '') then if (DirectiveArgs <> '') then
begin begin
Result := True; Result := True;
HandleError(Parser.Row, Parser.Col, Parser.Pos, 'FIXME AT ' + DirectiveArgs, errCompile, 'test'); if FileName = '' then
psWriteln(format('FIXME: In file %s: at row: %d, col: %d, pos %d: %s', psWriteln(format('Warning: In %s: at row: %d, col: %d, pos %d: %s',
['Main script', Parser.row, Parser.col,
Parser.pos, DirectiveArgs]))
else
psWriteln(format('Warning: In file %s: at row: %d, col: %d, pos %d: %s',
[FileName, Parser.row, Parser.col, [FileName, Parser.row, Parser.col,
Parser.pos, DirectiveArgs])); Parser.pos, DirectiveArgs]));
//HandleError(Parser.Row + 1, Parser.Col, Parser.Pos, 'Warning at ' + DirectiveArgs, errCompile, FileName);
end;
end else if CompareText(DirectiveName,'ERROR') = 0 then
begin
if (sender = nil) or (parser = nil) then
begin
psWriteln('ERROR: ERROR directive not supported for this interpreter');
exit(False);
end;
if (DirectiveArgs <> '') then
begin
Result := True;
if FileName = '' then
psWriteln(format('Error: In %s: at row: %d, col: %d, pos %d: %s',
['Main script', Parser.row, Parser.col,
Parser.pos, DirectiveArgs]))
else
psWriteln(format('Error: In file %s: at row: %d, col: %d, pos %d: %s',
[FileName, Parser.row, Parser.col,
Parser.pos, DirectiveArgs]));
HandleError(Parser.Row + 1, Parser.Col, Parser.Pos, 'Error at ' + DirectiveArgs, errCompile, FileName);
raise EPSPreProcessor.Create('ERROR directive found');
end; end;
end else end else
Result := True; // If we do not know the directive; return true so Continue Result := False; // If we do not know the directive; return true so Continue
// will be false. // will be false.
end; end;
@ -623,7 +649,9 @@ procedure TPSThread.OnProcessDirective(Sender: TPSPreProcessor;
Parser: TPSPascalPreProcessorParser; const Active: Boolean; Parser: TPSPascalPreProcessorParser; const Active: Boolean;
const DirectiveName, DirectiveParam: string; var Continue: Boolean; Filename: String); const DirectiveName, DirectiveParam: string; var Continue: Boolean; Filename: String);
begin begin
if (CompareText(DirectiveName, 'LOADLIB') = 0) or (CompareText(DirectiveName, 'FIXME') = 0) then if (CompareText(DirectiveName, 'LOADLIB') = 0)
or (CompareText(DirectiveName, 'WARNING') = 0)
or (CompareText(DirectiveName, 'ERROR') = 0) then
Continue := not ProcessDirective(Sender, Parser, DirectiveName,DirectiveParam, Continue := not ProcessDirective(Sender, Parser, DirectiveName,DirectiveParam,
FileName); FileName);
end; end;
@ -640,7 +668,6 @@ procedure TPSThread.PSScriptProcessUnknownDirective(Sender: TPSPreProcessor;
const DirectiveName, DirectiveParam: string; var Continue: Boolean; const DirectiveName, DirectiveParam: string; var Continue: Boolean;
Filename: string); Filename: string);
begin begin
writeln('PSScriptProcessUnknownDirective called');
Continue:= not ProcessDirective(Sender, Parser, DirectiveName, DirectiveParam, Continue:= not ProcessDirective(Sender, Parser, DirectiveName, DirectiveParam,
FileName); FileName);
end; end;