Add an empty cstdlib.elna source file
This commit is contained in:
@@ -3,24 +3,20 @@
|
||||
obtain one at https://mozilla.org/MPL/2.0/. *)
|
||||
module;
|
||||
|
||||
from Args import GetArg, Narg;
|
||||
from FIO import WriteString, WriteChar, WriteLine, StdErr;
|
||||
from Strings import CompareStr, Length;
|
||||
from MemUtils import MemZero;
|
||||
|
||||
from Common import ShortString;
|
||||
import cstdlib, common;
|
||||
|
||||
type
|
||||
CommandLine = record
|
||||
input: ShortString;
|
||||
output: ShortString;
|
||||
input: ^Char;
|
||||
output: ^Char;
|
||||
lex: Bool;
|
||||
parse: Bool
|
||||
end;
|
||||
|
||||
proc parse_command_line*() -> ^CommandLine;
|
||||
proc parse_command_line*(argc: Int, argv: ^^Char) -> ^CommandLine;
|
||||
var
|
||||
parameter: ShortString;
|
||||
parameter: ^Char;
|
||||
i: Word;
|
||||
result: ^CommandLine;
|
||||
parsed: Bool;
|
||||
@@ -29,43 +25,43 @@ begin
|
||||
NEW(result);
|
||||
result^.lex := false;
|
||||
result^.parse := false;
|
||||
MemZero(@result^.input, 256);
|
||||
memset(@result^.input, 0, 256);
|
||||
result^.output[1] := CHAR(0);
|
||||
|
||||
while (i < Narg()) & (result <> nil) do
|
||||
parsed := GetArg(parameter, i);
|
||||
while i < argc & result <> nil do
|
||||
parameter := (argv + i)^;
|
||||
parsed := false;
|
||||
|
||||
if CompareStr(parameter, '--lex') = 0 then
|
||||
if strcmp(parameter, "--lex\0".ptr) = 0 then
|
||||
parsed := true;
|
||||
result^.lex := true
|
||||
end;
|
||||
if CompareStr(parameter, '--parse') = 0 then
|
||||
if strcmp(parameter, "--parse\0".ptr) = 0 then
|
||||
parsed := true;
|
||||
result^.parse := true
|
||||
end;
|
||||
if CompareStr(parameter, '-o') = 0 then
|
||||
if strcmp(parameter, "-o\0".ptr) = 0 then
|
||||
i := i + 1u;
|
||||
|
||||
if i = Narg() then
|
||||
WriteString(StdErr, 'Fatal error: expecting a file name following -o.');
|
||||
if i = argc then
|
||||
WriteString(StdErr, "Fatal error: expecting a file name following -o.");
|
||||
result := nil
|
||||
end;
|
||||
if i < Narg() then
|
||||
parsed := GetArg(parameter, i);
|
||||
if i < argc then
|
||||
parameter := (argv + i)^;
|
||||
result^.output := parameter
|
||||
end;
|
||||
parsed := true
|
||||
end;
|
||||
if (parameter[1] <> '-') & (parsed = false) then
|
||||
if (parameter[1] <> '-') & ~parsed then
|
||||
parsed := true;
|
||||
|
||||
if Length(result^.input) > 0 then
|
||||
WriteString(StdErr, 'Fatal error: only one source file can be compiled at once. First given "');
|
||||
if result^.input <> nil then
|
||||
WriteString(StdErr, "Fatal error: only one source file can be compiled at once. First given \"");
|
||||
WriteString(StdErr, result^.input);
|
||||
WriteString(StdErr, '", then "');
|
||||
WriteString(StdErr, "\", then \"");
|
||||
WriteString(StdErr, parameter);
|
||||
WriteString(StdErr, '".');
|
||||
WriteString(StdErr, "\".");
|
||||
WriteLine(StdErr);
|
||||
result := nil
|
||||
end;
|
||||
@@ -73,8 +69,8 @@ begin
|
||||
result^.input := parameter
|
||||
end
|
||||
end;
|
||||
if parsed = false then
|
||||
WriteString(StdErr, 'Fatal error: unknown command line options: ');
|
||||
if ~parsed then
|
||||
WriteString(StdErr, "Fatal error: unknown command line options: ");
|
||||
|
||||
WriteString(StdErr, parameter);
|
||||
WriteChar(StdErr, '.');
|
||||
@@ -83,10 +79,10 @@ begin
|
||||
result := nil
|
||||
end;
|
||||
|
||||
i := i + 1
|
||||
i := i + 1u
|
||||
end;
|
||||
if (result <> nil) & (Length(result^.input) = 0) then
|
||||
WriteString(StdErr, 'Fatal error: no input files.');
|
||||
if result <> nil & result^.input = nil then
|
||||
WriteString(StdErr, "Fatal error: no input files.");
|
||||
WriteLine(StdErr);
|
||||
result := nil
|
||||
end;
|
||||
|
Reference in New Issue
Block a user