Replace the terrible code generation shell script with a Lua script.
This commit is contained in:
parent
90c6f0274a
commit
2558d00d17
|
@ -13,14 +13,12 @@ local cgglexer = flex {
|
|||
normalrule {
|
||||
name = "keywords",
|
||||
ins = {
|
||||
"./cvtkeywords",
|
||||
"util/cmisc+ed",
|
||||
"./make_enterkeyw_c.lua",
|
||||
"./keywords",
|
||||
matching(filenamesof(cggparser), "%.h$")
|
||||
},
|
||||
outleaves = { "enterkeyw.c" },
|
||||
commands = {
|
||||
"%{ins[1]} %{ins[2]} %{ins[3]} %{ins[4]} %{outs[1]}"
|
||||
"$LUA %{ins[1]} < %{ins[2]} > %{outs[1]}"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
#!/bin/sh
|
||||
: '$Id$'
|
||||
|
||||
grep '^#' $3 >tokendefs
|
||||
$1 -s $2 > $4 <<'!Funky!Stuff!'
|
||||
g/^#/d
|
||||
1,$s/\([^ ]*\)[ ][ ]*\(.*\)/ sy_p=lookup("\1",symkeyw,newsymbol);sy_p->sy_value.syv_keywno=\2;/
|
||||
1i
|
||||
#include "lookup.h"
|
||||
.
|
||||
.r tokendefs
|
||||
a
|
||||
|
||||
void enterkeyw(void) {
|
||||
register symbol *sy_p;
|
||||
|
||||
.
|
||||
$a
|
||||
}
|
||||
.
|
||||
1,$p
|
||||
!Funky!Stuff!
|
||||
rm tokendefs
|
||||
|
26
util/ncgg/make_enterkeyw_c.lua
Executable file
26
util/ncgg/make_enterkeyw_c.lua
Executable file
|
@ -0,0 +1,26 @@
|
|||
print([[
|
||||
#include "param.h"
|
||||
#include "lookup.h"
|
||||
#include "varinfo.h"
|
||||
#include "instruct.h"
|
||||
#include "set.h"
|
||||
#include "expr.h"
|
||||
#include "iocc.h"
|
||||
#include "y.tab.h"
|
||||
|
||||
void enterkeyw(void) {
|
||||
]])
|
||||
|
||||
for line in io.stdin:lines() do
|
||||
if not line:find("^#") then
|
||||
local _, _, w1, w2 = line:find("^(%g+)%s+(%g+)$")
|
||||
print(string.format([[
|
||||
lookup("%s", symkeyw, newsymbol)->sy_value.syv_keywno = %s;
|
||||
]], w1, w2))
|
||||
end
|
||||
end
|
||||
|
||||
print([[
|
||||
}
|
||||
]])
|
||||
|
Loading…
Reference in a new issue