Package: src/packages/flx_flxg.fdoc
key | file |
---|---|
flx_flxg.flx | share/lib/std/felix/flx_flxg.flx |
A wrapper around the {flxg} command line compiler executable.
.. index:: Flxg(class)
.. index:: def(type)
.. index:: run_felix_compiler(gen)
//[flx_flxg.flx]
class Flxg
{
typedef flxg_spec_t =
(
INLINE:int,
OUTPUT_DIR:string,
BUNDLE_DIR:opt[string],
CACHE_DIR:string,
COMPILER_PHASE:string,
DOREDUCE:int,
FLXG:string,
VERBOSE:list[string],
STDGRAMMAR:string,
AUTOMATON:string,
IMPORTS:list[string],
FLXLIBS:list[string],
INCLUDE_DIRS:list[string],
TIME:int,
FORCE:int,
FLAGS: list[string],
filebase:string,
use_ext:string,
debugln: string -> 0
);
gen run_felix_compiler (spec:flxg_spec_t) : int =
{
var FLXFLAGS=spec.FLAGS + (list[string]$ "--inline="+str(spec.INLINE));
if spec.OUTPUT_DIR != "" do
FLXFLAGS += '--output_dir=' + str(spec.OUTPUT_DIR);
done
match spec.BUNDLE_DIR with
| Some dir =>
FLXFLAGS += '--bundle_dir=' + dir;
| #None=> ;
endmatch;
if spec.CACHE_DIR != "" do
FLXFLAGS +="--cache_dir=" + spec.CACHE_DIR;
done
if spec.COMPILER_PHASE != "" do
FLXFLAGS += '--compiler-phase=' + spec.COMPILER_PHASE;
done
if spec.DOREDUCE == 0 do
FLXFLAGS += '--no-reduce';
done
if spec.TIME == 1 do
FLXFLAGS += '--time';
done
if spec.FORCE == 1 do
FLXFLAGS += '--force';
done
var cmd =
spec.FLXG !
spec.VERBOSE +
FLXFLAGS +
map (fun (s:string) => "-I"+s) spec.INCLUDE_DIRS +
("--syntax="+spec.STDGRAMMAR) +
("--automaton="+spec.AUTOMATON) +
map (fun (s:string) => "--import="+s) spec.IMPORTS +
spec.FLXLIBS +
(spec.filebase + spec.use_ext)
;
var CMD = catmap ' ' Shell::quote_arg cmd;
spec.debugln$ "Felix command="+CMD;
var result=System::system(CMD);
if result != 0 do
eprintln$ "Felix compilation "+CMD+" failed";
done
return result;
}
}