yacc, ncgg; platform ncg builds now.
This commit is contained in:
parent
bff5c4019c
commit
a8a9d1bbfa
|
@ -20,4 +20,25 @@ definerule("yacc",
|
|||
end
|
||||
)
|
||||
|
||||
definerule("flex",
|
||||
{
|
||||
srcs = { type="targets" },
|
||||
commands = {
|
||||
type="strings",
|
||||
default={
|
||||
"flex -s -t %{ins} > %{outs[1]}"
|
||||
}
|
||||
}
|
||||
},
|
||||
function (e)
|
||||
return normalrule {
|
||||
name = e.name,
|
||||
cwd = e.cwd,
|
||||
ins = e.srcs,
|
||||
outleaves = { "lex.yy.c" },
|
||||
label = e.label,
|
||||
commands = e.commands
|
||||
}
|
||||
end
|
||||
)
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ clibrary {
|
|||
name = "emheaders",
|
||||
hdrs = {
|
||||
"./*.h",
|
||||
"./con_float",
|
||||
"+em_path",
|
||||
"+local",
|
||||
}
|
||||
|
|
45
mach/proto/ncg/build.lua
Normal file
45
mach/proto/ncg/build.lua
Normal file
|
@ -0,0 +1,45 @@
|
|||
include("util/ncgg/build.lua")
|
||||
|
||||
definerule("build_ncg",
|
||||
{
|
||||
arch = { type="string" }
|
||||
},
|
||||
function(e)
|
||||
-- Remember this is executed from the caller's directory; local
|
||||
-- target names will resolve there
|
||||
local headers = clibrary {
|
||||
name = e.name.."/headers",
|
||||
srcs = {},
|
||||
hdrs = {
|
||||
"mach/proto/ncg/*.h",
|
||||
"mach/"..e.arch.."/ncg/mach*"
|
||||
}
|
||||
}
|
||||
|
||||
local tables = ncgg {
|
||||
name = e.name.."/tables",
|
||||
srcs = { "mach/"..e.arch.."/ncg/table" }
|
||||
}
|
||||
|
||||
return cprogram {
|
||||
name = e.name,
|
||||
srcs = {
|
||||
"mach/proto/ncg/*.c",
|
||||
"mach/"..e.arch.."/ncg/mach.h",
|
||||
archlib, -- for .c file
|
||||
tables, -- for .c file
|
||||
},
|
||||
deps = {
|
||||
"h+emheaders",
|
||||
"modules+headers",
|
||||
"modules/src/flt_arith+lib",
|
||||
"modules/src/object+lib",
|
||||
"util/data+em_data",
|
||||
archlib, -- for .h file
|
||||
headers,
|
||||
tables, -- for .h file
|
||||
}
|
||||
}
|
||||
end
|
||||
)
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
include("mach/proto/as/build.lua")
|
||||
include("mach/proto/ncg/build.lua")
|
||||
|
||||
definerule("build_plat",
|
||||
{
|
||||
arch = { type = "string" },
|
||||
plat = { type = "string" },
|
||||
},
|
||||
function(e)
|
||||
local descr = "plat/"..e.plat.."/descr"
|
||||
|
||||
local as = build_as {
|
||||
name = "as",
|
||||
arch = e.arch
|
||||
}
|
||||
|
||||
local ncg = build_ncg {
|
||||
name = "ncg",
|
||||
arch = e.arch,
|
||||
}
|
||||
|
||||
local tools = installable {
|
||||
name = "tools",
|
||||
map = {
|
||||
["$(PLATDEP)/"..e.arch.."/as"] = as,
|
||||
["$(PLATDEP)/"..e.plat.."/ncg"] = ncg,
|
||||
["$(PLATIND)/descr/"..e.plat.."/descr"] = descr,
|
||||
}
|
||||
}
|
||||
|
||||
local libraries = installable {
|
||||
name = "libraries",
|
||||
map = {
|
||||
}
|
||||
}
|
||||
|
||||
return installable {
|
||||
name = e.name,
|
||||
map = {
|
||||
tools,
|
||||
libraries,
|
||||
}
|
||||
}
|
||||
end
|
||||
)
|
||||
|
|
@ -1,14 +1,7 @@
|
|||
include("mach/proto/as/build.lua")
|
||||
include("plat/build.lua")
|
||||
|
||||
build_as {
|
||||
name = "as",
|
||||
arch = "i86"
|
||||
}
|
||||
|
||||
installable {
|
||||
build_plat {
|
||||
name = "pkg",
|
||||
map = {
|
||||
["$(PLATDEP)/pc86/as"] = "+as"
|
||||
arch = "i86",
|
||||
plat = "pc86",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
122
util/ncgg/build.lua
Normal file
122
util/ncgg/build.lua
Normal file
|
@ -0,0 +1,122 @@
|
|||
include("first/yacc.lua")
|
||||
|
||||
local cggparser = yacc {
|
||||
name = "cggparser",
|
||||
srcs = { "./cgg.y" }
|
||||
}
|
||||
|
||||
flex {
|
||||
name = "cgglexer",
|
||||
srcs = { "./scan.l" }
|
||||
}
|
||||
|
||||
normalrule {
|
||||
name = "keywords",
|
||||
ins = {
|
||||
"./cvtkeywords",
|
||||
"./keywords",
|
||||
unpack(filenamesof({cggparser}, "%.h$"))
|
||||
},
|
||||
outleaves = { "enterkeyw.c" },
|
||||
commands = {
|
||||
"%{ins[1]} %{ins[2]} %{ins[3]} %{outs[1]}"
|
||||
}
|
||||
}
|
||||
|
||||
cprogram {
|
||||
name = "ncgg",
|
||||
srcs = {
|
||||
"./*.c",
|
||||
"+cggparser", -- for .c file
|
||||
"+cgglexer", -- for .c file
|
||||
"+keywords",
|
||||
},
|
||||
deps = {
|
||||
"+cggparser", -- for .h file
|
||||
"+cgglexer", -- for .h file
|
||||
"h+emheaders",
|
||||
"util/data+em_data",
|
||||
}
|
||||
}
|
||||
|
||||
definerule("ncgg",
|
||||
{
|
||||
srcs = { type="targets" }
|
||||
},
|
||||
function(e)
|
||||
-- Remember this is executed from the caller's directory; local
|
||||
-- target names will resolve there
|
||||
if (#e.srcs ~= 1) then
|
||||
error("you must supply exactly one input file")
|
||||
end
|
||||
|
||||
local cpptable = cppfile {
|
||||
name = e.name.."/cpptable",
|
||||
outleaf = "cpptable",
|
||||
srcs = e.srcs
|
||||
}
|
||||
|
||||
return normalrule {
|
||||
name = e.name,
|
||||
cwd = e.cwd,
|
||||
outleaves = {
|
||||
"tables.c",
|
||||
"tables.h",
|
||||
},
|
||||
ins = {
|
||||
"util/ncgg+ncgg",
|
||||
cpptable
|
||||
},
|
||||
commands = {
|
||||
"cd %{dir} && %{ins}",
|
||||
"mv %{dir}/tables.H %{dir}/tables.h"
|
||||
}
|
||||
}
|
||||
end
|
||||
)
|
||||
|
||||
--[[
|
||||
D := util/ncgg
|
||||
|
||||
define build-ncgg-impl
|
||||
|
||||
$(call reset)
|
||||
$(eval cflags += -I$D)
|
||||
|
||||
$(call yacc, $(OBJDIR)/$D, $D/cgg.y)
|
||||
|
||||
$(call flex, $(OBJDIR)/$D, $D/scan.l)
|
||||
$(call dependson, $(OBJDIR)/$D/y.tab.h)
|
||||
|
||||
$(call cfile, $D/subr.c)
|
||||
$(call cfile, $D/main.c)
|
||||
$(call cfile, $D/coerc.c)
|
||||
$(call cfile, $D/error.c)
|
||||
$(call cfile, $D/emlookup.c)
|
||||
$(call cfile, $D/expr.c)
|
||||
$(call cfile, $D/instruct.c)
|
||||
$(call cfile, $D/iocc.c)
|
||||
$(call cfile, $D/lookup.c)
|
||||
$(call cfile, $D/output.c)
|
||||
$(call cfile, $D/set.c)
|
||||
$(call cfile, $D/strlookup.c)
|
||||
$(call cfile, $D/var.c)
|
||||
$(call cfile, $D/hall.c)
|
||||
|
||||
$(eval CLEANABLES += $(OBJDIR)/$D/enterkeyw.c)
|
||||
$(OBJDIR)/$D/enterkeyw.c: $D/cvtkeywords $D/keywords $(OBJDIR)/$D/y.tab.h
|
||||
@echo KEYWORDS $$@
|
||||
@mkdir -p $$(dir $$@)
|
||||
$(hide) cd $$(dir $$@) && sh $(abspath $D/cvtkeywords) $(abspath $D/keywords)
|
||||
$(call cfile, $(OBJDIR)/$D/enterkeyw.c)
|
||||
|
||||
$(eval $q: $(INCDIR)/em_spec.h)
|
||||
|
||||
$(call rawfile, $(LIBEM_DATA))
|
||||
$(call cprogram, $(BINDIR)/ncgg)
|
||||
$(eval NCGG := $o)
|
||||
|
||||
endef
|
||||
|
||||
$(eval $(build-ncgg-impl))
|
||||
--]]
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/sh
|
||||
: '$Id$'
|
||||
|
||||
grep '^#' y.tab.h >tokendefs
|
||||
ed -s $1 <<'!Funky!Stuff!'
|
||||
grep '^#' $2 >tokendefs
|
||||
ed -s $1 > $3 <<'!Funky!Stuff!'
|
||||
g/^#/d
|
||||
1,$s/\([^ ]*\)[ ][ ]*\(.*\)/ sy_p=lookup("\1",symkeyw,newsymbol);sy_p->sy_value.syv_keywno=\2;/
|
||||
1i
|
||||
|
@ -18,7 +18,8 @@ enterkeyw() {
|
|||
$a
|
||||
}
|
||||
.
|
||||
w enterkeyw.c
|
||||
,p
|
||||
q
|
||||
!Funky!Stuff!
|
||||
rm tokendefs
|
||||
|
||||
|
|
Loading…
Reference in a new issue