2024-02-02 05:57:46 +00:00
|
|
|
program main;
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
2024-02-12 15:57:30 +00:00
|
|
|
uses HCL, SysUtils;
|
2024-02-02 05:57:46 +00:00
|
|
|
|
|
|
|
var
|
|
|
|
x: HCL.Interp = nil;
|
|
|
|
begin
|
2024-02-12 15:57:30 +00:00
|
|
|
(* System.ParamCount() returns only the number of argumetns except System.ParamStr(0). It is the upper bound to System.ParamStr(). *)
|
|
|
|
if System.ParamCount() <> 1 then begin
|
|
|
|
writeln (System.Stderr, SysUtils.Format('Usage: %s <filename>', [SysUtils.ExtractFileName(System.ParamStr(0))]));
|
|
|
|
System.Halt(-1);
|
|
|
|
end;
|
|
|
|
|
2024-02-02 05:57:46 +00:00
|
|
|
try
|
|
|
|
x := HCL.Interp.Create(100);
|
|
|
|
x.Ignite(0);
|
|
|
|
|
|
|
|
x.AddBuiltinPrims();
|
|
|
|
//x.AttachCCIO();
|
|
|
|
//x.AttachUDIO();
|
|
|
|
|
2024-02-12 15:57:30 +00:00
|
|
|
(*
|
2024-02-02 05:57:46 +00:00
|
|
|
x.Compile(pwidechar('(printf "hello 동키콩\n")'));
|
2024-02-03 04:36:05 +00:00
|
|
|
x.Compile('(printf "hello 동키콩월드\n") ');
|
|
|
|
x.Compile('(동가리오 := 20)');
|
2024-02-11 07:39:16 +00:00
|
|
|
x.Compile('(printf "%d %d\n" 동가리오 (+ 동가리오 동가리오))');
|
|
|
|
|
|
|
|
x.Compile(pwidechar('(printf "%d %d\n" 동가리오 (동가리오 * 동가리오))'#10'printf "hello, world\n";;;'#10));
|
2024-02-12 15:57:30 +00:00
|
|
|
*)
|
2024-02-02 05:57:46 +00:00
|
|
|
|
2024-02-12 15:57:30 +00:00
|
|
|
x.CompileFile(pansichar(ansistring(System.ParamStr(1))));
|
2024-02-03 04:36:05 +00:00
|
|
|
x.Execute(); // check if exception...
|
2024-02-02 05:57:46 +00:00
|
|
|
except
|
|
|
|
on e: Exception do
|
2024-02-12 15:57:30 +00:00
|
|
|
writeln ('exception: ', e.Message);
|
2024-02-02 05:57:46 +00:00
|
|
|
else
|
|
|
|
writeln ('unknonw exception');
|
|
|
|
end;
|
|
|
|
|
|
|
|
if x <> nil then x.Destroy();
|
|
|
|
end.
|