2016-11-11 19:17:10 +00:00
|
|
|
clibrary {
|
|
|
|
name = "headers",
|
LLgen: use size_t, reduce warnings, other small changes
Use C89 size_t for sizes from sizeof() or to malloc() or realloc().
Remove obsolete (unsigned) casts. Sizes were unsigned int in
traditional C but are size_t in C89.
Silence some clang warnings. Add the second pair of round brackets in
`while ((ff = ff->ff_next))` to silence -Wparentheses. Change
`if (nc_first(...))/*nothing*/;` to `(void)nc_first(...);` to silence
-Wempty-body. The code in compute.c nc_first() had the form
`if (x) if (y) s; else t;`. The old indentation (before 10717cc)
suggests that the "else" belongs to the 2nd "if", so add braces like
`if (x) { if (y) s; else t; }` to silence -Wdangling-else.
Shuffle extern function declarations. Add missing declaration for
LLparse(). Stop declaring RENAME(); it doesn't exist. Move some
declarations from main.c to extern.h, so the C compiler may check that
the declarations are compatible with the function definitions.
Assume that standard C89 remove() is available and doesn't need the
UNLINK() wrapper.
In lib/incl, don't need to include <stdio.h> nor <stdlib.h> to use
assert().
Remove alloc.h. If you don't clean your build, then an outdated
BUILDDIR/obj/util/LLgen/headers/alloc.h will survive but should not
cause harm, because nothing includes it. Don't need to remove alloc.h
from util/LLgen/distr.sh, because it isn't there.
Run the bootstrap to rebuild LLgen.c, Lpars.c, tokens.c.
2019-10-22 16:56:50 +00:00
|
|
|
hdrs = { "./src/*.h" } -- rm alloc.h
|
2016-11-11 19:17:10 +00:00
|
|
|
}
|
|
|
|
|
2016-07-14 21:54:13 +00:00
|
|
|
cprogram {
|
|
|
|
name = "llgen",
|
|
|
|
|
2019-10-21 22:15:52 +00:00
|
|
|
-- These use pre-LLgen'd versions of LLgen.c, Lpars.c, Lpars.h, and
|
|
|
|
-- tokens.c. If LLgen.g or tokens.g gets updated, they need
|
|
|
|
-- rebuilding. Use the bootstrap target to do this.
|
2016-07-14 21:54:13 +00:00
|
|
|
|
|
|
|
srcs = { "./src/*.c" },
|
2016-11-11 19:17:10 +00:00
|
|
|
deps = { "+headers" },
|
2016-07-26 22:10:15 +00:00
|
|
|
vars = {
|
|
|
|
["+cflags"] = {
|
|
|
|
"-DLIBDIR=\\\""..posix.getcwd().."/"..cwd().."/lib\\\"",
|
|
|
|
"-DNON_CORRECTING"
|
|
|
|
},
|
|
|
|
}
|
2016-07-14 21:54:13 +00:00
|
|
|
}
|
|
|
|
|
2019-10-21 22:15:52 +00:00
|
|
|
-- This bootstrap target rebuilds LLgen's own parser with LLgen.
|
|
|
|
-- It acts like ./bootstrap.sh but without installing LLgen in PATH.
|
|
|
|
normalrule {
|
|
|
|
name = "bootstrap",
|
|
|
|
ins = "+llgen",
|
|
|
|
outleaves = { "phony" },
|
|
|
|
commands = {
|
|
|
|
"cd %{abspath(cwd()..\"/src\")}",
|
|
|
|
"%{abspath(ins)} -vvv -x tokens.g LLgen.g",
|
|
|
|
"echo",
|
|
|
|
"echo You should now be able to rebuild LLgen with the new parser.",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-14 21:54:13 +00:00
|
|
|
definerule("llgen",
|
|
|
|
{
|
|
|
|
srcs = { type="targets" },
|
|
|
|
},
|
|
|
|
function(e)
|
|
|
|
-- Remember this is executed from the caller's directory; local
|
|
|
|
-- target names will resolve there
|
2016-08-04 21:51:19 +00:00
|
|
|
local fs = replace(basename(filenamesof(e.srcs)), "%.g$", "")
|
2016-07-14 21:54:13 +00:00
|
|
|
|
|
|
|
return normalrule {
|
|
|
|
name = e.name,
|
|
|
|
cwd = e.cwd,
|
|
|
|
outleaves = {
|
|
|
|
"Lpars.c",
|
|
|
|
"Lpars.h",
|
2016-08-04 21:51:19 +00:00
|
|
|
replace(fs, "$", ".c")
|
2016-07-14 21:54:13 +00:00
|
|
|
},
|
|
|
|
ins = {
|
|
|
|
"util/LLgen+llgen",
|
2016-08-04 21:51:19 +00:00
|
|
|
e.srcs,
|
2016-07-14 21:54:13 +00:00
|
|
|
},
|
|
|
|
commands = {
|
2017-11-15 18:41:39 +00:00
|
|
|
"cd %{dir} && rm -f %{outs} && %{abspath(ins)}"
|
2016-07-14 21:54:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
)
|