commit
33ce9169b4
|
@ -1,17 +0,0 @@
|
||||||
environment:
|
|
||||||
matrix:
|
|
||||||
- CYGWIN: C:\cygwin64
|
|
||||||
|
|
||||||
clone_depth: 1
|
|
||||||
|
|
||||||
init:
|
|
||||||
- git config --global core.autocrlf input
|
|
||||||
|
|
||||||
install:
|
|
||||||
- '%CYGWIN%\bin\bash -lc "cygcheck -dc cygwin"'
|
|
||||||
- '%CYGWIN%\setup-x86_64 -q -P bison,flex,ninja'
|
|
||||||
|
|
||||||
build_script:
|
|
||||||
- 'echo building...'
|
|
||||||
- '%CYGWIN%\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0</dev/null; make +ack"'
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
---
|
---
|
||||||
AlignAfterOpenBracket: AlwaysBreak
|
AlignAfterOpenBracket: AlwaysBreak
|
||||||
AllowShortFunctionsOnASingleLine: false
|
AllowShortFunctionsOnASingleLine: false
|
||||||
AllowShortLoopsOnASingleLine: false
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
|
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
* -text
|
||||||
|
|
65
.github/workflows/ccpp.yml
vendored
65
.github/workflows/ccpp.yml
vendored
|
@ -8,50 +8,41 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: apt
|
- name: apt
|
||||||
run: sudo apt update && sudo apt install bison flex ninja-build lua5.1 lua-posix
|
run: sudo apt update && sudo apt install bison flex ninja-build lua5.3
|
||||||
- name: make
|
- name: make
|
||||||
run: make LUA=lua
|
run: make
|
||||||
|
|
||||||
build-macos:
|
build-macos:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: brew
|
- name: brew
|
||||||
run: brew install ninja lua@5.1 luarocks
|
run: brew install ninja lua@5.4
|
||||||
- name: luarocks
|
|
||||||
run: |
|
|
||||||
luarocks install --lua-version 5.1 luaposix 33.0.0-1
|
|
||||||
- name: make
|
- name: make
|
||||||
run: |
|
run: |
|
||||||
eval $(luarocks --lua-version 5.1 path)
|
make
|
||||||
make LUA=/usr/local/bin/lua5.1
|
|
||||||
|
build-windows:
|
||||||
|
runs-on: windows-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: msys2 {0}
|
||||||
|
steps:
|
||||||
|
- uses: msys2/setup-msys2@v2
|
||||||
|
with:
|
||||||
|
update: true
|
||||||
|
msystem: MINGW32
|
||||||
|
install: >-
|
||||||
|
make
|
||||||
|
mingw-w64-i686-gcc
|
||||||
|
mingw-w64-i686-lua
|
||||||
|
ninja
|
||||||
|
bison
|
||||||
|
flex
|
||||||
|
zip
|
||||||
|
git
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: build
|
||||||
|
run: |
|
||||||
|
make
|
||||||
|
|
||||||
# build-windows:
|
|
||||||
# runs-on: windows-latest
|
|
||||||
# defaults:
|
|
||||||
# run:
|
|
||||||
# shell: msys2 {0}
|
|
||||||
# steps:
|
|
||||||
# - uses: msys2/setup-msys2@v2
|
|
||||||
# with:
|
|
||||||
# update: true
|
|
||||||
# msystem: MINGW32
|
|
||||||
# install: >-
|
|
||||||
# make
|
|
||||||
# mingw-w64-i686-gcc
|
|
||||||
# mingw-w64-x86_64-lua51
|
|
||||||
# mingw-w64-x86_64-lua-luarocks
|
|
||||||
# ninja
|
|
||||||
# bison
|
|
||||||
# flex
|
|
||||||
# zip
|
|
||||||
# git
|
|
||||||
# - name: luarocks
|
|
||||||
# run: |
|
|
||||||
# git config --global url."https://".insteadOf git://
|
|
||||||
# /mingw64/bin/luarocks --lua-version 5.1 install luaposix 33.0.0-1
|
|
||||||
# - uses: actions/checkout@v3
|
|
||||||
# - name: build
|
|
||||||
# run: |
|
|
||||||
# make LUA=/mingw64/bin/lua5.1
|
|
||||||
#
|
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -105,7 +105,7 @@ else
|
||||||
$(error unknown BUILDSYSTEM = $(BUILDSYSTEM))
|
$(error unknown BUILDSYSTEM = $(BUILDSYSTEM))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(build-file): first/ackbuilder.lua Makefile
|
$(build-file): first/ackbuilder.lua Makefile $(lua-files)
|
||||||
@mkdir -p $(BUILDDIR)
|
@mkdir -p $(BUILDDIR)
|
||||||
@$(LUA) first/ackbuilder.lua \
|
@$(LUA) first/ackbuilder.lua \
|
||||||
first/build.lua build.lua \
|
first/build.lua build.lua \
|
||||||
|
|
5
README
5
README
|
@ -2,7 +2,7 @@
|
||||||
===================================
|
===================================
|
||||||
|
|
||||||
© 1987-2005 Vrije Universiteit, Amsterdam
|
© 1987-2005 Vrije Universiteit, Amsterdam
|
||||||
2018-02-23
|
2022-06-18
|
||||||
|
|
||||||
|
|
||||||
INTRODUCTION
|
INTRODUCTION
|
||||||
|
@ -45,7 +45,8 @@ INSTALLATION
|
||||||
============
|
============
|
||||||
|
|
||||||
The version 5.0 build mechanism has been completely rewritten. Installation
|
The version 5.0 build mechanism has been completely rewritten. Installation
|
||||||
ought to be fairly straightforward.
|
ought to be fairly straightforward. It will build on Unixishes including Linux,
|
||||||
|
OSX, and Windows using MSYS2 and mingw32.
|
||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
|
|
||||||
|
|
46
build.lua
46
build.lua
|
@ -28,6 +28,13 @@ vars.plats_with_tests = {
|
||||||
"pc86",
|
"pc86",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local is_windows = os.getenv("OS") == "Windows_NT"
|
||||||
|
|
||||||
|
local int = {}
|
||||||
|
if not is_windows then
|
||||||
|
int[#int+1] = "util/int+pkg"
|
||||||
|
end
|
||||||
|
|
||||||
installable {
|
installable {
|
||||||
name = "ack-common",
|
name = "ack-common",
|
||||||
map = {
|
map = {
|
||||||
|
@ -41,10 +48,10 @@ installable {
|
||||||
"util/arch+pkg",
|
"util/arch+pkg",
|
||||||
"util/ass+pkg",
|
"util/ass+pkg",
|
||||||
"util/ego+pkg",
|
"util/ego+pkg",
|
||||||
"util/int+pkg",
|
|
||||||
"util/led+pkg",
|
"util/led+pkg",
|
||||||
"util/misc+pkg",
|
"util/misc+pkg",
|
||||||
"util/opt+pkg",
|
"util/opt+pkg",
|
||||||
|
int
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,16 +82,29 @@ installable {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
normalrule {
|
if not is_windows then
|
||||||
name = "tests",
|
normalrule {
|
||||||
ins = {
|
name = "tests",
|
||||||
"first/testsummary.sh",
|
ins = {
|
||||||
test_packages
|
"first/testsummary.sh",
|
||||||
},
|
test_packages
|
||||||
outleaves = {
|
},
|
||||||
"stamp"
|
outleaves = {
|
||||||
},
|
"stamp"
|
||||||
commands = {
|
},
|
||||||
"%{ins}"
|
commands = {
|
||||||
|
"%{ins}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
normalrule {
|
||||||
|
name = "tests",
|
||||||
|
ins = {},
|
||||||
|
outleaves = {
|
||||||
|
"stamp"
|
||||||
|
},
|
||||||
|
commands = {
|
||||||
|
"touch %{outs}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
-- is = { set of rule types which made the target }
|
-- is = { set of rule types which made the target }
|
||||||
-- }
|
-- }
|
||||||
|
|
||||||
local posix = require("posix")
|
|
||||||
local emitter = {}
|
local emitter = {}
|
||||||
local rules = {}
|
local rules = {}
|
||||||
local targets = {}
|
local targets = {}
|
||||||
|
@ -21,6 +20,24 @@ local loadingstack = {}
|
||||||
-- Forward references
|
-- Forward references
|
||||||
local loadtarget
|
local loadtarget
|
||||||
|
|
||||||
|
-- Compatibility polyfill for load
|
||||||
|
local function loadf(text, source, mode, env)
|
||||||
|
if rawget(_G, "loadstring") and rawget(_G, "setfenv") then
|
||||||
|
local chunk, e = loadstring(text, "@"..source)
|
||||||
|
if chunk then
|
||||||
|
setfenv(chunk, env)
|
||||||
|
end
|
||||||
|
return chunk, e
|
||||||
|
else
|
||||||
|
return load(text, source, mode, env)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Compatibility polyfill for unpack
|
||||||
|
if not rawget(_G, "unpack") then
|
||||||
|
unpack = table.unpack
|
||||||
|
end
|
||||||
|
|
||||||
local function print(...)
|
local function print(...)
|
||||||
local function print_no_nl(list)
|
local function print_no_nl(list)
|
||||||
for _, s in ipairs(list) do
|
for _, s in ipairs(list) do
|
||||||
|
@ -125,7 +142,7 @@ local function concatpath(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Returns a list of the targets within the given collection; the keys of any
|
-- Returns a list of the targets within the given collection; the keys of any
|
||||||
-- keyed items are lost. Lists and wildcards are expanded.
|
-- keyed items are lost. Lists are expanded.
|
||||||
local function targetsof(...)
|
local function targetsof(...)
|
||||||
local o = {}
|
local o = {}
|
||||||
|
|
||||||
|
@ -226,9 +243,6 @@ local function abspath(...)
|
||||||
return dotocollection({...},
|
return dotocollection({...},
|
||||||
function(filename)
|
function(filename)
|
||||||
assertString(filename, 1)
|
assertString(filename, 1)
|
||||||
if not filename:find("^[/$]") then
|
|
||||||
filename = concatpath(posix.getcwd(), filename)
|
|
||||||
end
|
|
||||||
return filename
|
return filename
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
@ -345,11 +359,10 @@ local function templateexpand(list, vars)
|
||||||
o[#o+1] = s:gsub("%%%b{}",
|
o[#o+1] = s:gsub("%%%b{}",
|
||||||
function(expr)
|
function(expr)
|
||||||
expr = expr:sub(3, -2)
|
expr = expr:sub(3, -2)
|
||||||
local chunk, e = loadstring("return ("..expr..")", expr)
|
local chunk, e = loadf("return ("..expr..")", expr, nil, vars)
|
||||||
if e then
|
if e then
|
||||||
error(string.format("error evaluating expression: %s", e))
|
error(string.format("error evaluating expression: %s", e))
|
||||||
end
|
end
|
||||||
setfenv(chunk, vars)
|
|
||||||
local value = chunk()
|
local value = chunk()
|
||||||
if (value == nil) then
|
if (value == nil) then
|
||||||
error(string.format("template expression '%s' expands to nil (probably an undefined variable)", expr))
|
error(string.format("template expression '%s' expands to nil (probably an undefined variable)", expr))
|
||||||
|
@ -381,10 +394,7 @@ local function loadbuildfile(filename)
|
||||||
local thisglobals = {}
|
local thisglobals = {}
|
||||||
thisglobals._G = thisglobals
|
thisglobals._G = thisglobals
|
||||||
setmetatable(thisglobals, {__index = globals})
|
setmetatable(thisglobals, {__index = globals})
|
||||||
chunk, e = loadstring(data, "@"..filename)
|
chunk, e = loadf(data, filename, nil, thisglobals)
|
||||||
if not e then
|
|
||||||
setfenv(chunk, thisglobals)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if e then
|
if e then
|
||||||
|
@ -401,13 +411,17 @@ end
|
||||||
|
|
||||||
local function loadbuildfilefor(filepart, targetpart)
|
local function loadbuildfilefor(filepart, targetpart)
|
||||||
local normalname = concatpath(filepart, "/build.lua")
|
local normalname = concatpath(filepart, "/build.lua")
|
||||||
if posix.access(normalname, "r") then
|
local fp = io.open(normalname, "r")
|
||||||
|
if fp then
|
||||||
|
fp:close()
|
||||||
loadbuildfile(normalname)
|
loadbuildfile(normalname)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local extendedname = concatpath(filepart, "/build-"..targetpart..".lua")
|
local extendedname = concatpath(filepart, "/build-"..targetpart..".lua")
|
||||||
if posix.access(extendedname, "r") then
|
fp = io.open(extendedname, "r")
|
||||||
|
if fp then
|
||||||
|
fp:close()
|
||||||
loadbuildfile(extendedname)
|
loadbuildfile(extendedname)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -424,10 +438,7 @@ loadtarget = function(targetname)
|
||||||
if not targetname:find("%+") then
|
if not targetname:find("%+") then
|
||||||
local files
|
local files
|
||||||
if targetname:find("[?*]") then
|
if targetname:find("[?*]") then
|
||||||
files = posix.glob(targetname)
|
error("wildcards not supported")
|
||||||
if not files then
|
|
||||||
files = {}
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
files = {targetname}
|
files = {targetname}
|
||||||
end
|
end
|
||||||
|
@ -823,8 +834,6 @@ local function parse_arguments(argmap, arg)
|
||||||
end
|
end
|
||||||
|
|
||||||
globals = {
|
globals = {
|
||||||
posix = posix,
|
|
||||||
|
|
||||||
abspath = abspath,
|
abspath = abspath,
|
||||||
asstring = asstring,
|
asstring = asstring,
|
||||||
basename = basename,
|
basename = basename,
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
definerule("yacc",
|
definerule("bison",
|
||||||
{
|
{
|
||||||
srcs = { type="targets" },
|
srcs = { type="targets" },
|
||||||
commands = {
|
commands = {
|
||||||
type="strings",
|
type="strings",
|
||||||
default={
|
default={
|
||||||
"yacc -t -b %{dir}/y -d %{ins}"
|
"bison -t -b %{dir}/y -d %{ins}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
18
h/build.lua
18
h/build.lua
|
@ -23,7 +23,23 @@ normalrule {
|
||||||
clibrary {
|
clibrary {
|
||||||
name = "emheaders",
|
name = "emheaders",
|
||||||
hdrs = {
|
hdrs = {
|
||||||
"./*.h",
|
"./arch.h",
|
||||||
|
"./as_spec.h",
|
||||||
|
"./cgg_cg.h",
|
||||||
|
"./cg_pattern.h",
|
||||||
|
"./em_abs.h",
|
||||||
|
"./em_ego.h",
|
||||||
|
"./em_flag.h",
|
||||||
|
"./em_mes.h",
|
||||||
|
"./em_ptyp.h",
|
||||||
|
"./em_reg.h",
|
||||||
|
"./ip_spec.h",
|
||||||
|
"./ocm_chan.h",
|
||||||
|
"./ocm_parco.h",
|
||||||
|
"./ocm_proc.h",
|
||||||
|
"./out.h",
|
||||||
|
"./ranlib.h",
|
||||||
|
"./stb.h",
|
||||||
"./con_float",
|
"./con_float",
|
||||||
"+em_path",
|
"+em_path",
|
||||||
"+local",
|
"+local",
|
||||||
|
|
88
h/em_table_lib.lua
Normal file
88
h/em_table_lib.lua
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
local function strip(s)
|
||||||
|
return s:match("^%s*(.-)%s*$")
|
||||||
|
end
|
||||||
|
|
||||||
|
function load_table()
|
||||||
|
local specs = {}
|
||||||
|
for line in io.lines() do
|
||||||
|
line = strip(line)
|
||||||
|
if line == "" then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
local _, _, name, num = line:find("^(%w+)%s+(%d+)$")
|
||||||
|
if not name then
|
||||||
|
error("malformed spec line in em_table")
|
||||||
|
end
|
||||||
|
|
||||||
|
specs[#specs+1] = {
|
||||||
|
name = name,
|
||||||
|
num = tonumber(num)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, v in ipairs(specs) do
|
||||||
|
specs[v.name] = v
|
||||||
|
end
|
||||||
|
|
||||||
|
local pseudos = {}
|
||||||
|
local pseudo_count = 0
|
||||||
|
for line in io.lines() do
|
||||||
|
line = strip(line)
|
||||||
|
if line == "" then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
local _, _, name, num, flags = line:find("^(%w+)%s+(%d+)%s+(%g+)$")
|
||||||
|
if not name then
|
||||||
|
error("malformed pseudo line in em_table")
|
||||||
|
end
|
||||||
|
|
||||||
|
pseudos[#pseudos+1] = {
|
||||||
|
name = name,
|
||||||
|
num = tonumber(num) + specs.fpseu.num,
|
||||||
|
flags = flags
|
||||||
|
}
|
||||||
|
pseudo_count = pseudo_count + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local mnems = {}
|
||||||
|
local mnem_count = 0
|
||||||
|
for line in io.lines() do
|
||||||
|
line = strip(line)
|
||||||
|
if line == "" then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
local _, _, name, flags1, flags2 = line:find("^(%w+)%s+(%g+)%s+(%g+)$")
|
||||||
|
if not name then
|
||||||
|
error("malformed mnemonic line in em_table")
|
||||||
|
end
|
||||||
|
|
||||||
|
mnem_count = mnem_count + 1
|
||||||
|
mnems[#mnems+1] = {
|
||||||
|
name = name,
|
||||||
|
num = mnem_count,
|
||||||
|
flags1 = flags1,
|
||||||
|
flags2 = flags2
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local lpseu = {
|
||||||
|
name = "lpseu",
|
||||||
|
num = specs.fpseu.num + pseudo_count - 1
|
||||||
|
}
|
||||||
|
local lmnem = {
|
||||||
|
name = "lmnem",
|
||||||
|
num = specs.fmnem.num + mnem_count - 1
|
||||||
|
}
|
||||||
|
|
||||||
|
specs[#specs+1] = lpseu
|
||||||
|
specs.lpseu = lpseu
|
||||||
|
|
||||||
|
specs[#specs+1] = lmnem
|
||||||
|
specs.lmnem = lmnem
|
||||||
|
|
||||||
|
return specs, pseudos, mnems
|
||||||
|
end
|
||||||
|
|
|
@ -93,13 +93,13 @@ int narg;
|
||||||
postin[0] = dup(0);
|
postin[0] = dup(0);
|
||||||
if (pass1) {
|
if (pass1) {
|
||||||
if (useroif) {
|
if (useroif) {
|
||||||
if ((hashin = fopen(oifile, "r")) == NULL)
|
if ((hashin = fopen(oifile, "rb")) == NULL)
|
||||||
fatal("bad ignore/only file: %s",oifile);
|
fatal("bad ignore/only file: %s",oifile);
|
||||||
buildhash();
|
buildhash();
|
||||||
fclose(hashin);
|
fclose(hashin);
|
||||||
}
|
}
|
||||||
input = stdin;
|
input = stdin;
|
||||||
output = fdopen(scanout[1], "w");
|
output = fdopen(scanout[1], "wb");
|
||||||
nfiles = argc;
|
nfiles = argc;
|
||||||
setjmp(env);
|
setjmp(env);
|
||||||
while (argc--)
|
while (argc--)
|
||||||
|
@ -203,9 +203,9 @@ scan(s) char *s;
|
||||||
oifsuf++;
|
oifsuf++;
|
||||||
if (lastc != oifile[oifsuf] ) {
|
if (lastc != oifile[oifsuf] ) {
|
||||||
oifile[oifsuf] = lastc;
|
oifile[oifsuf] = lastc;
|
||||||
if ((hashin = fopen(oifile, "r")) == NULL) {
|
if ((hashin = fopen(oifile, "rb")) == NULL) {
|
||||||
oifile[oifsuf] = 'x';
|
oifile[oifsuf] = 'x';
|
||||||
if ((hashin = fopen(oifile, "r")) == NULL)
|
if ((hashin = fopen(oifile, "rb")) == NULL)
|
||||||
fatal("cannot open %s",oifile);
|
fatal("cannot open %s",oifile);
|
||||||
}
|
}
|
||||||
buildhash();
|
buildhash();
|
||||||
|
@ -215,7 +215,7 @@ scan(s) char *s;
|
||||||
if (s[0]=='-' && s[1]=='\0')
|
if (s[0]=='-' && s[1]=='\0')
|
||||||
input = stdin;
|
input = stdin;
|
||||||
else
|
else
|
||||||
if ((input = fopen(s, "r")) == NULL)
|
if ((input = fopen(s, "rb")) == NULL)
|
||||||
fatal("cannot open %s",s);
|
fatal("cannot open %s",s);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'x':
|
case 'x':
|
||||||
|
|
|
@ -45,7 +45,7 @@ extern const char* modulename;
|
||||||
extern int paramsize;
|
extern int paramsize;
|
||||||
extern struct hshtab hshtab[HSHSIZ];
|
extern struct hshtab hshtab[HSHSIZ];
|
||||||
extern int hshused;
|
extern int hshused;
|
||||||
extern int eof;
|
extern int ateof;
|
||||||
extern int peekc;
|
extern int peekc;
|
||||||
extern const char* ctab;
|
extern const char* ctab;
|
||||||
extern struct hshtab *bsym;
|
extern struct hshtab *bsym;
|
||||||
|
|
|
@ -22,7 +22,7 @@ int string_part;
|
||||||
int paramsize;
|
int paramsize;
|
||||||
struct hshtab hshtab[HSHSIZ];
|
struct hshtab hshtab[HSHSIZ];
|
||||||
int hshused;
|
int hshused;
|
||||||
int eof;
|
int ateof;
|
||||||
int peekc;
|
int peekc;
|
||||||
const char* ctab;
|
const char* ctab;
|
||||||
struct hshtab *bsym;
|
struct hshtab *bsym;
|
||||||
|
@ -129,7 +129,7 @@ main(int argc, char *argv[])
|
||||||
string_part = 0;
|
string_part = 0;
|
||||||
code_part = C_getid();
|
code_part = C_getid();
|
||||||
C_beginpart(code_part);
|
C_beginpart(code_part);
|
||||||
while (!eof) {
|
while (!ateof) {
|
||||||
extdef();
|
extdef();
|
||||||
blkend();
|
blkend();
|
||||||
}
|
}
|
||||||
|
@ -368,12 +368,12 @@ symbol(void)
|
||||||
c = peekc;
|
c = peekc;
|
||||||
peekc = 0;
|
peekc = 0;
|
||||||
} else
|
} else
|
||||||
if (eof)
|
if (ateof)
|
||||||
return EOFC;
|
return EOFC;
|
||||||
else
|
else
|
||||||
c = getchar();
|
c = getchar();
|
||||||
if (c==EOF) {
|
if (c==EOF) {
|
||||||
eof++;
|
ateof++;
|
||||||
return(EOFC);
|
return(EOFC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ loop:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
eof++;
|
ateof++;
|
||||||
error("Nonterminated comment");
|
error("Nonterminated comment");
|
||||||
return EOFC;
|
return EOFC;
|
||||||
|
|
||||||
|
@ -820,7 +820,7 @@ stmt:
|
||||||
if ((o = symbol()) == LBRACE) {
|
if ((o = symbol()) == LBRACE) {
|
||||||
if (d)
|
if (d)
|
||||||
blkhed();
|
blkhed();
|
||||||
while (!eof) {
|
while (!ateof) {
|
||||||
if ((o = symbol()) == RBRACE)
|
if ((o = symbol()) == RBRACE)
|
||||||
goto bend;
|
goto bend;
|
||||||
pushsym(o);
|
pushsym(o);
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
cprogram {
|
cprogram {
|
||||||
name = "em_b",
|
name = "em_b",
|
||||||
srcs = {
|
srcs = {
|
||||||
"./*.c",
|
"./b0.c",
|
||||||
|
"./b1.c",
|
||||||
},
|
},
|
||||||
deps = {
|
deps = {
|
||||||
"./*.h",
|
"./b.h",
|
||||||
"modules+headers",
|
"modules+headers",
|
||||||
"modules/src/alloc+lib",
|
"modules/src/alloc+lib",
|
||||||
"modules/src/data+lib",
|
"modules/src/data+lib",
|
||||||
|
|
|
@ -4,12 +4,12 @@ for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = {
|
srcs = {
|
||||||
"./*.c",
|
"./init.c",
|
||||||
"./*.e",
|
"./main.c",
|
||||||
},
|
},
|
||||||
hdrs = {}, -- must be empty
|
hdrs = {}, -- must be empty
|
||||||
deps = {
|
deps = {
|
||||||
"./*.h",
|
"./b.h",
|
||||||
"h+emheaders",
|
"h+emheaders",
|
||||||
"lang/cem/libcc.ansi/headers+pkg",
|
"lang/cem/libcc.ansi/headers+pkg",
|
||||||
"plat/"..plat.."/include+pkg",
|
"plat/"..plat.."/include+pkg",
|
||||||
|
|
|
@ -4,15 +4,47 @@ for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = {
|
srcs = {
|
||||||
"./*.c",
|
"./abs.c",
|
||||||
"./*.e",
|
"./asc.c",
|
||||||
|
"./asrt.c",
|
||||||
|
"./atn.c",
|
||||||
|
"./chr.c",
|
||||||
|
"./conversion.c",
|
||||||
|
"./error.c",
|
||||||
|
"./exp.c",
|
||||||
|
"./file.c",
|
||||||
|
"./hlt.c",
|
||||||
|
"./io.c",
|
||||||
|
"./log.c",
|
||||||
|
"./mki.c",
|
||||||
|
"./oct.c",
|
||||||
|
"./peek.c",
|
||||||
|
"./power.c",
|
||||||
|
"./print.c",
|
||||||
|
"./random.c",
|
||||||
|
"./read.c",
|
||||||
|
"./return.c",
|
||||||
|
"./salloc.c",
|
||||||
|
"./sgn.c",
|
||||||
|
"./sin.c",
|
||||||
|
"./sqt.c",
|
||||||
|
"./stop.c",
|
||||||
|
"./string.c",
|
||||||
|
"./swap.c",
|
||||||
|
"./trace.c",
|
||||||
|
"./trap.c",
|
||||||
|
"./write.c",
|
||||||
|
"./fef.e",
|
||||||
|
"./fif.e",
|
||||||
|
"./setline.e",
|
||||||
},
|
},
|
||||||
hdrs = {}, -- must be empty
|
hdrs = {}, -- must be empty
|
||||||
deps = {
|
deps = {
|
||||||
"h+emheaders",
|
"h+emheaders",
|
||||||
"lang/cem/libcc.ansi/headers+pkg",
|
"lang/cem/libcc.ansi/headers+pkg",
|
||||||
"plat/"..plat.."/include+pkg",
|
"plat/"..plat.."/include+pkg",
|
||||||
"./*.h",
|
"./bc_io.h",
|
||||||
|
"./lib.h",
|
||||||
},
|
},
|
||||||
vars = { plat = plat }
|
vars = { plat = plat }
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,19 +76,19 @@ void _opnchn(int reclen, String* fname, String* mode)
|
||||||
{
|
{
|
||||||
case 'O':
|
case 'O':
|
||||||
case 'o':
|
case 'o':
|
||||||
if ((f = fopen(fname->strval, "w")) == NULL)
|
if ((f = fopen(fname->strval, "wb")) == NULL)
|
||||||
error(28);
|
error(28);
|
||||||
m = OMODE;
|
m = OMODE;
|
||||||
break;
|
break;
|
||||||
case 'I':
|
case 'I':
|
||||||
case 'i':
|
case 'i':
|
||||||
if ((f = fopen(fname->strval, "r")) == NULL)
|
if ((f = fopen(fname->strval, "rb")) == NULL)
|
||||||
error(28);
|
error(28);
|
||||||
m = IMODE;
|
m = IMODE;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
case 'R':
|
case 'R':
|
||||||
if ((f = fopen(fname->strval, "a")) == NULL)
|
if ((f = fopen(fname->strval, "ab")) == NULL)
|
||||||
error(28);
|
error(28);
|
||||||
m = RMODE;
|
m = RMODE;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -572,6 +572,7 @@ int yylex(void)
|
||||||
/* handle double operators */
|
/* handle double operators */
|
||||||
case ' ':
|
case ' ':
|
||||||
case '\t':
|
case '\t':
|
||||||
|
case '\r':
|
||||||
cptr++;
|
cptr++;
|
||||||
return(yylex());
|
return(yylex());
|
||||||
case '&':
|
case '&':
|
||||||
|
|
|
@ -2,30 +2,48 @@ include("util/LLgen/build.lua")
|
||||||
|
|
||||||
llgen {
|
llgen {
|
||||||
name = "llgen",
|
name = "llgen",
|
||||||
srcs = { "./*.g" }
|
srcs = { "./basic.g" }
|
||||||
}
|
}
|
||||||
|
|
||||||
normalrule {
|
normalrule {
|
||||||
name = "tokentab_h",
|
name = "tokentab_h",
|
||||||
ins = {
|
ins = {
|
||||||
"./maketokentab",
|
"./maketokentab",
|
||||||
"util/cmisc+ed",
|
|
||||||
matching(filenamesof("+llgen"), "/Lpars.h$"),
|
matching(filenamesof("+llgen"), "/Lpars.h$"),
|
||||||
},
|
},
|
||||||
outleaves = { "tokentab.h" },
|
outleaves = { "tokentab.h" },
|
||||||
commands = {
|
commands = {
|
||||||
"%{ins} %{outs}"
|
"%{ins[1]} < %{ins[2]} > %{outs}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cprogram {
|
cprogram {
|
||||||
name = "em_bem",
|
name = "em_bem",
|
||||||
srcs = {
|
srcs = {
|
||||||
"./*.c",
|
"./bem.c",
|
||||||
|
"./compile.c",
|
||||||
|
"./eval.c",
|
||||||
|
"./func.c",
|
||||||
|
"./gencode.c",
|
||||||
|
"./graph.c",
|
||||||
|
"./initialize.c",
|
||||||
|
"./parsepar.c",
|
||||||
|
"./symbols.c",
|
||||||
|
"./util.c",
|
||||||
matching(filenamesof("+llgen"), "%.c$"),
|
matching(filenamesof("+llgen"), "%.c$"),
|
||||||
},
|
},
|
||||||
deps = {
|
deps = {
|
||||||
"./*.h",
|
"./bem.h",
|
||||||
|
"./eval.h",
|
||||||
|
"./func.h",
|
||||||
|
"./gencode.h",
|
||||||
|
"./graph.h",
|
||||||
|
"./llmess.h",
|
||||||
|
"./parsepar.h",
|
||||||
|
"./symbols.h",
|
||||||
|
"./util.h",
|
||||||
|
"./yylexp.h",
|
||||||
|
"./basic.lex",
|
||||||
"+llgen",
|
"+llgen",
|
||||||
"+tokentab_h",
|
"+tokentab_h",
|
||||||
"h+emheaders",
|
"h+emheaders",
|
||||||
|
|
|
@ -1,17 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
$1 -s "${2:-Lpars.h}" > $3 <<'+'
|
echo "char* tokentab[] = {"
|
||||||
1d
|
awk '/^#define/ { print "\"" $2 "\"," }'
|
||||||
1,$s/# *define //
|
echo "};"
|
||||||
1,$s/ ...$//
|
|
||||||
1,$s/^/ "/
|
|
||||||
1,$-1s/$/",/
|
|
||||||
$s/$/"/
|
|
||||||
0a
|
|
||||||
char *tokentab[] = {
|
|
||||||
.
|
|
||||||
$a
|
|
||||||
};
|
|
||||||
.
|
|
||||||
1,$p
|
|
||||||
+
|
|
||||||
|
|
|
@ -1,135 +1,135 @@
|
||||||
!File: lint.h
|
!File: lint.h
|
||||||
/*#define LINT 1 *//* if defined, 'lint' is produced */
|
/*#define LINT 1 *//* if defined, 'lint' is produced */
|
||||||
|
|
||||||
|
|
||||||
!File: pathlength.h
|
!File: pathlength.h
|
||||||
#define PATHLENGTH 1024 /* max. length of path to file */
|
#define PATHLENGTH 1024 /* max. length of path to file */
|
||||||
|
|
||||||
|
|
||||||
!File: errout.h
|
!File: errout.h
|
||||||
#define ERROUT STDERR /* file pointer for writing messages */
|
#define ERROUT STDERR /* file pointer for writing messages */
|
||||||
#define ERR_SHADOW 5 /* a syntax error overshadows error messages
|
#define ERR_SHADOW 5 /* a syntax error overshadows error messages
|
||||||
until ERR_SHADOW symbols have been
|
until ERR_SHADOW symbols have been
|
||||||
accepted without syntax error */
|
accepted without syntax error */
|
||||||
|
|
||||||
|
|
||||||
!File: idfsize.h
|
!File: idfsize.h
|
||||||
#define IDFSIZE 64 /* maximum significant length of an identifier */
|
#define IDFSIZE 64 /* maximum significant length of an identifier */
|
||||||
|
|
||||||
|
|
||||||
!File: numsize.h
|
!File: numsize.h
|
||||||
#define NUMSIZE 256 /* maximum length of a numeric constant */
|
#define NUMSIZE 256 /* maximum length of a numeric constant */
|
||||||
|
|
||||||
|
|
||||||
!File: nparams.h
|
!File: nparams.h
|
||||||
#define NPARAMS 32 /* maximum number of parameters */
|
#define NPARAMS 32 /* maximum number of parameters */
|
||||||
#define STDC_NPARAMS 31 /* ANSI limit on number of parameters */
|
#define STDC_NPARAMS 31 /* ANSI limit on number of parameters */
|
||||||
|
|
||||||
|
|
||||||
!File: ifdepth.h
|
!File: ifdepth.h
|
||||||
#define IFDEPTH 256 /* maximum number of nested if-constructions */
|
#define IFDEPTH 256 /* maximum number of nested if-constructions */
|
||||||
|
|
||||||
|
|
||||||
!File: density.h
|
!File: density.h
|
||||||
#define DENSITY 3 /* see switch.[ch] for an explanation */
|
#define DENSITY 3 /* see switch.[ch] for an explanation */
|
||||||
|
|
||||||
|
|
||||||
!File: macbuf.h
|
!File: macbuf.h
|
||||||
#define LAPBUF 128 /* initial size of macro replacement buffer */
|
#define LAPBUF 128 /* initial size of macro replacement buffer */
|
||||||
#define ARGBUF 128 /* initial size of macro parameter buffer(s) */
|
#define ARGBUF 128 /* initial size of macro parameter buffer(s) */
|
||||||
|
|
||||||
|
|
||||||
!File: strsize.h
|
!File: strsize.h
|
||||||
#define ISTRSIZE 32 /* minimum number of bytes allocated for
|
#define ISTRSIZE 32 /* minimum number of bytes allocated for
|
||||||
storing a string */
|
storing a string */
|
||||||
#define RSTRSIZE 16 /* step size in enlarging the memory for
|
#define RSTRSIZE 16 /* step size in enlarging the memory for
|
||||||
the storage of a string */
|
the storage of a string */
|
||||||
|
|
||||||
|
|
||||||
!File: trgt_sizes.h
|
!File: trgt_sizes.h
|
||||||
#define MAXSIZE 8 /* the maximum of the SZ_* constants */
|
#define MAXSIZE 8 /* the maximum of the SZ_* constants */
|
||||||
|
|
||||||
/* target machine sizes */
|
/* target machine sizes */
|
||||||
#define SZ_CHAR 1
|
#define SZ_CHAR 1
|
||||||
#define SZ_SHORT 2
|
#define SZ_SHORT 2
|
||||||
#define SZ_WORD 4
|
#define SZ_WORD 4
|
||||||
#define SZ_INT 4
|
#define SZ_INT 4
|
||||||
#define SZ_LONG 4
|
#define SZ_LONG 4
|
||||||
#define SZ_LNGLNG -1
|
#define SZ_LNGLNG -1
|
||||||
#define SZ_FLOAT 4
|
#define SZ_FLOAT 4
|
||||||
#define SZ_DOUBLE 8
|
#define SZ_DOUBLE 8
|
||||||
#define SZ_LNGDBL 8 /* for now */
|
#define SZ_LNGDBL 8 /* for now */
|
||||||
#define SZ_POINTER 4
|
#define SZ_POINTER 4
|
||||||
|
|
||||||
/* target machine alignment requirements */
|
/* target machine alignment requirements */
|
||||||
#define AL_CHAR 1
|
#define AL_CHAR 1
|
||||||
#define AL_SHORT SZ_SHORT
|
#define AL_SHORT SZ_SHORT
|
||||||
#define AL_WORD SZ_WORD
|
#define AL_WORD SZ_WORD
|
||||||
#define AL_INT SZ_WORD
|
#define AL_INT SZ_WORD
|
||||||
#define AL_LONG SZ_WORD
|
#define AL_LONG SZ_WORD
|
||||||
#define AL_LNGLNG SZ_WORD
|
#define AL_LNGLNG SZ_WORD
|
||||||
#define AL_FLOAT SZ_WORD
|
#define AL_FLOAT SZ_WORD
|
||||||
#define AL_DOUBLE SZ_WORD
|
#define AL_DOUBLE SZ_WORD
|
||||||
#define AL_LNGDBL SZ_WORD
|
#define AL_LNGDBL SZ_WORD
|
||||||
#define AL_POINTER SZ_WORD
|
#define AL_POINTER SZ_WORD
|
||||||
#define AL_STRUCT 1
|
#define AL_STRUCT 1
|
||||||
#define AL_UNION 1
|
#define AL_UNION 1
|
||||||
|
|
||||||
|
|
||||||
!File: botch_free.h
|
!File: botch_free.h
|
||||||
/*#define BOTCH_FREE 1* *//* when defined, botch freed memory, as a check */
|
/*#define BOTCH_FREE 1* *//* when defined, botch freed memory, as a check */
|
||||||
|
|
||||||
|
|
||||||
!File: dataflow.h
|
!File: dataflow.h
|
||||||
#define DATAFLOW 1 /* produce some compile-time xref */
|
#define DATAFLOW 1 /* produce some compile-time xref */
|
||||||
|
|
||||||
|
|
||||||
!File: debug.h
|
!File: debug.h
|
||||||
/*#define DEBUG 1 *//* perform various self-tests */
|
/*#define DEBUG 1 *//* perform various self-tests */
|
||||||
#define NDEBUG 1 /* disable assertions */
|
#define NDEBUG 1 /* disable assertions */
|
||||||
|
|
||||||
|
|
||||||
!File: use_tmp.h
|
!File: use_tmp.h
|
||||||
#define PREPEND_SCOPES 1 /* collect exa, exp, ina and inp commands
|
#define PREPEND_SCOPES 1 /* collect exa, exp, ina and inp commands
|
||||||
and if USE_TMP is defined let them
|
and if USE_TMP is defined let them
|
||||||
precede the rest of the generated
|
precede the rest of the generated
|
||||||
compact code */
|
compact code */
|
||||||
#define USE_TMP 1 /* use C_insertpart, C_endpart mechanism
|
#define USE_TMP 1 /* use C_insertpart, C_endpart mechanism
|
||||||
to generate EM-code in the order needed
|
to generate EM-code in the order needed
|
||||||
for the code-generators. If not defined,
|
for the code-generators. If not defined,
|
||||||
the old-style peephole optimizer is
|
the old-style peephole optimizer is
|
||||||
needed. */
|
needed. */
|
||||||
|
|
||||||
|
|
||||||
!File: parbufsize.h
|
!File: parbufsize.h
|
||||||
#define PARBUFSIZE 1024
|
#define PARBUFSIZE 1024
|
||||||
|
|
||||||
|
|
||||||
!File: textsize.h
|
!File: textsize.h
|
||||||
#define ITEXTSIZE 32 /* 1st piece of memory for repl. text */
|
#define ITEXTSIZE 32 /* 1st piece of memory for repl. text */
|
||||||
|
|
||||||
|
|
||||||
!File: inputtype.h
|
!File: inputtype.h
|
||||||
#define INP_READ_IN_ONE 1 /* read input file in one */
|
#define INP_READ_IN_ONE 1 /* read input file in one */
|
||||||
|
|
||||||
|
|
||||||
!File: nobitfield.h
|
!File: nobitfield.h
|
||||||
/*#define NOBITFIELD 1 *//* if NOT defined, implement bitfields */
|
/*#define NOBITFIELD 1 *//* if NOT defined, implement bitfields */
|
||||||
|
|
||||||
|
|
||||||
!File: static.h
|
!File: static.h
|
||||||
#define GSTATIC /* for large global "static" arrays */
|
#define GSTATIC /* for large global "static" arrays */
|
||||||
|
|
||||||
|
|
||||||
!File: nocross.h
|
!File: nocross.h
|
||||||
/*#define NOCROSS 1 *//* if NOT defined, cross compiler */
|
/*#define NOCROSS 1 *//* if NOT defined, cross compiler */
|
||||||
|
|
||||||
|
|
||||||
!File: regcount.h
|
!File: regcount.h
|
||||||
/*#define REGCOUNT 1 *//* count occurrences for register messages */
|
/*#define REGCOUNT 1 *//* count occurrences for register messages */
|
||||||
|
|
||||||
|
|
||||||
!File: dbsymtab.h
|
!File: dbsymtab.h
|
||||||
#define DBSYMTAB 1 /* ability to produce symbol table for debugger */
|
#define DBSYMTAB 1 /* ability to produce symbol table for debugger */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,34 @@ normalrule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local str_files = basename(filenamesof("./*.str"))
|
local str_files = {
|
||||||
|
"./code.str",
|
||||||
|
"./declar.str",
|
||||||
|
"./def.str",
|
||||||
|
"./estack.str",
|
||||||
|
"./expr.str",
|
||||||
|
"./field.str",
|
||||||
|
"./idf.str",
|
||||||
|
"./l_brace.str",
|
||||||
|
"./l_outdef.str",
|
||||||
|
"./l_state.str",
|
||||||
|
"./macro.str",
|
||||||
|
"./next.str",
|
||||||
|
"./proto.str",
|
||||||
|
"./stack.str",
|
||||||
|
"./stmt.str",
|
||||||
|
"./struct.str",
|
||||||
|
"./switch.str",
|
||||||
|
"./type.str",
|
||||||
|
"./util.str"
|
||||||
|
}
|
||||||
|
|
||||||
|
local str_bases = basename(filenamesof(str_files))
|
||||||
|
|
||||||
local str_targets = {}
|
local str_targets = {}
|
||||||
|
|
||||||
for _, f in ipairs(str_files) do
|
for _, f in ipairs(str_bases) do
|
||||||
local bf = f:gsub("%.str$", "")
|
local bf = f:gsub("%.str$", ""):gsub("^$./", "")
|
||||||
str_targets[#str_targets+1] = normalrule {
|
str_targets[#str_targets+1] = normalrule {
|
||||||
name = "allocd_header/"..bf,
|
name = "allocd_header/"..bf,
|
||||||
ins = { "./make.allocd", "./"..f },
|
ins = { "./make.allocd", "./"..f },
|
||||||
|
@ -32,7 +55,7 @@ normalrule {
|
||||||
name = "next-c",
|
name = "next-c",
|
||||||
ins = {
|
ins = {
|
||||||
"./make.next",
|
"./make.next",
|
||||||
"./*.str",
|
str_files
|
||||||
},
|
},
|
||||||
outleaves = { "next.c" },
|
outleaves = { "next.c" },
|
||||||
commands = {
|
commands = {
|
||||||
|
@ -78,7 +101,11 @@ llgen {
|
||||||
name = "llgen",
|
name = "llgen",
|
||||||
srcs = {
|
srcs = {
|
||||||
"+tokenfile-g", -- must be first
|
"+tokenfile-g", -- must be first
|
||||||
"./*.g",
|
"./declar.g",
|
||||||
|
"./expression.g",
|
||||||
|
"./ival.g",
|
||||||
|
"./program.g",
|
||||||
|
"./statement.g",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,354 +1,354 @@
|
||||||
/*
|
/*
|
||||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/* EXPRESSION SYNTAX PARSER */
|
/* EXPRESSION SYNTAX PARSER */
|
||||||
|
|
||||||
{
|
{
|
||||||
#include <alloc.h>
|
#include <alloc.h>
|
||||||
#include "parameters.h"
|
#include "parameters.h"
|
||||||
#include <flt_arith.h>
|
#include <flt_arith.h>
|
||||||
#include "arith.h"
|
#include "arith.h"
|
||||||
#include "LLlex.h"
|
#include "LLlex.h"
|
||||||
#include "type.h"
|
#include "type.h"
|
||||||
#include "label.h"
|
#include "label.h"
|
||||||
#include "expr.h"
|
#include "expr.h"
|
||||||
#include "code.h"
|
#include "code.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "ch3.h"
|
#include "ch3.h"
|
||||||
#include "ch3bin.h"
|
#include "ch3bin.h"
|
||||||
#include "ch3mon.h"
|
#include "ch3mon.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "sizes.h"
|
#include "sizes.h"
|
||||||
|
|
||||||
extern struct expr *intexpr();
|
extern struct expr *intexpr();
|
||||||
int InSizeof = 0; /* inside a sizeof- expression */
|
int InSizeof = 0; /* inside a sizeof- expression */
|
||||||
int ResultKnown = 0; /* result of the expression is already known */
|
int ResultKnown = 0; /* result of the expression is already known */
|
||||||
|
|
||||||
/* Since the grammar in the standard is not LL(n), it is modified so that
|
/* Since the grammar in the standard is not LL(n), it is modified so that
|
||||||
* it accepts basically the same grammar. This means that there is no 1-1
|
* it accepts basically the same grammar. This means that there is no 1-1
|
||||||
* mapping from the grammar in the standard to the grammar given here.
|
* mapping from the grammar in the standard to the grammar given here.
|
||||||
* Such is life.
|
* Such is life.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 3.3.1 */
|
/* 3.3.1 */
|
||||||
primary(register struct expr **expp;) :
|
primary(register struct expr **expp;) :
|
||||||
IDENTIFIER
|
IDENTIFIER
|
||||||
{dot2expr(expp);}
|
{dot2expr(expp);}
|
||||||
|
|
|
|
||||||
constant(expp)
|
constant(expp)
|
||||||
|
|
|
|
||||||
string(expp)
|
string(expp)
|
||||||
|
|
|
|
||||||
'(' expression(expp) ')'
|
'(' expression(expp) ')'
|
||||||
{ (*expp)->ex_flags |= EX_PARENS; }
|
{ (*expp)->ex_flags |= EX_PARENS; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
/* Character string literals that are adjacent tokens
|
/* Character string literals that are adjacent tokens
|
||||||
* are concatenated into a single character string
|
* are concatenated into a single character string
|
||||||
* literal.
|
* literal.
|
||||||
*/
|
*/
|
||||||
string(register struct expr **expp;)
|
string(register struct expr **expp;)
|
||||||
{ register int i, len;
|
{ register int i, len;
|
||||||
register char *str;
|
register char *str;
|
||||||
register int fund;
|
register int fund;
|
||||||
}
|
}
|
||||||
:
|
:
|
||||||
STRING
|
STRING
|
||||||
{ str = dot.tk_bts;
|
{ str = dot.tk_bts;
|
||||||
len = dot.tk_len;
|
len = dot.tk_len;
|
||||||
fund = dot.tk_fund;
|
fund = dot.tk_fund;
|
||||||
}
|
}
|
||||||
[
|
[
|
||||||
STRING
|
STRING
|
||||||
{ /* A pasted string keeps the type of the first
|
{ /* A pasted string keeps the type of the first
|
||||||
* string literal.
|
* string literal.
|
||||||
* The pasting of normal strings and wide
|
* The pasting of normal strings and wide
|
||||||
* character strings are stated as having an
|
* character strings are stated as having an
|
||||||
* undefined behaviour.
|
* undefined behaviour.
|
||||||
*/
|
*/
|
||||||
if (dot.tk_fund != fund)
|
if (dot.tk_fund != fund)
|
||||||
warning("illegal pasting of string literals");
|
warning("illegal pasting of string literals");
|
||||||
str = Realloc(str, (unsigned) (--len + dot.tk_len));
|
str = Realloc(str, (unsigned) (--len + dot.tk_len));
|
||||||
for (i = 0; i < dot.tk_len; i++)
|
for (i = 0; i < dot.tk_len; i++)
|
||||||
str[len++] = dot.tk_bts[i];
|
str[len++] = dot.tk_bts[i];
|
||||||
}
|
}
|
||||||
]*
|
]*
|
||||||
{ string2expr(expp, str, len); }
|
{ string2expr(expp, str, len); }
|
||||||
;
|
;
|
||||||
|
|
||||||
/* 3.3.2 */
|
/* 3.3.2 */
|
||||||
postfix_expression(register struct expr **expp;)
|
postfix_expression(register struct expr **expp;)
|
||||||
{ int oper;
|
{ int oper;
|
||||||
struct expr *e1 = 0;
|
struct expr *e1 = 0;
|
||||||
struct idf *idf;
|
struct idf *idf;
|
||||||
}
|
}
|
||||||
:
|
:
|
||||||
primary(expp)
|
primary(expp)
|
||||||
[
|
[
|
||||||
'[' expression(&e1) ']'
|
'[' expression(&e1) ']'
|
||||||
{ ch3bin(expp, '[', e1); e1 = 0; }
|
{ ch3bin(expp, '[', e1); e1 = 0; }
|
||||||
|
|
|
|
||||||
'(' parameter_list(&e1)? ')'
|
'(' parameter_list(&e1)? ')'
|
||||||
{ ch3bin(expp, '(', e1); call_proto(expp); e1 = 0; }
|
{ ch3bin(expp, '(', e1); call_proto(expp); e1 = 0; }
|
||||||
|
|
|
|
||||||
[ '.' | ARROW ] { oper = DOT; }
|
[ '.' | ARROW ] { oper = DOT; }
|
||||||
identifier(&idf) { ch3sel(expp, oper, idf); }
|
identifier(&idf) { ch3sel(expp, oper, idf); }
|
||||||
|
|
|
|
||||||
[
|
[
|
||||||
PLUSPLUS { oper = POSTINCR; }
|
PLUSPLUS { oper = POSTINCR; }
|
||||||
|
|
|
|
||||||
MINMIN { oper = POSTDECR; }
|
MINMIN { oper = POSTDECR; }
|
||||||
]
|
]
|
||||||
{ ch3incr(expp, oper); }
|
{ ch3incr(expp, oper); }
|
||||||
]*
|
]*
|
||||||
;
|
;
|
||||||
|
|
||||||
parameter_list(struct expr **expp;)
|
parameter_list(struct expr **expp;)
|
||||||
{struct expr *e1 = 0;}
|
{struct expr *e1 = 0;}
|
||||||
:
|
:
|
||||||
assignment_expression(expp)
|
assignment_expression(expp)
|
||||||
{any2opnd(expp, PARCOMMA);}
|
{any2opnd(expp, PARCOMMA);}
|
||||||
[ %persistent
|
[ %persistent
|
||||||
','
|
','
|
||||||
assignment_expression(&e1)
|
assignment_expression(&e1)
|
||||||
{any2opnd(&e1, PARCOMMA);}
|
{any2opnd(&e1, PARCOMMA);}
|
||||||
{ch3bin(expp, PARCOMMA, e1);}
|
{ch3bin(expp, PARCOMMA, e1);}
|
||||||
]*
|
]*
|
||||||
;
|
;
|
||||||
|
|
||||||
%first first_of_type_specifier, type_specifier;
|
%first first_of_type_specifier, type_specifier;
|
||||||
|
|
||||||
/* 3.3.3 & 3.3.4 */
|
/* 3.3.3 & 3.3.4 */
|
||||||
unary(register struct expr **expp;)
|
unary(register struct expr **expp;)
|
||||||
{struct type *tp; int oper;}
|
{struct type *tp; int oper;}
|
||||||
:
|
:
|
||||||
%if (first_of_type_specifier(AHEAD) && AHEAD != IDENTIFIER)
|
%if (first_of_type_specifier(AHEAD) && AHEAD != IDENTIFIER)
|
||||||
cast(&tp) unary(expp)
|
cast(&tp) unary(expp)
|
||||||
{ ch3cast(expp, CAST, tp);
|
{ ch3cast(expp, CAST, tp);
|
||||||
(*expp)->ex_flags |= EX_CAST;
|
(*expp)->ex_flags |= EX_CAST;
|
||||||
if (int_size != pointer_size)
|
if (int_size != pointer_size)
|
||||||
(*expp)->ex_flags &= ~EX_PTRDIFF;
|
(*expp)->ex_flags &= ~EX_PTRDIFF;
|
||||||
}
|
}
|
||||||
|
|
|
|
||||||
postfix_expression(expp)
|
postfix_expression(expp)
|
||||||
|
|
|
|
||||||
unop(&oper) unary(expp)
|
unop(&oper) unary(expp)
|
||||||
{ch3mon(oper, expp);}
|
{ch3mon(oper, expp);}
|
||||||
|
|
|
|
||||||
size_of(expp)
|
size_of(expp)
|
||||||
;
|
;
|
||||||
|
|
||||||
/* When an identifier is used in a sizeof()-expression, we must stil not
|
/* When an identifier is used in a sizeof()-expression, we must stil not
|
||||||
* mark it as used.
|
* mark it as used.
|
||||||
* extern int i; .... sizeof(i) .... need not have a definition for i
|
* extern int i; .... sizeof(i) .... need not have a definition for i
|
||||||
*/
|
*/
|
||||||
size_of(register struct expr **expp;)
|
size_of(register struct expr **expp;)
|
||||||
{struct type *tp;}
|
{struct type *tp;}
|
||||||
:
|
:
|
||||||
SIZEOF { InSizeof++; } /* handle (sizeof(sizeof(int))) too */
|
SIZEOF { InSizeof++; } /* handle (sizeof(sizeof(int))) too */
|
||||||
[%if (first_of_type_specifier(AHEAD) && AHEAD != IDENTIFIER)
|
[%if (first_of_type_specifier(AHEAD) && AHEAD != IDENTIFIER)
|
||||||
cast(&tp)
|
cast(&tp)
|
||||||
{
|
{
|
||||||
*expp = intexpr(size_of_type(tp, "type"), UNSIGNED);
|
*expp = intexpr(size_of_type(tp, "type"), UNSIGNED);
|
||||||
(*expp)->ex_flags |= EX_SIZEOF;
|
(*expp)->ex_flags |= EX_SIZEOF;
|
||||||
}
|
}
|
||||||
|
|
|
|
||||||
unary(expp)
|
unary(expp)
|
||||||
{ch3mon(SIZEOF, expp);}
|
{ch3mon(SIZEOF, expp);}
|
||||||
]
|
]
|
||||||
{ InSizeof--; }
|
{ InSizeof--; }
|
||||||
;
|
;
|
||||||
|
|
||||||
/* 3.3.5-3.3.17 */
|
/* 3.3.5-3.3.17 */
|
||||||
/* The set of operators in C is stratified in 15 levels, with level
|
/* The set of operators in C is stratified in 15 levels, with level
|
||||||
N being treated in RM 7.N (although this is not the standard
|
N being treated in RM 7.N (although this is not the standard
|
||||||
anymore). The standard describes this in phrase-structure-grammar,
|
anymore). The standard describes this in phrase-structure-grammar,
|
||||||
which we are unable to parse. The description that follows comes
|
which we are unable to parse. The description that follows comes
|
||||||
from the old C-compiler.
|
from the old C-compiler.
|
||||||
|
|
||||||
In principle each operator is assigned a rank, ranging
|
In principle each operator is assigned a rank, ranging
|
||||||
from 1 to 15. Such an expression can be parsed by a construct
|
from 1 to 15. Such an expression can be parsed by a construct
|
||||||
like:
|
like:
|
||||||
binary_expression(int maxrank;)
|
binary_expression(int maxrank;)
|
||||||
{int oper;}
|
{int oper;}
|
||||||
:
|
:
|
||||||
binary_expression(maxrank - 1)
|
binary_expression(maxrank - 1)
|
||||||
[%if (rank_of(DOT) <= maxrank)
|
[%if (rank_of(DOT) <= maxrank)
|
||||||
binop(&oper)
|
binop(&oper)
|
||||||
binary_expression(rank_of(oper)-1)
|
binary_expression(rank_of(oper)-1)
|
||||||
]?
|
]?
|
||||||
;
|
;
|
||||||
except that some call of 'unary' is necessary, depending on the
|
except that some call of 'unary' is necessary, depending on the
|
||||||
grammar.
|
grammar.
|
||||||
|
|
||||||
This simple view is marred by three complications:
|
This simple view is marred by three complications:
|
||||||
1. Level 15 (comma operator) is not allowed in many
|
1. Level 15 (comma operator) is not allowed in many
|
||||||
contexts and is different.
|
contexts and is different.
|
||||||
2. Level 13 (conditional operator) is a ternary operator,
|
2. Level 13 (conditional operator) is a ternary operator,
|
||||||
which does not fit this scheme at all.
|
which does not fit this scheme at all.
|
||||||
3. Level 14 (assignment operators) group right-to-left, as
|
3. Level 14 (assignment operators) group right-to-left, as
|
||||||
opposed to 2-12, which group left-to-right (or are
|
opposed to 2-12, which group left-to-right (or are
|
||||||
immaterial).
|
immaterial).
|
||||||
4. The operators in level 14 start with operators in levels
|
4. The operators in level 14 start with operators in levels
|
||||||
2-13 (RM 7.14: The two parts of a compound assignment
|
2-13 (RM 7.14: The two parts of a compound assignment
|
||||||
operator are separate tokens.) This causes LL1 problems.
|
operator are separate tokens.) This causes LL1 problems.
|
||||||
This forces us to have four rules:
|
This forces us to have four rules:
|
||||||
binary_expression for level 2-12
|
binary_expression for level 2-12
|
||||||
conditional_expression for level 13
|
conditional_expression for level 13
|
||||||
assignment_expression for level 14 and
|
assignment_expression for level 14 and
|
||||||
expression for the most general expression
|
expression for the most general expression
|
||||||
*/
|
*/
|
||||||
|
|
||||||
binary_expression(int maxrank; struct expr **expp;)
|
binary_expression(int maxrank; struct expr **expp;)
|
||||||
{int oper, OldResultKnown; struct expr *e1;}
|
{int oper, OldResultKnown; struct expr *e1;}
|
||||||
:
|
:
|
||||||
unary(expp)
|
unary(expp)
|
||||||
[%while (rank_of(DOT) <= maxrank )
|
[%while (rank_of(DOT) <= maxrank )
|
||||||
/* '?', '=', and ',' are no binops
|
/* '?', '=', and ',' are no binops
|
||||||
*/
|
*/
|
||||||
binop(&oper)
|
binop(&oper)
|
||||||
{ OldResultKnown = ResultKnown;
|
{ OldResultKnown = ResultKnown;
|
||||||
if (oper == OR || oper == AND) {
|
if (oper == OR || oper == AND) {
|
||||||
if (is_cp_cst(*expp) || is_fp_cst(*expp)) {
|
if (is_cp_cst(*expp) || is_fp_cst(*expp)) {
|
||||||
if (is_zero_cst(*expp)) {
|
if (is_zero_cst(*expp)) {
|
||||||
if (oper == AND) ResultKnown++;
|
if (oper == AND) ResultKnown++;
|
||||||
} else if (oper == OR) ResultKnown++;
|
} else if (oper == OR) ResultKnown++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
binary_expression(rank_of(oper)-1, &e1)
|
binary_expression(rank_of(oper)-1, &e1)
|
||||||
{
|
{
|
||||||
ch3bin(expp, oper, e1);
|
ch3bin(expp, oper, e1);
|
||||||
ResultKnown = OldResultKnown;
|
ResultKnown = OldResultKnown;
|
||||||
}
|
}
|
||||||
]*
|
]*
|
||||||
;
|
;
|
||||||
|
|
||||||
/* 3.3.15 */
|
/* 3.3.15 */
|
||||||
conditional_expression(struct expr **expp;)
|
conditional_expression(struct expr **expp;)
|
||||||
{struct expr *e1 = 0, *e2 = 0; int OldResultKnown, ConstExpr=0;}
|
{struct expr *e1 = 0, *e2 = 0; int OldResultKnown, ConstExpr=0;}
|
||||||
:
|
:
|
||||||
/* allow all binary operators */
|
/* allow all binary operators */
|
||||||
binary_expression(rank_of('?') - 1, expp)
|
binary_expression(rank_of('?') - 1, expp)
|
||||||
[ '?'
|
[ '?'
|
||||||
{ OldResultKnown = ResultKnown;
|
{ OldResultKnown = ResultKnown;
|
||||||
if (is_cp_cst(*expp) || is_fp_cst(*expp)) {
|
if (is_cp_cst(*expp) || is_fp_cst(*expp)) {
|
||||||
ConstExpr++;
|
ConstExpr++;
|
||||||
if (is_zero_cst(*expp)) ResultKnown++;
|
if (is_zero_cst(*expp)) ResultKnown++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
expression(&e1)
|
expression(&e1)
|
||||||
':'
|
':'
|
||||||
{ if (ConstExpr) {
|
{ if (ConstExpr) {
|
||||||
if (OldResultKnown == ResultKnown) ResultKnown++;
|
if (OldResultKnown == ResultKnown) ResultKnown++;
|
||||||
else ResultKnown = OldResultKnown;
|
else ResultKnown = OldResultKnown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conditional_expression(&e2)
|
conditional_expression(&e2)
|
||||||
{
|
{
|
||||||
ResultKnown = OldResultKnown;
|
ResultKnown = OldResultKnown;
|
||||||
ch3bin(&e1, ':', e2);
|
ch3bin(&e1, ':', e2);
|
||||||
opnd2test(expp, '?');
|
opnd2test(expp, '?');
|
||||||
ch3bin(expp, '?', e1);
|
ch3bin(expp, '?', e1);
|
||||||
}
|
}
|
||||||
]?
|
]?
|
||||||
;
|
;
|
||||||
|
|
||||||
/* 3.3.16 */
|
/* 3.3.16 */
|
||||||
assignment_expression(struct expr **expp;)
|
assignment_expression(struct expr **expp;)
|
||||||
{ int oper;
|
{ int oper;
|
||||||
struct expr *e1 = 0;
|
struct expr *e1 = 0;
|
||||||
}
|
}
|
||||||
:
|
:
|
||||||
conditional_expression(expp)
|
conditional_expression(expp)
|
||||||
[
|
[
|
||||||
asgnop(&oper)
|
asgnop(&oper)
|
||||||
assignment_expression(&e1)
|
assignment_expression(&e1)
|
||||||
{ch3asgn(expp, oper, e1);}
|
{ch3asgn(expp, oper, e1);}
|
||||||
|
|
|
|
||||||
empty /* LLgen artefact ??? */
|
empty /* LLgen artefact ??? */
|
||||||
]
|
]
|
||||||
;
|
;
|
||||||
|
|
||||||
/* 3.3.17 */
|
/* 3.3.17 */
|
||||||
expression(struct expr **expp;)
|
expression(struct expr **expp;)
|
||||||
{struct expr *e1;}
|
{struct expr *e1;}
|
||||||
:
|
:
|
||||||
assignment_expression(expp)
|
assignment_expression(expp)
|
||||||
[ ','
|
[ ','
|
||||||
assignment_expression(&e1)
|
assignment_expression(&e1)
|
||||||
{
|
{
|
||||||
ch3bin(expp, ',', e1);
|
ch3bin(expp, ',', e1);
|
||||||
}
|
}
|
||||||
]*
|
]*
|
||||||
;
|
;
|
||||||
|
|
||||||
unop(int *oper;) :
|
unop(int *oper;) :
|
||||||
['*' | '&' | '-' | '+' | '!' | '~' | PLUSPLUS | MINMIN]
|
['*' | '&' | '-' | '+' | '!' | '~' | PLUSPLUS | MINMIN]
|
||||||
{ if (DOT == '&') DOT = ADDRESSOF;
|
{ if (DOT == '&') DOT = ADDRESSOF;
|
||||||
*oper = DOT;
|
*oper = DOT;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
multop:
|
multop:
|
||||||
'*' | '/' | '%'
|
'*' | '/' | '%'
|
||||||
;
|
;
|
||||||
|
|
||||||
addop:
|
addop:
|
||||||
'+' | '-'
|
'+' | '-'
|
||||||
;
|
;
|
||||||
|
|
||||||
shiftop:
|
shiftop:
|
||||||
LEFT | RIGHT
|
LEFT | RIGHT
|
||||||
;
|
;
|
||||||
|
|
||||||
relop:
|
relop:
|
||||||
'<' | '>' | LESSEQ | GREATEREQ
|
'<' | '>' | LESSEQ | GREATEREQ
|
||||||
;
|
;
|
||||||
|
|
||||||
eqop:
|
eqop:
|
||||||
EQUAL | NOTEQUAL
|
EQUAL | NOTEQUAL
|
||||||
;
|
;
|
||||||
|
|
||||||
arithop:
|
arithop:
|
||||||
multop | addop | shiftop
|
multop | addop | shiftop
|
||||||
|
|
|
|
||||||
'&' | '^' | '|'
|
'&' | '^' | '|'
|
||||||
;
|
;
|
||||||
|
|
||||||
binop(int *oper;) :
|
binop(int *oper;) :
|
||||||
[ arithop | relop | eqop | AND | OR ]
|
[ arithop | relop | eqop | AND | OR ]
|
||||||
{*oper = DOT;}
|
{*oper = DOT;}
|
||||||
;
|
;
|
||||||
|
|
||||||
asgnop(register int *oper;):
|
asgnop(register int *oper;):
|
||||||
[ '=' | PLUSAB | MINAB | TIMESAB | DIVAB | MODAB
|
[ '=' | PLUSAB | MINAB | TIMESAB | DIVAB | MODAB
|
||||||
| LEFTAB | RIGHTAB | ANDAB | XORAB | ORAB ]
|
| LEFTAB | RIGHTAB | ANDAB | XORAB | ORAB ]
|
||||||
{ *oper = DOT; }
|
{ *oper = DOT; }
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
constant(struct expr **expp;) :
|
constant(struct expr **expp;) :
|
||||||
[
|
[
|
||||||
INTEGER
|
INTEGER
|
||||||
|
|
|
|
||||||
FLOATING
|
FLOATING
|
||||||
] {dot2expr(expp);}
|
] {dot2expr(expp);}
|
||||||
;
|
;
|
||||||
|
|
||||||
/* 3.4 */
|
/* 3.4 */
|
||||||
constant_expression (struct expr **expp;) :
|
constant_expression (struct expr **expp;) :
|
||||||
conditional_expression(expp)
|
conditional_expression(expp)
|
||||||
{ chk_cst_expr(expp); }
|
{ chk_cst_expr(expp); }
|
||||||
;
|
;
|
||||||
|
|
||||||
identifier(struct idf **idfp;) :
|
identifier(struct idf **idfp;) :
|
||||||
[ IDENTIFIER
|
[ IDENTIFIER
|
||||||
| TYPE_IDENTIFIER
|
| TYPE_IDENTIFIER
|
||||||
]
|
]
|
||||||
{ *idfp = dot.tk_idf; }
|
{ *idfp = dot.tk_idf; }
|
||||||
;
|
;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,227 +1,227 @@
|
||||||
/*
|
/*
|
||||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/* PROGRAM PARSER */
|
/* PROGRAM PARSER */
|
||||||
|
|
||||||
/* The presence of typedef declarations renders it impossible to
|
/* The presence of typedef declarations renders it impossible to
|
||||||
make a context-free grammar of C. Consequently we need
|
make a context-free grammar of C. Consequently we need
|
||||||
context-sensitive parsing techniques, the simplest one being
|
context-sensitive parsing techniques, the simplest one being
|
||||||
a subtle cooperation between the parser and the lexical scanner.
|
a subtle cooperation between the parser and the lexical scanner.
|
||||||
The lexical scanner has to know whether to return IDENTIFIER
|
The lexical scanner has to know whether to return IDENTIFIER
|
||||||
or TYPE_IDENTIFIER for a given tag, and it obtains this information
|
or TYPE_IDENTIFIER for a given tag, and it obtains this information
|
||||||
from the definition list, as constructed by the parser.
|
from the definition list, as constructed by the parser.
|
||||||
The present grammar is essentially LL(2), and is processed by
|
The present grammar is essentially LL(2), and is processed by
|
||||||
a parser generator which accepts LL(1) with tie breaking rules
|
a parser generator which accepts LL(1) with tie breaking rules
|
||||||
in C, of the form %if(cond) and %while(cond). To solve the LL(1)
|
in C, of the form %if(cond) and %while(cond). To solve the LL(1)
|
||||||
ambiguities, the lexical scanner does a one symbol look-ahead.
|
ambiguities, the lexical scanner does a one symbol look-ahead.
|
||||||
This symbol, however, cannot always be correctly assessed, since
|
This symbol, however, cannot always be correctly assessed, since
|
||||||
the present symbol may cause a change in the definition list
|
the present symbol may cause a change in the definition list
|
||||||
which causes the identification of the look-ahead symbol to be
|
which causes the identification of the look-ahead symbol to be
|
||||||
invalidated.
|
invalidated.
|
||||||
The lexical scanner relies on the parser (or its routines) to
|
The lexical scanner relies on the parser (or its routines) to
|
||||||
detect this situation and then update the look-ahead symbol.
|
detect this situation and then update the look-ahead symbol.
|
||||||
An alternative approach would be to reassess the look-ahead symbol
|
An alternative approach would be to reassess the look-ahead symbol
|
||||||
in the lexical scanner when it is promoted to dot symbol. This
|
in the lexical scanner when it is promoted to dot symbol. This
|
||||||
would be more beautiful but less correct, since then for a short
|
would be more beautiful but less correct, since then for a short
|
||||||
while there would be a discrepancy between the look-ahead symbol
|
while there would be a discrepancy between the look-ahead symbol
|
||||||
and the definition list; I think it would nevertheless work in
|
and the definition list; I think it would nevertheless work in
|
||||||
correct programs.
|
correct programs.
|
||||||
A third solution would be to enter the identifier as soon as it
|
A third solution would be to enter the identifier as soon as it
|
||||||
is found; its storage class is then known, although its full type
|
is found; its storage class is then known, although its full type
|
||||||
isn't. We would have to fill that in afterwards.
|
isn't. We would have to fill that in afterwards.
|
||||||
|
|
||||||
At block exit the situation is even worse. Upon reading the
|
At block exit the situation is even worse. Upon reading the
|
||||||
closing brace, the names declared inside the function are cleared
|
closing brace, the names declared inside the function are cleared
|
||||||
from the name list. This action may expose a type identifier that
|
from the name list. This action may expose a type identifier that
|
||||||
is the same as the identifier in the look-ahead symbol. This
|
is the same as the identifier in the look-ahead symbol. This
|
||||||
situation certainly invalidates the third solution, and casts
|
situation certainly invalidates the third solution, and casts
|
||||||
doubts upon the second.
|
doubts upon the second.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
%lexical LLlex;
|
%lexical LLlex;
|
||||||
%start C_program, program;
|
%start C_program, program;
|
||||||
%start If_expr, control_if_expression;
|
%start If_expr, control_if_expression;
|
||||||
|
|
||||||
{
|
{
|
||||||
#include "parameters.h"
|
#include "parameters.h"
|
||||||
#include <flt_arith.h>
|
#include <flt_arith.h>
|
||||||
#include "arith.h"
|
#include "arith.h"
|
||||||
#include "LLlex.h"
|
#include "LLlex.h"
|
||||||
#include "label.h"
|
#include "label.h"
|
||||||
#include "type.h"
|
#include "type.h"
|
||||||
#include "declar.h"
|
#include "declar.h"
|
||||||
#include "decspecs.h"
|
#include "decspecs.h"
|
||||||
#include "code.h"
|
#include "code.h"
|
||||||
#include "expr.h"
|
#include "expr.h"
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
#include "idf.h"
|
#include "idf.h"
|
||||||
#include "declarator.h"
|
#include "declarator.h"
|
||||||
#include "stack.h"
|
#include "stack.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#ifdef LINT
|
#ifdef LINT
|
||||||
#include "l_lint.h"
|
#include "l_lint.h"
|
||||||
#endif /* LINT */
|
#endif /* LINT */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
control_if_expression
|
control_if_expression
|
||||||
{
|
{
|
||||||
struct expr *exprX;
|
struct expr *exprX;
|
||||||
}
|
}
|
||||||
:
|
:
|
||||||
constant_expression(&exprX)
|
constant_expression(&exprX)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
/* 3.7 */
|
/* 3.7 */
|
||||||
program:
|
program:
|
||||||
[%persistent external_definition]*
|
[%persistent external_definition]*
|
||||||
{ unstack_world(); }
|
{ unstack_world(); }
|
||||||
;
|
;
|
||||||
|
|
||||||
/* A C identifier definition is remarkable in that it formulates
|
/* A C identifier definition is remarkable in that it formulates
|
||||||
the declaration in a way different from most other languages:
|
the declaration in a way different from most other languages:
|
||||||
e.g., rather than defining x as a pointer-to-integer, it defines
|
e.g., rather than defining x as a pointer-to-integer, it defines
|
||||||
*x as an integer and lets the compiler deduce that x is actually
|
*x as an integer and lets the compiler deduce that x is actually
|
||||||
pointer-to-integer. This has profound consequences, both for the
|
pointer-to-integer. This has profound consequences, both for the
|
||||||
structure of an identifier definition and for the compiler.
|
structure of an identifier definition and for the compiler.
|
||||||
|
|
||||||
A definition starts with a decl_specifiers, which contains things
|
A definition starts with a decl_specifiers, which contains things
|
||||||
like
|
like
|
||||||
typedef int
|
typedef int
|
||||||
which is implicitly repeated for every definition in the list, and
|
which is implicitly repeated for every definition in the list, and
|
||||||
then for each identifier a declarator is given, of the form
|
then for each identifier a declarator is given, of the form
|
||||||
*a()
|
*a()
|
||||||
or so. The decl_specifiers is kept in a struct decspecs, to be
|
or so. The decl_specifiers is kept in a struct decspecs, to be
|
||||||
used again and again, while the declarator is stored in a struct
|
used again and again, while the declarator is stored in a struct
|
||||||
declarator, only to be passed to declare_idf together with the
|
declarator, only to be passed to declare_idf together with the
|
||||||
struct decspecs.
|
struct decspecs.
|
||||||
|
|
||||||
With the introduction of prototypes, extra problems for the scope
|
With the introduction of prototypes, extra problems for the scope
|
||||||
administration were introduced as well. We can have, for example,
|
administration were introduced as well. We can have, for example,
|
||||||
int x(double x);
|
int x(double x);
|
||||||
and
|
and
|
||||||
int x(double x) { ... use(x) ... }
|
int x(double x) { ... use(x) ... }
|
||||||
In the first case, the parameter name can be forgotten, whereas in
|
In the first case, the parameter name can be forgotten, whereas in
|
||||||
the second case, the parameter should have a block scope. The
|
the second case, the parameter should have a block scope. The
|
||||||
problem lies in the fact that the parameter's type is known before
|
problem lies in the fact that the parameter's type is known before
|
||||||
the type of the function, which causes the def structure to be on
|
the type of the function, which causes the def structure to be on
|
||||||
the end of the list. Our solution is as follows:
|
the end of the list. Our solution is as follows:
|
||||||
1- In case of a declaration, throw the parameter identifier away
|
1- In case of a declaration, throw the parameter identifier away
|
||||||
before the declaration of the outer x.
|
before the declaration of the outer x.
|
||||||
2- In case of a definition, the function begin_proc() changes the
|
2- In case of a definition, the function begin_proc() changes the
|
||||||
def list for the identifier. This means that declare_idf()
|
def list for the identifier. This means that declare_idf()
|
||||||
contains an extra test in case we already saw a declaration of
|
contains an extra test in case we already saw a declaration of
|
||||||
such a function, because this function is called before
|
such a function, because this function is called before
|
||||||
begin_proc().
|
begin_proc().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
external_definition
|
external_definition
|
||||||
{ struct decspecs Ds;
|
{ struct decspecs Ds;
|
||||||
struct declarator Dc;
|
struct declarator Dc;
|
||||||
}
|
}
|
||||||
:
|
:
|
||||||
{ Ds = null_decspecs;
|
{ Ds = null_decspecs;
|
||||||
Dc = null_declarator;
|
Dc = null_declarator;
|
||||||
}
|
}
|
||||||
[ %if (DOT != IDENTIFIER || AHEAD == IDENTIFIER)
|
[ %if (DOT != IDENTIFIER || AHEAD == IDENTIFIER)
|
||||||
decl_specifiers(&Ds)
|
decl_specifiers(&Ds)
|
||||||
|
|
|
|
||||||
{do_decspecs(&Ds);}
|
{do_decspecs(&Ds);}
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
declarator(&Dc)
|
declarator(&Dc)
|
||||||
{
|
{
|
||||||
declare_idf(&Ds, &Dc, level);
|
declare_idf(&Ds, &Dc, level);
|
||||||
#ifdef LINT
|
#ifdef LINT
|
||||||
lint_ext_def(Dc.dc_idf, Ds.ds_sc);
|
lint_ext_def(Dc.dc_idf, Ds.ds_sc);
|
||||||
#endif /* LINT */
|
#endif /* LINT */
|
||||||
}
|
}
|
||||||
[
|
[
|
||||||
function(&Ds, &Dc)
|
function(&Ds, &Dc)
|
||||||
|
|
|
|
||||||
{ if (! Ds.ds_sc_given && ! Ds.ds_typequal &&
|
{ if (! Ds.ds_sc_given && ! Ds.ds_typequal &&
|
||||||
Ds.ds_notypegiven) {
|
Ds.ds_notypegiven) {
|
||||||
strict("declaration specifiers missing");
|
strict("declaration specifiers missing");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
non_function(&Ds, &Dc)
|
non_function(&Ds, &Dc)
|
||||||
]
|
]
|
||||||
|
|
|
|
||||||
{ if (! Ds.ds_sc_given && ! Ds.ds_typequal &&
|
{ if (! Ds.ds_sc_given && ! Ds.ds_typequal &&
|
||||||
Ds.ds_notypegiven) {
|
Ds.ds_notypegiven) {
|
||||||
strict("declaration missing");
|
strict("declaration missing");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
';'
|
';'
|
||||||
]
|
]
|
||||||
{remove_declarator(&Dc); flush_strings(); }
|
{remove_declarator(&Dc); flush_strings(); }
|
||||||
;
|
;
|
||||||
|
|
||||||
non_function(register struct decspecs *ds; register struct declarator *dc;)
|
non_function(register struct decspecs *ds; register struct declarator *dc;)
|
||||||
:
|
:
|
||||||
{ reject_params(dc);
|
{ reject_params(dc);
|
||||||
}
|
}
|
||||||
[
|
[
|
||||||
initializer(dc->dc_idf, ds->ds_sc)
|
initializer(dc->dc_idf, ds->ds_sc)
|
||||||
|
|
|
|
||||||
{ code_declaration(dc->dc_idf, (struct expr *) 0, level, ds->ds_sc); }
|
{ code_declaration(dc->dc_idf, (struct expr *) 0, level, ds->ds_sc); }
|
||||||
]
|
]
|
||||||
{
|
{
|
||||||
#ifdef LINT
|
#ifdef LINT
|
||||||
lint_non_function_decl(ds, dc);
|
lint_non_function_decl(ds, dc);
|
||||||
#endif /* LINT */
|
#endif /* LINT */
|
||||||
}
|
}
|
||||||
[
|
[
|
||||||
','
|
','
|
||||||
init_declarator(ds)
|
init_declarator(ds)
|
||||||
]*
|
]*
|
||||||
';'
|
';'
|
||||||
;
|
;
|
||||||
|
|
||||||
/* 3.7.1 */
|
/* 3.7.1 */
|
||||||
function(struct decspecs *ds; struct declarator *dc;)
|
function(struct decspecs *ds; struct declarator *dc;)
|
||||||
{
|
{
|
||||||
arith fbytes;
|
arith fbytes;
|
||||||
register struct idf *idf = dc->dc_idf;
|
register struct idf *idf = dc->dc_idf;
|
||||||
}
|
}
|
||||||
:
|
:
|
||||||
{
|
{
|
||||||
#ifdef LINT
|
#ifdef LINT
|
||||||
lint_start_function();
|
lint_start_function();
|
||||||
#endif /* LINT */
|
#endif /* LINT */
|
||||||
idf_initialized(idf);
|
idf_initialized(idf);
|
||||||
stack_level(); /* L_FORMAL1 declarations */
|
stack_level(); /* L_FORMAL1 declarations */
|
||||||
declare_params(dc);
|
declare_params(dc);
|
||||||
begin_proc(ds, idf); /* sets global function info */
|
begin_proc(ds, idf); /* sets global function info */
|
||||||
stack_level(); /* L_FORMAL2 declarations */
|
stack_level(); /* L_FORMAL2 declarations */
|
||||||
declare_protos(dc);
|
declare_protos(dc);
|
||||||
}
|
}
|
||||||
declaration*
|
declaration*
|
||||||
{
|
{
|
||||||
check_formals(idf, dc); /* check style-mixtures */
|
check_formals(idf, dc); /* check style-mixtures */
|
||||||
declare_formals(idf, &fbytes);
|
declare_formals(idf, &fbytes);
|
||||||
#ifdef LINT
|
#ifdef LINT
|
||||||
lint_formals();
|
lint_formals();
|
||||||
#endif /* LINT */
|
#endif /* LINT */
|
||||||
}
|
}
|
||||||
compound_statement
|
compound_statement
|
||||||
{
|
{
|
||||||
end_proc(fbytes);
|
end_proc(fbytes);
|
||||||
#ifdef LINT
|
#ifdef LINT
|
||||||
lint_implicit_return();
|
lint_implicit_return();
|
||||||
#endif /* LINT */
|
#endif /* LINT */
|
||||||
unstack_level(); /* L_FORMAL2 declarations */
|
unstack_level(); /* L_FORMAL2 declarations */
|
||||||
#ifdef LINT
|
#ifdef LINT
|
||||||
lint_end_formals();
|
lint_end_formals();
|
||||||
#endif /* LINT */
|
#endif /* LINT */
|
||||||
unstack_level(); /* L_FORMAL1 declarations */
|
unstack_level(); /* L_FORMAL1 declarations */
|
||||||
#ifdef LINT
|
#ifdef LINT
|
||||||
lint_end_function();
|
lint_end_function();
|
||||||
#endif /* LINT */
|
#endif /* LINT */
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,16 +1,16 @@
|
||||||
default:
|
default:
|
||||||
if (tok <= 0) return "end of file";
|
if (tok <= 0) return "end of file";
|
||||||
if (tok < 040 || tok >= 0177) {
|
if (tok < 040 || tok >= 0177) {
|
||||||
return "bad token";
|
return "bad token";
|
||||||
}
|
}
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case '\n':
|
case '\n':
|
||||||
case '\f':
|
case '\f':
|
||||||
case '\v':
|
case '\v':
|
||||||
case '\r':
|
case '\r':
|
||||||
case '\t':
|
case '\t':
|
||||||
index = (index+2) & (SIZBUF-1);
|
index = (index+2) & (SIZBUF-1);
|
||||||
buf[index] = tok;
|
buf[index] = tok;
|
||||||
return &buf[index];
|
return &buf[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
/* Generated by make.tokcase */
|
/* Generated by make.tokcase */
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
#include "Lpars.h"
|
#include "Lpars.h"
|
||||||
|
|
||||||
char *symbol2str(int tok)
|
char *symbol2str(int tok)
|
||||||
{
|
{
|
||||||
#define SIZBUF 8
|
#define SIZBUF 8
|
||||||
/* allow for a few invocations in f.i. an argument list */
|
/* allow for a few invocations in f.i. an argument list */
|
||||||
static char buf[SIZBUF];
|
static char buf[SIZBUF];
|
||||||
static int index;
|
static int index;
|
||||||
|
|
||||||
switch (tok) {
|
switch (tok) {
|
||||||
|
|
|
@ -58,7 +58,8 @@ normalrule {
|
||||||
name = "next_c",
|
name = "next_c",
|
||||||
ins = {
|
ins = {
|
||||||
"./make.next",
|
"./make.next",
|
||||||
"./*.str",
|
"./macro.str",
|
||||||
|
"./replace.str",
|
||||||
},
|
},
|
||||||
outleaves = { "next.c" },
|
outleaves = { "next.c" },
|
||||||
commands = {
|
commands = {
|
||||||
|
@ -82,7 +83,22 @@ tabgen {
|
||||||
cprogram {
|
cprogram {
|
||||||
name = "cpp",
|
name = "cpp",
|
||||||
srcs = concat(
|
srcs = concat(
|
||||||
"./*.c",
|
"./ch3bin.c",
|
||||||
|
"./ch3mon.c",
|
||||||
|
"./domacro.c",
|
||||||
|
"./error.c",
|
||||||
|
"./expr.c",
|
||||||
|
"./idf.c",
|
||||||
|
"./init.c",
|
||||||
|
"./input.c",
|
||||||
|
"./LLlex.c",
|
||||||
|
"./LLmessage.c",
|
||||||
|
"./main.c",
|
||||||
|
"./options.c",
|
||||||
|
"./preprocess.c",
|
||||||
|
"./replace.c",
|
||||||
|
"./skip.c",
|
||||||
|
"./tokenname.c",
|
||||||
matching(filenamesof(llgen), "%.c$"),
|
matching(filenamesof(llgen), "%.c$"),
|
||||||
"+next_c",
|
"+next_c",
|
||||||
"+symbol2str_c",
|
"+symbol2str_c",
|
||||||
|
|
|
@ -33,24 +33,163 @@ for _, plat in ipairs(vars.plats) do
|
||||||
srcs = {
|
srcs = {
|
||||||
"+ctype_files",
|
"+ctype_files",
|
||||||
"+ctype_tab",
|
"+ctype_tab",
|
||||||
"./core/ctype/*.c",
|
"./core/ctype/tolower.c",
|
||||||
"./core/errno/*.c",
|
"./core/ctype/toupper.c",
|
||||||
"./core/locale/*.c",
|
"./core/errno/errlist.c",
|
||||||
"./core/math/*.c",
|
"./core/errno/perror.c",
|
||||||
"./core/math/*.e",
|
"./core/errno/strerror.c",
|
||||||
"./core/misc/*.c",
|
"./core/locale/localeconv.c",
|
||||||
"./core/printf/*.c",
|
"./core/locale/setlocale.c",
|
||||||
"./core/scanf/*.c",
|
"./core/math/asin.c",
|
||||||
"./core/setjmp/*.c",
|
"./core/math/atan2.c",
|
||||||
"./core/setjmp/*.e",
|
"./core/math/atan.c",
|
||||||
"./core/stdlib/*.c",
|
"./core/math/ceil.c",
|
||||||
"./core/stdio/*.c",
|
"./core/math/exp.c",
|
||||||
"./core/string/*.c",
|
"./core/math/fabs.c",
|
||||||
"./core/time/*.c",
|
"./core/math/floor.c",
|
||||||
"./sys/exit/*.c",
|
"./core/math/fmod.c",
|
||||||
"./sys/malloc/*.c",
|
"./core/math/frexp.e",
|
||||||
"./sys/misc/*.c",
|
"./core/math/hugeval.c",
|
||||||
"./sys/stdio/*.c",
|
"./core/math/hypot.c",
|
||||||
|
"./core/math/isnan.c",
|
||||||
|
"./core/math/ldexp.c",
|
||||||
|
"./core/math/log10.c",
|
||||||
|
"./core/math/log.c",
|
||||||
|
"./core/math/modf.e",
|
||||||
|
"./core/math/pow.c",
|
||||||
|
"./core/math/sin.c",
|
||||||
|
"./core/math/sinh.c",
|
||||||
|
"./core/math/sqrt.c",
|
||||||
|
"./core/math/tan.c",
|
||||||
|
"./core/math/tanh.c",
|
||||||
|
"./core/misc/abort.c",
|
||||||
|
"./core/misc/assert.c",
|
||||||
|
"./core/misc/getopt.c",
|
||||||
|
"./core/misc/raise.c",
|
||||||
|
"./core/misc/termcap.c",
|
||||||
|
"./core/printf/doprnt.c",
|
||||||
|
"./core/printf/fltpr.c",
|
||||||
|
"./core/printf/fprintf.c",
|
||||||
|
"./core/printf/icompute.c",
|
||||||
|
"./core/printf/itoa.c",
|
||||||
|
"./core/printf/printf.c",
|
||||||
|
"./core/printf/snprintf.c",
|
||||||
|
"./core/printf/sprintf.c",
|
||||||
|
"./core/printf/vfprintf.c",
|
||||||
|
"./core/printf/vprintf.c",
|
||||||
|
"./core/printf/vsnprintf.c",
|
||||||
|
"./core/printf/vsprintf.c",
|
||||||
|
"./core/scanf/doscan.c",
|
||||||
|
"./core/scanf/fscanf.c",
|
||||||
|
"./core/scanf/scanf.c",
|
||||||
|
"./core/scanf/sscanf.c",
|
||||||
|
"./core/scanf/vfscanf.c",
|
||||||
|
"./core/setjmp/setjmp.e",
|
||||||
|
"./core/setjmp/sigmisc.c",
|
||||||
|
"./core/stdio/clearerr.c",
|
||||||
|
"./core/stdio/feof.c",
|
||||||
|
"./core/stdio/ferror.c",
|
||||||
|
"./core/stdio/fgetc.c",
|
||||||
|
"./core/stdio/fgetpos.c",
|
||||||
|
"./core/stdio/fgets.c",
|
||||||
|
"./core/stdio/fputc.c",
|
||||||
|
"./core/stdio/fputs.c",
|
||||||
|
"./core/stdio/fread.c",
|
||||||
|
"./core/stdio/fsetpos.c",
|
||||||
|
"./core/stdio/fwrite.c",
|
||||||
|
"./core/stdio/getc.c",
|
||||||
|
"./core/stdio/getchar.c",
|
||||||
|
"./core/stdio/gets.c",
|
||||||
|
"./core/stdio/getw.c",
|
||||||
|
"./core/stdio/putc.c",
|
||||||
|
"./core/stdio/putchar.c",
|
||||||
|
"./core/stdio/puts.c",
|
||||||
|
"./core/stdio/putw.c",
|
||||||
|
"./core/stdio/rewind.c",
|
||||||
|
"./core/stdlib/abs.c",
|
||||||
|
"./core/stdlib/atof.c",
|
||||||
|
"./core/stdlib/atoi.c",
|
||||||
|
"./core/stdlib/atol.c",
|
||||||
|
"./core/stdlib/bsearch.c",
|
||||||
|
"./core/stdlib/div.c",
|
||||||
|
"./core/stdlib/ecvt.c",
|
||||||
|
"./core/stdlib/environ.c",
|
||||||
|
"./core/stdlib/ext_comp.c",
|
||||||
|
"./core/stdlib/getenv.c",
|
||||||
|
"./core/stdlib/labs.c",
|
||||||
|
"./core/stdlib/ldiv.c",
|
||||||
|
"./core/stdlib/mblen.c",
|
||||||
|
"./core/stdlib/mbstowcs.c",
|
||||||
|
"./core/stdlib/mbtowc.c",
|
||||||
|
"./core/stdlib/putenv.c",
|
||||||
|
"./core/stdlib/qsort.c",
|
||||||
|
"./core/stdlib/rand.c",
|
||||||
|
"./core/stdlib/setenv.c",
|
||||||
|
"./core/stdlib/strtod.c",
|
||||||
|
"./core/stdlib/strtol.c",
|
||||||
|
"./core/stdlib/wcstombs.c",
|
||||||
|
"./core/stdlib/wctomb.c",
|
||||||
|
"./core/string/memchr.c",
|
||||||
|
"./core/string/memcmp.c",
|
||||||
|
"./core/string/memcpy.c",
|
||||||
|
"./core/string/memmove.c",
|
||||||
|
"./core/string/memset.c",
|
||||||
|
"./core/string/strcat.c",
|
||||||
|
"./core/string/strchr.c",
|
||||||
|
"./core/string/strcmp.c",
|
||||||
|
"./core/string/strcoll.c",
|
||||||
|
"./core/string/strcpy.c",
|
||||||
|
"./core/string/strcspn.c",
|
||||||
|
"./core/string/strdup.c",
|
||||||
|
"./core/string/strlen.c",
|
||||||
|
"./core/string/strncat.c",
|
||||||
|
"./core/string/strncmp.c",
|
||||||
|
"./core/string/strncpy.c",
|
||||||
|
"./core/string/strpbrk.c",
|
||||||
|
"./core/string/strrchr.c",
|
||||||
|
"./core/string/strspn.c",
|
||||||
|
"./core/string/strstr.c",
|
||||||
|
"./core/string/strtok.c",
|
||||||
|
"./core/string/strxfrm.c",
|
||||||
|
"./core/time/asctime.c",
|
||||||
|
"./core/time/ctime.c",
|
||||||
|
"./core/time/difftime.c",
|
||||||
|
"./core/time/gmtime.c",
|
||||||
|
"./core/time/localtime.c",
|
||||||
|
"./core/time/misc.c",
|
||||||
|
"./core/time/mktime.c",
|
||||||
|
"./core/time/strftime.c",
|
||||||
|
"./core/time/tzset.c",
|
||||||
|
"./sys/exit/atexit.c",
|
||||||
|
"./sys/exit/exit.c",
|
||||||
|
"./sys/malloc/calloc.c",
|
||||||
|
"./sys/malloc/malloc.c",
|
||||||
|
"./sys/malloc/realloc.c",
|
||||||
|
"./sys/misc/clock.c",
|
||||||
|
"./sys/misc/getpass.c",
|
||||||
|
"./sys/misc/isatty.c",
|
||||||
|
"./sys/misc/mktemp.c",
|
||||||
|
"./sys/misc/popen.c",
|
||||||
|
"./sys/misc/remove.c",
|
||||||
|
"./sys/misc/sleep.c",
|
||||||
|
"./sys/misc/system.c",
|
||||||
|
"./sys/misc/time.c",
|
||||||
|
"./sys/stdio/data.c",
|
||||||
|
"./sys/stdio/fclose.c",
|
||||||
|
"./sys/stdio/fdopen.c",
|
||||||
|
"./sys/stdio/fflush.c",
|
||||||
|
"./sys/stdio/fileno.c",
|
||||||
|
"./sys/stdio/fillbuf.c",
|
||||||
|
"./sys/stdio/flushbuf.c",
|
||||||
|
"./sys/stdio/fopen.c",
|
||||||
|
"./sys/stdio/freopen.c",
|
||||||
|
"./sys/stdio/fseek.c",
|
||||||
|
"./sys/stdio/ftell.c",
|
||||||
|
"./sys/stdio/setbuf.c",
|
||||||
|
"./sys/stdio/setvbuf.c",
|
||||||
|
"./sys/stdio/tmpfile.c",
|
||||||
|
"./sys/stdio/tmpnam.c",
|
||||||
|
"./sys/stdio/ungetc.c",
|
||||||
},
|
},
|
||||||
hdrs = {}, -- must be empty
|
hdrs = {}, -- must be empty
|
||||||
deps = {
|
deps = {
|
||||||
|
|
|
@ -11,9 +11,38 @@ local function addheader(dir, list)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
addheader("", filenamesof("./*.h"))
|
addheader("", filenamesof(
|
||||||
addheader("sys/", filenamesof("./sys/*.h"))
|
"./assert.h",
|
||||||
addheader("ack/", filenamesof("./ack/*.h"))
|
"./ctype.h",
|
||||||
|
"./errno.h",
|
||||||
|
"./fcntl.h",
|
||||||
|
"./float.h",
|
||||||
|
"./iso646.h",
|
||||||
|
"./limits.h",
|
||||||
|
"./locale.h",
|
||||||
|
"./math.h",
|
||||||
|
"./setjmp.h",
|
||||||
|
"./signal.h",
|
||||||
|
"./stdarg.h",
|
||||||
|
"./stdbool.h",
|
||||||
|
"./stddef.h",
|
||||||
|
"./stdint.h",
|
||||||
|
"./stdio.h",
|
||||||
|
"./stdlib.h",
|
||||||
|
"./string.h",
|
||||||
|
"./time.h",
|
||||||
|
"./unistd.h"
|
||||||
|
))
|
||||||
|
|
||||||
|
addheader("sys/", filenamesof(
|
||||||
|
"./sys/time.h",
|
||||||
|
"./sys/times.h"
|
||||||
|
))
|
||||||
|
|
||||||
|
addheader("ack/", filenamesof(
|
||||||
|
"./ack/config.h",
|
||||||
|
"./ack/emufile.h"
|
||||||
|
))
|
||||||
|
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "headers",
|
name = "headers",
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <alloc.h>
|
#include <alloc.h>
|
||||||
#include <em_arith.h>
|
#include <em_arith.h>
|
||||||
#include <em_label.h>
|
#include <em_label.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "parameters.h"
|
#include "parameters.h"
|
||||||
#include "idf.h"
|
#include "idf.h"
|
||||||
|
|
|
@ -15,7 +15,10 @@ llgen {
|
||||||
srcs = {
|
srcs = {
|
||||||
-- order here is important
|
-- order here is important
|
||||||
"+tokenfile_g",
|
"+tokenfile_g",
|
||||||
"./*.g",
|
"./declar.g",
|
||||||
|
"./expression.g",
|
||||||
|
"./program.g",
|
||||||
|
"./statement.g",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,42 +34,10 @@ normalrule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, f in ipairs(filenamesof("./*.xh")) do
|
|
||||||
local name = replace(basename(f), "%.xh$", "")
|
|
||||||
normalrule {
|
|
||||||
name = name.."_h",
|
|
||||||
ins = {
|
|
||||||
"./make.allocd",
|
|
||||||
f
|
|
||||||
},
|
|
||||||
outleaves = { name..".h" },
|
|
||||||
commands = {
|
|
||||||
"%{ins[1]} < %{ins[2]} > %{outs}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, f in ipairs(filenamesof("./*.xc")) do
|
|
||||||
local name = replace(basename(f), "%.xc$", "")
|
|
||||||
normalrule {
|
|
||||||
name = name.."_c",
|
|
||||||
ins = {
|
|
||||||
"./make.allocd",
|
|
||||||
f
|
|
||||||
},
|
|
||||||
outleaves = { name..".c" },
|
|
||||||
commands = {
|
|
||||||
"%{ins[1]} < %{ins[2]} > %{outs}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
normalrule {
|
normalrule {
|
||||||
name = "next_c",
|
name = "next_c",
|
||||||
ins = {
|
ins = {
|
||||||
"./make.next",
|
"./make.next",
|
||||||
"./*.xh",
|
|
||||||
"./*.xc",
|
|
||||||
},
|
},
|
||||||
outleaves = { "next.c" },
|
outleaves = { "next.c" },
|
||||||
commands = {
|
commands = {
|
||||||
|
@ -94,22 +65,39 @@ tabgen {
|
||||||
cprogram {
|
cprogram {
|
||||||
name = "em_m2",
|
name = "em_m2",
|
||||||
srcs = {
|
srcs = {
|
||||||
"./*.c",
|
|
||||||
"+casestat_c",
|
|
||||||
"+next_c",
|
|
||||||
"+scope_c",
|
|
||||||
"+symbol2str_c",
|
|
||||||
"+tmpvar_c",
|
|
||||||
"+chartab_c",
|
"+chartab_c",
|
||||||
|
"+next_c",
|
||||||
|
"+symbol2str_c",
|
||||||
|
"./LLlex.c",
|
||||||
|
"./LLmessage.c",
|
||||||
|
"./casestat.c",
|
||||||
|
"./chk_expr.c",
|
||||||
|
"./code.c",
|
||||||
|
"./cstoper.c",
|
||||||
|
"./def.c",
|
||||||
|
"./defmodule.c",
|
||||||
|
"./desig.c",
|
||||||
|
"./enter.c",
|
||||||
|
"./error.c",
|
||||||
|
"./idf.c",
|
||||||
|
"./input.c",
|
||||||
|
"./lookup.c",
|
||||||
|
"./main.c",
|
||||||
|
"./misc.c",
|
||||||
|
"./node.c",
|
||||||
|
"./options.c",
|
||||||
|
"./scope.c",
|
||||||
|
"./stab.c",
|
||||||
|
"./tmpvar.c",
|
||||||
|
"./tokenname.c",
|
||||||
|
"./type.c",
|
||||||
|
"./typequiv.c",
|
||||||
|
"./walk.c",
|
||||||
matching(filenamesof("+llgen"), "%.c$"),
|
matching(filenamesof("+llgen"), "%.c$"),
|
||||||
},
|
},
|
||||||
deps = {
|
deps = {
|
||||||
"+def_h",
|
|
||||||
"+llgen",
|
"+llgen",
|
||||||
"+node_h",
|
|
||||||
"+parameters_h",
|
"+parameters_h",
|
||||||
"+real_h",
|
|
||||||
"+type_h",
|
|
||||||
"h+emheaders",
|
"h+emheaders",
|
||||||
"lang/m2/include+headers",
|
"lang/m2/include+headers",
|
||||||
"modules+headers",
|
"modules+headers",
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "parameters.h"
|
#include "parameters.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "em_label.h"
|
#include "em_label.h"
|
||||||
#include "em_arith.h"
|
#include "em_arith.h"
|
||||||
|
@ -50,7 +51,8 @@ struct switch_hdr {
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
/* STATICALLOCDEF "switch_hdr" 5 */
|
#define new_switch_hdr() ((struct switch_hdr*) calloc(1, sizeof(struct switch_hdr)))
|
||||||
|
#define free_switch_hdr(p) free(p)
|
||||||
|
|
||||||
struct case_entry {
|
struct case_entry {
|
||||||
struct case_entry *ce_next; /* next in list */
|
struct case_entry *ce_next; /* next in list */
|
||||||
|
@ -60,7 +62,8 @@ struct case_entry {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* STATICALLOCDEF "case_entry" 20 */
|
#define new_case_entry() ((struct case_entry*) calloc(1, sizeof(struct case_entry)))
|
||||||
|
#define free_case_entry(p) free(p)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "parameters.h"
|
#include "parameters.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "em_arith.h"
|
#include "em_arith.h"
|
||||||
#include "em_label.h"
|
#include "em_label.h"
|
||||||
|
|
|
@ -132,7 +132,8 @@ struct def { /* list of definitions for a name */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* ALLOCDEF "def" 50 */
|
#define new_def() ((struct def*) calloc(1, sizeof(struct def)))
|
||||||
|
#define free_def(p) free(p)
|
||||||
|
|
||||||
|
|
||||||
#define NULLDEF ((struct def *) 0)
|
#define NULLDEF ((struct def *) 0)
|
||||||
|
@ -150,4 +151,4 @@ struct def * DefineLocalModule(struct idf *id);
|
||||||
void CheckWithDef(register struct def *df, struct type *tp);
|
void CheckWithDef(register struct def *df, struct type *tp);
|
||||||
void end_definition_list(register struct def **pdf);
|
void end_definition_list(register struct def **pdf);
|
||||||
|
|
||||||
#endif /* DEF_H_ */
|
#endif /* DEF_H_ */
|
|
@ -19,6 +19,7 @@
|
||||||
#include "parameters.h"
|
#include "parameters.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "em_arith.h"
|
#include "em_arith.h"
|
||||||
#include "em_label.h"
|
#include "em_label.h"
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <varargs.h>
|
#include <varargs.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <system.h>
|
#include <system.h>
|
||||||
#include <em_arith.h>
|
#include <em_arith.h>
|
||||||
#include <em_label.h>
|
#include <em_label.h>
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <em_arith.h>
|
#include <em_arith.h>
|
||||||
#include <em_label.h>
|
#include <em_label.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "lookup.h"
|
#include "lookup.h"
|
||||||
#include "LLlex.h"
|
#include "LLlex.h"
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "em_arith.h"
|
#include "em_arith.h"
|
||||||
#include "em_label.h"
|
#include "em_label.h"
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
sed -e '
|
|
||||||
s:^.*[ ]ALLOCDEF[ ].*"\(.*\)"[ ]*\([0-9][0-9]*\).*$:\
|
|
||||||
/* allocation definitions of struct \1 */\
|
|
||||||
extern char *st_alloc();\
|
|
||||||
extern struct \1 *h_\1;\
|
|
||||||
#ifdef DEBUG\
|
|
||||||
extern int cnt_\1;\
|
|
||||||
extern char *std_alloc();\
|
|
||||||
#define new_\1() ((struct \1 *) std_alloc((char **)\&h_\1, sizeof(struct \1), \2, \&cnt_\1))\
|
|
||||||
#else\
|
|
||||||
#define new_\1() ((struct \1 *) st_alloc((char **)\&h_\1, sizeof(struct \1), \2))\
|
|
||||||
#endif\
|
|
||||||
#define free_\1(p) st_free(p, \&h_\1, sizeof(struct \1))\
|
|
||||||
:' -e '
|
|
||||||
s:^.*[ ]STATICALLOCDEF[ ].*"\(.*\)"[ ]*\([0-9][0-9]*\).*$:\
|
|
||||||
/* allocation definitions of struct \1 */\
|
|
||||||
extern char *st_alloc();\
|
|
||||||
struct \1 *h_\1;\
|
|
||||||
#ifdef DEBUG\
|
|
||||||
int cnt_\1;\
|
|
||||||
#define new_\1() ((struct \1 *) std_alloc((char **)\&h_\1, sizeof(struct \1), \2, \&cnt_\1))\
|
|
||||||
#else\
|
|
||||||
#define new_\1() ((struct \1 *) st_alloc((char **)\&h_\1, sizeof(struct \1), \2))\
|
|
||||||
#endif\
|
|
||||||
#define free_\1(p) st_free(p, \&h_\1, sizeof(struct \1))\
|
|
||||||
:'
|
|
|
@ -1,35 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
: Update Files from database
|
|
||||||
|
|
||||||
PATH=/bin:/usr/bin
|
|
||||||
|
|
||||||
case $# in
|
|
||||||
1) ;;
|
|
||||||
*) echo use: $0 file >&2
|
|
||||||
exit 1
|
|
||||||
esac
|
|
||||||
|
|
||||||
(
|
|
||||||
IFCOMMAND="if [ -r \$FN ] ;\
|
|
||||||
then if cmp -s \$FN \$TMP;\
|
|
||||||
then rm \$TMP;\
|
|
||||||
else mv \$TMP \$FN;\
|
|
||||||
echo update \$FN;\
|
|
||||||
fi;\
|
|
||||||
else mv \$TMP \$FN;\
|
|
||||||
echo create \$FN;\
|
|
||||||
fi"
|
|
||||||
echo 'TMP=.uf$$'
|
|
||||||
echo 'FN=$TMP'
|
|
||||||
echo 'cat >$TMP <<\!EOF!'
|
|
||||||
sed -n '/^!File:/,${
|
|
||||||
/^$/d
|
|
||||||
/^!File:[ ]*\(.*\)$/s@@!EOF!\
|
|
||||||
'"$IFCOMMAND"'\
|
|
||||||
FN=\1\
|
|
||||||
cat >$TMP <<\\!EOF!@
|
|
||||||
p
|
|
||||||
}' $1
|
|
||||||
echo '!EOF!'
|
|
||||||
echo $IFCOMMAND
|
|
||||||
) | eval "$(cat)"
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <em_arith.h>
|
#include <em_arith.h>
|
||||||
#include <alloc.h>
|
#include <alloc.h>
|
||||||
#include <system.h>
|
#include <system.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "LLlex.h"
|
#include "LLlex.h"
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
|
|
|
@ -52,9 +52,8 @@ struct node {
|
||||||
#define nd_RVAL nd_token.TOK_RVAL
|
#define nd_RVAL nd_token.TOK_RVAL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define new_node() ((struct node*) calloc(1, sizeof(struct node)))
|
||||||
|
#define free_node(p) free(p)
|
||||||
/* ALLOCDEF "node" 50 */
|
|
||||||
|
|
||||||
extern struct node *dot2node(), *dot2leaf(), *getnode();
|
extern struct node *dot2node(), *dot2leaf(), *getnode();
|
||||||
|
|
||||||
|
@ -76,4 +75,4 @@ void FreeNode(register struct node *nd);
|
||||||
int NodeCrash(register struct node* expp, label exit_label, int end_reached);
|
int NodeCrash(register struct node* expp, label exit_label, int end_reached);
|
||||||
int PNodeCrash(struct node **expp, int flags);
|
int PNodeCrash(struct node **expp, int flags);
|
||||||
|
|
||||||
#endif /* NODE_H_ */
|
#endif /* NODE_H_ */
|
|
@ -14,6 +14,7 @@
|
||||||
#include <em_arith.h>
|
#include <em_arith.h>
|
||||||
#include <em_label.h>
|
#include <em_label.h>
|
||||||
#include <alloc.h>
|
#include <alloc.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "type.h"
|
#include "type.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
|
@ -1,158 +0,0 @@
|
||||||
# $Id$
|
|
||||||
|
|
||||||
# make Modula-2 compiler
|
|
||||||
|
|
||||||
#PARAMS do not remove this line!
|
|
||||||
|
|
||||||
UTIL_BIN = \
|
|
||||||
$(UTIL_HOME)/bin
|
|
||||||
SRC_DIR = \
|
|
||||||
$(SRC_HOME)/lang/m2/comp
|
|
||||||
|
|
||||||
TABGEN= $(UTIL_BIN)/tabgen
|
|
||||||
LLGEN = $(UTIL_BIN)/LLgen
|
|
||||||
LLGENOPTIONS = \
|
|
||||||
-n
|
|
||||||
|
|
||||||
SRC_G = $(SRC_DIR)/program.g $(SRC_DIR)/declar.g \
|
|
||||||
$(SRC_DIR)/expression.g $(SRC_DIR)/statement.g
|
|
||||||
GEN_G = tokenfile.g
|
|
||||||
GFILES= $(GEN_G) $(SRC_G)
|
|
||||||
|
|
||||||
SRC_C = $(SRC_DIR)/LLlex.c $(SRC_DIR)/LLmessage.c $(SRC_DIR)/error.c \
|
|
||||||
$(SRC_DIR)/main.c $(SRC_DIR)/tokenname.c $(SRC_DIR)/idf.c \
|
|
||||||
$(SRC_DIR)/input.c $(SRC_DIR)/type.c $(SRC_DIR)/def.c \
|
|
||||||
$(SRC_DIR)/misc.c $(SRC_DIR)/enter.c $(SRC_DIR)/defmodule.c \
|
|
||||||
$(SRC_DIR)/typequiv.c $(SRC_DIR)/node.c $(SRC_DIR)/cstoper.c \
|
|
||||||
$(SRC_DIR)/chk_expr.c $(SRC_DIR)/options.c $(SRC_DIR)/walk.c \
|
|
||||||
$(SRC_DIR)/desig.c $(SRC_DIR)/code.c $(SRC_DIR)/lookup.c \
|
|
||||||
$(SRC_DIR)/stab.c
|
|
||||||
GEN_C = tokenfile.c program.c declar.c expression.c statement.c \
|
|
||||||
symbol2str.c char.c Lpars.c Lncor.c casestat.c tmpvar.c scope.c next.c
|
|
||||||
CFILES= $(SRC_C) $(GEN_C)
|
|
||||||
|
|
||||||
SRC_H = $(SRC_DIR)/LLlex.h $(SRC_DIR)/chk_expr.h $(SRC_DIR)/class.h \
|
|
||||||
$(SRC_DIR)/debug.h $(SRC_DIR)/desig.h $(SRC_DIR)/f_info.h \
|
|
||||||
$(SRC_DIR)/idf.h $(SRC_DIR)/input.h $(SRC_DIR)/main.h \
|
|
||||||
$(SRC_DIR)/misc.h $(SRC_DIR)/scope.h $(SRC_DIR)/standards.h \
|
|
||||||
$(SRC_DIR)/tokenname.h $(SRC_DIR)/walk.h $(SRC_DIR)/warning.h \
|
|
||||||
$(SRC_DIR)/SYSTEM.h
|
|
||||||
GEN_H = errout.h idfsize.h numsize.h strsize.h target_sizes.h bigresult.h \
|
|
||||||
inputtype.h density.h squeeze.h nocross.h nostrict.h def.h debugcst.h \
|
|
||||||
type.h Lpars.h node.h strict3rd.h real.h use_insert.h dbsymtab.h \
|
|
||||||
uns_arith.h def.h type.h node.h real.h
|
|
||||||
HFILES= $(GEN_H) $(SRC_H)
|
|
||||||
|
|
||||||
NEXTFILES = \
|
|
||||||
$(SRC_DIR)/def.H $(SRC_DIR)/type.H $(SRC_DIR)/node.H $(SRC_DIR)/real.H \
|
|
||||||
$(SRC_DIR)/scope.C $(SRC_DIR)/tmpvar.C $(SRC_DIR)/casestat.C
|
|
||||||
|
|
||||||
all: make.main
|
|
||||||
make -f make.main main
|
|
||||||
|
|
||||||
install: all
|
|
||||||
cp main $(TARGET_HOME)/lib.bin/em_m2
|
|
||||||
if [ $(DO_MACHINE_INDEP) = y ] ; \
|
|
||||||
then mk_manpage $(SRC_DIR)/em_m2.6 $(TARGET_HOME) ; \
|
|
||||||
mk_manpage $(SRC_DIR)/modula-2.1 $(TARGET_HOME) ; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
cmp: all
|
|
||||||
-cmp main $(TARGET_HOME)/lib.bin/em_m2
|
|
||||||
|
|
||||||
opr:
|
|
||||||
make pr | opr
|
|
||||||
|
|
||||||
pr:
|
|
||||||
@pr $(SRC_DIR)/proto.make $(SRC_DIR)/proto.main Parameters \
|
|
||||||
$(SRC_DIR)/char.tab $(SRC_G) $(SRC_H) $(NEXTFILES) $(SRC_C)
|
|
||||||
|
|
||||||
lint: make.main
|
|
||||||
make -f make.main lint
|
|
||||||
|
|
||||||
Cfiles: hfiles LLfiles $(GEN_C) $(GEN_H) Makefile
|
|
||||||
echo $(CFILES) | tr ' ' '\012' > Cfiles
|
|
||||||
echo $(HFILES) | tr ' ' '\012' >> Cfiles
|
|
||||||
|
|
||||||
resolved: Cfiles
|
|
||||||
CC="$(CC)" UTIL_HOME="$(UTIL_HOME)" do_resolve `cat Cfiles` > Cfiles.new
|
|
||||||
-if cmp -s Cfiles Cfiles.new ; then rm -f Cfiles.new ; else mv Cfiles.new Cfiles ; fi
|
|
||||||
touch resolved
|
|
||||||
|
|
||||||
# there is no file called "dependencies"; we want dependencies checked
|
|
||||||
# every time. This means that make.main is made every time. Oh well ...
|
|
||||||
# it does not take much time.
|
|
||||||
dependencies: resolved
|
|
||||||
do_deps `grep '.c$$' Cfiles`
|
|
||||||
|
|
||||||
make.main: dependencies make_macros lists $(SRC_DIR)/proto.main
|
|
||||||
rm_deps $(SRC_DIR)/proto.main | sed -e '/^.PARAMS/r make_macros' -e '/^.LISTS/r lists' > make.main
|
|
||||||
cat *.dep >> make.main
|
|
||||||
|
|
||||||
make_macros: Makefile
|
|
||||||
echo 'SRC_DIR=$(SRC_DIR)' > make_macros
|
|
||||||
echo 'UTIL_HOME=$(UTIL_HOME)' >> make_macros
|
|
||||||
echo 'TARGET_HOME=$(TARGET_HOME)' >> make_macros
|
|
||||||
echo 'CC=$(CC)' >> make_macros
|
|
||||||
echo 'COPTIONS=$(COPTIONS)' >> make_macros
|
|
||||||
echo 'LDOPTIONS=$(LDOPTIONS)' >> make_macros
|
|
||||||
echo 'LINT=$(LINT)' >> make_macros
|
|
||||||
echo 'LINTSUF=$(LINTSUF)' >> make_macros
|
|
||||||
echo 'LINTPREF=$(LINTPREF)' >> make_macros
|
|
||||||
echo 'LINTOPTIONS=$(LINTOPTIONS)' >> make_macros
|
|
||||||
echo 'SUF=$(SUF)' >> make_macros
|
|
||||||
echo 'LIBSUF=$(LIBSUF)' >> make_macros
|
|
||||||
echo 'CC_AND_MKDEP=$(CC_AND_MKDEP)' >> make_macros
|
|
||||||
|
|
||||||
lists: Cfiles
|
|
||||||
echo "C_SRC = \\" > lists
|
|
||||||
echo $(CFILES) >> lists
|
|
||||||
echo "OBJ = \\" >> lists
|
|
||||||
echo $(CFILES) | sed -e 's|[^ ]*/||g' -e 's/\.c/.$$(SUF)/g' >> lists
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-make -f make.main clean
|
|
||||||
rm -f $(GEN_C) $(GEN_G) $(GEN_H) hfiles LLfiles Cfiles LL.output
|
|
||||||
rm -f resolved *.dep lists make.main make_macros
|
|
||||||
|
|
||||||
LLfiles: $(GFILES)
|
|
||||||
$(LLGEN) $(LLGENOPTIONS) $(GFILES)
|
|
||||||
@touch LLfiles
|
|
||||||
@if [ -f Lncor.c ] ; then : ; else touch Lncor.c ; fi
|
|
||||||
|
|
||||||
hfiles: Parameters $(SRC_DIR)/make.hfiles
|
|
||||||
$(SRC_DIR)/make.hfiles Parameters
|
|
||||||
touch hfiles
|
|
||||||
|
|
||||||
tokenfile.g: $(SRC_DIR)/tokenname.c $(SRC_DIR)/make.tokfile
|
|
||||||
$(SRC_DIR)/make.tokfile <$(SRC_DIR)/tokenname.c >tokenfile.g
|
|
||||||
|
|
||||||
symbol2str.c: $(SRC_DIR)/tokenname.c $(SRC_DIR)/make.tokcase
|
|
||||||
$(SRC_DIR)/make.tokcase <$(SRC_DIR)/tokenname.c >symbol2str.c
|
|
||||||
|
|
||||||
def.h: $(SRC_DIR)/make.allocd $(SRC_DIR)/def.H
|
|
||||||
$(SRC_DIR)/make.allocd < $(SRC_DIR)/def.H > def.h
|
|
||||||
|
|
||||||
type.h: $(SRC_DIR)/make.allocd $(SRC_DIR)/type.H
|
|
||||||
$(SRC_DIR)/make.allocd < $(SRC_DIR)/type.H > type.h
|
|
||||||
|
|
||||||
real.h: $(SRC_DIR)/make.allocd $(SRC_DIR)/real.H
|
|
||||||
$(SRC_DIR)/make.allocd < $(SRC_DIR)/real.H > real.h
|
|
||||||
|
|
||||||
node.h: $(SRC_DIR)/make.allocd $(SRC_DIR)/node.H
|
|
||||||
$(SRC_DIR)/make.allocd < $(SRC_DIR)/node.H > node.h
|
|
||||||
|
|
||||||
scope.c: $(SRC_DIR)/make.allocd $(SRC_DIR)/scope.C
|
|
||||||
$(SRC_DIR)/make.allocd < $(SRC_DIR)/scope.C > scope.c
|
|
||||||
|
|
||||||
tmpvar.c: $(SRC_DIR)/make.allocd $(SRC_DIR)/tmpvar.C
|
|
||||||
$(SRC_DIR)/make.allocd < $(SRC_DIR)/tmpvar.C > tmpvar.c
|
|
||||||
|
|
||||||
casestat.c: $(SRC_DIR)/make.allocd $(SRC_DIR)/casestat.C
|
|
||||||
$(SRC_DIR)/make.allocd < $(SRC_DIR)/casestat.C > casestat.c
|
|
||||||
|
|
||||||
next.c: $(NEXTFILES) $(SRC_DIR)/make.next
|
|
||||||
$(SRC_DIR)/make.next $(NEXTFILES) > next.c
|
|
||||||
|
|
||||||
char.c: $(SRC_DIR)/char.tab
|
|
||||||
$(TABGEN) -f$(SRC_DIR)/char.tab >char.c
|
|
|
@ -16,4 +16,5 @@ struct real {
|
||||||
flt_arith r_val;
|
flt_arith r_val;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ALLOCDEF "real" 20 */
|
#define new_real() ((struct real*) calloc(1, sizeof(struct real)))
|
||||||
|
#define free_real(p) free(p)
|
|
@ -12,6 +12,7 @@
|
||||||
#include "parameters.h"
|
#include "parameters.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "alloc.h"
|
#include "alloc.h"
|
||||||
#include "em_arith.h"
|
#include "em_arith.h"
|
||||||
|
@ -31,9 +32,11 @@ struct scopelist *CurrVis, *GlobalVis;
|
||||||
extern int proclevel;
|
extern int proclevel;
|
||||||
extern char options[];
|
extern char options[];
|
||||||
|
|
||||||
/* STATICALLOCDEF "scope" 10 */
|
#define new_scope() ((struct scope*) calloc(1, sizeof(struct scope)))
|
||||||
|
#define free_scope(p) free(p)
|
||||||
|
|
||||||
/* STATICALLOCDEF "scopelist" 10 */
|
#define new_scopelist() ((struct scopelist*) calloc(1, sizeof(struct scopelist)))
|
||||||
|
#define free_scopelist(p) free(p)
|
||||||
|
|
||||||
static int sc_count;
|
static int sc_count;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <em_reg.h>
|
#include <em_reg.h>
|
||||||
#include <alloc.h>
|
#include <alloc.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "LLlex.h"
|
#include "LLlex.h"
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
|
@ -32,13 +33,15 @@
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
#include "tmpvar.h"
|
#include "tmpvar.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "tmpvar.h"
|
||||||
|
|
||||||
struct tmpvar {
|
struct tmpvar {
|
||||||
struct tmpvar *t_next;
|
struct tmpvar *t_next;
|
||||||
arith t_offset; /* offset from LocalBase */
|
arith t_offset; /* offset from LocalBase */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* STATICALLOCDEF "tmpvar" 10 */
|
#define new_tmpvar() ((struct tmpvar*) calloc(1, sizeof(struct tmpvar)))
|
||||||
|
#define free_tmpvar(p) free(p)
|
||||||
|
|
||||||
static struct tmpvar *TmpInts, /* for integer temporaries */
|
static struct tmpvar *TmpInts, /* for integer temporaries */
|
||||||
*TmpPtrs; /* for pointer temporaries */
|
*TmpPtrs; /* for pointer temporaries */
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include "parameters.h"
|
#include "parameters.h"
|
||||||
#include "tokenname.h"
|
#include "tokenname.h"
|
||||||
#include "Lpars.h"
|
#include "Lpars.h"
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "parameters.h"
|
#include "parameters.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ack_string.h>
|
#include <ack_string.h>
|
||||||
#include <alloc.h>
|
#include <alloc.h>
|
||||||
|
|
|
@ -24,8 +24,8 @@ struct paramlist { /* structure for parameterlist of a PROCEDURE */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct paramlist;
|
struct paramlist;
|
||||||
|
#define new_paramlist() ((struct paramlist*) calloc(1, sizeof(struct paramlist)))
|
||||||
/* ALLOCDEF "paramlist" 20 */
|
#define free_paramlist(p) free(p)
|
||||||
|
|
||||||
struct enume {
|
struct enume {
|
||||||
struct def *en_enums; /* Definitions of enumeration literals */
|
struct def *en_enums; /* Definitions of enumeration literals */
|
||||||
|
@ -36,7 +36,8 @@ struct enume {
|
||||||
#define enm_rck tp_value.tp_enum->en_rck
|
#define enm_rck tp_value.tp_enum->en_rck
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ALLOCDEF "enume" 5 */
|
#define new_enume() ((struct enume*) calloc(1, sizeof(struct enume)))
|
||||||
|
#define free_enume(p) free(p)
|
||||||
|
|
||||||
struct subrange {
|
struct subrange {
|
||||||
arith su_lb, su_ub; /* lower bound and upper bound */
|
arith su_lb, su_ub; /* lower bound and upper bound */
|
||||||
|
@ -46,7 +47,8 @@ struct subrange {
|
||||||
#define sub_rck tp_value.tp_subrange->su_rck
|
#define sub_rck tp_value.tp_subrange->su_rck
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ALLOCDEF "subrange" 5 */
|
#define new_subrange() ((struct subrange*) calloc(1, sizeof(struct subrange)))
|
||||||
|
#define free_subrange(p) free(p)
|
||||||
|
|
||||||
struct array {
|
struct array {
|
||||||
struct type *ar_elem; /* type of elements */
|
struct type *ar_elem; /* type of elements */
|
||||||
|
@ -61,7 +63,8 @@ struct array {
|
||||||
#define arr_high tp_value.tp_arr->ar_high
|
#define arr_high tp_value.tp_arr->ar_high
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ALLOCDEF "array" 5 */
|
#define new_array() ((struct array*) calloc(1, sizeof(struct array)))
|
||||||
|
#define free_array(p) free(p)
|
||||||
|
|
||||||
struct record {
|
struct record {
|
||||||
struct scope *rc_scope; /* scope of this record */
|
struct scope *rc_scope; /* scope of this record */
|
||||||
|
@ -126,7 +129,8 @@ struct type {
|
||||||
|
|
||||||
struct type;
|
struct type;
|
||||||
|
|
||||||
/* ALLOCDEF "type" 50 */
|
#define new_type() ((struct type*) calloc(1, sizeof(struct type)))
|
||||||
|
#define free_type(p) free(p)
|
||||||
|
|
||||||
extern struct type
|
extern struct type
|
||||||
*bool_type,
|
*bool_type,
|
||||||
|
@ -290,4 +294,4 @@ int lcm(int m, int n);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* TYPE_H_ */
|
#endif /* TYPE_H_ */
|
|
@ -15,6 +15,7 @@
|
||||||
#include "parameters.h"
|
#include "parameters.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <em_arith.h>
|
#include <em_arith.h>
|
||||||
#include <em_label.h>
|
#include <em_label.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
clibrary {
|
clibrary {
|
||||||
name = "headers",
|
name = "headers",
|
||||||
hdrs = {"./*.h"}
|
hdrs = {
|
||||||
|
"./libm2.h",
|
||||||
|
"./m2_traps.h",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,34 @@ local function addheader(dir, list)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
addheader("", filenamesof("./*.def"))
|
addheader("", filenamesof(
|
||||||
|
"./Arguments.def",
|
||||||
|
"./ArraySort.def",
|
||||||
|
"./ASCII.def",
|
||||||
|
"./Conversions.def",
|
||||||
|
"./CSP.def",
|
||||||
|
"./EM.def",
|
||||||
|
"./Epilogue.def",
|
||||||
|
"./InOut.def",
|
||||||
|
"./MathLib0.def",
|
||||||
|
"./Mathlib.def",
|
||||||
|
"./PascalIO.def",
|
||||||
|
"./Processes.def",
|
||||||
|
"./random.def",
|
||||||
|
"./RealConversions.def",
|
||||||
|
"./RealInOut.def",
|
||||||
|
"./Semaphores.def",
|
||||||
|
"./Storage.def",
|
||||||
|
"./Streams.def",
|
||||||
|
"./Strings.def",
|
||||||
|
"./StripUnix.def",
|
||||||
|
"./Termcap.def",
|
||||||
|
"./Terminal.def",
|
||||||
|
"./Traps.def",
|
||||||
|
"./Unix.def",
|
||||||
|
"./XXTermcap.def"
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
installable {
|
installable {
|
||||||
name = "headers",
|
name = "headers",
|
||||||
|
@ -20,8 +47,47 @@ for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = {
|
srcs = {
|
||||||
"./*.c",
|
"./absd.c",
|
||||||
"./*.mod",
|
"./absi.c",
|
||||||
|
"./absl.c",
|
||||||
|
"./Arguments.c",
|
||||||
|
"./ArraySort.mod",
|
||||||
|
"./blockmove.c",
|
||||||
|
"./cap.c",
|
||||||
|
"./catch.c",
|
||||||
|
"./confarray.c",
|
||||||
|
"./Conversions.mod",
|
||||||
|
"./CSP.mod",
|
||||||
|
"./dvi.c",
|
||||||
|
"./halt.c",
|
||||||
|
"./init.c",
|
||||||
|
"./InOut.mod",
|
||||||
|
"./load.c",
|
||||||
|
"./MathLib0.mod",
|
||||||
|
"./Mathlib.mod",
|
||||||
|
"./PascalIO.mod",
|
||||||
|
"./Processes.mod",
|
||||||
|
"./random.mod",
|
||||||
|
"./rcka.c",
|
||||||
|
"./rcki.c",
|
||||||
|
"./rckil.c",
|
||||||
|
"./rcku.c",
|
||||||
|
"./rckul.c",
|
||||||
|
"./RealConversions.mod",
|
||||||
|
"./RealInOut.mod",
|
||||||
|
"./Semaphores.mod",
|
||||||
|
"./sigtrp.c",
|
||||||
|
"./stackprio.c",
|
||||||
|
"./Storage.mod",
|
||||||
|
"./store.c",
|
||||||
|
"./StrAss.c",
|
||||||
|
"./Streams.mod",
|
||||||
|
"./Strings.mod",
|
||||||
|
"./SYSTEM.c",
|
||||||
|
"./Termcap.mod",
|
||||||
|
"./Terminal.mod",
|
||||||
|
"./Traps.mod",
|
||||||
|
"./ucheck.c",
|
||||||
"./EM.e",
|
"./EM.e",
|
||||||
"./LtoUset.e",
|
"./LtoUset.e",
|
||||||
"./absf.e",
|
"./absf.e",
|
||||||
|
|
|
@ -15,7 +15,10 @@ llgen {
|
||||||
srcs = {
|
srcs = {
|
||||||
-- order here is important
|
-- order here is important
|
||||||
"+tokenfile_g",
|
"+tokenfile_g",
|
||||||
"./*.g",
|
"./declar.g",
|
||||||
|
"./expression.g",
|
||||||
|
"./program.g",
|
||||||
|
"./statement.g",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +34,15 @@ normalrule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, f in ipairs(filenamesof("./*.xh")) do
|
local xh_files = {
|
||||||
|
"./def.xh",
|
||||||
|
"./desig.xh",
|
||||||
|
"./node.xh",
|
||||||
|
"./scope.xh",
|
||||||
|
"./type.xh",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, f in ipairs(filenamesof(xh_files)) do
|
||||||
local name = replace(basename(f), "%.xh$", "")
|
local name = replace(basename(f), "%.xh$", "")
|
||||||
normalrule {
|
normalrule {
|
||||||
name = name.."_h",
|
name = name.."_h",
|
||||||
|
@ -46,7 +57,12 @@ for _, f in ipairs(filenamesof("./*.xh")) do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, f in ipairs(filenamesof("./*.xc")) do
|
local xc_files = {
|
||||||
|
"./casestat.xc",
|
||||||
|
"./tmpvar.xc",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, f in ipairs(filenamesof(xc_files)) do
|
||||||
local name = replace(basename(f), "%.xc$", "")
|
local name = replace(basename(f), "%.xc$", "")
|
||||||
normalrule {
|
normalrule {
|
||||||
name = name.."_c",
|
name = name.."_c",
|
||||||
|
@ -65,8 +81,8 @@ normalrule {
|
||||||
name = "next_c",
|
name = "next_c",
|
||||||
ins = {
|
ins = {
|
||||||
"./make.next",
|
"./make.next",
|
||||||
"./*.xh",
|
xh_files,
|
||||||
"./*.xc",
|
xc_files
|
||||||
},
|
},
|
||||||
outleaves = { "next.c" },
|
outleaves = { "next.c" },
|
||||||
commands = {
|
commands = {
|
||||||
|
@ -94,7 +110,31 @@ tabgen {
|
||||||
cprogram {
|
cprogram {
|
||||||
name = "em_pc",
|
name = "em_pc",
|
||||||
srcs = {
|
srcs = {
|
||||||
"./*.c",
|
"./body.c",
|
||||||
|
"./chk_expr.c",
|
||||||
|
"./code.c",
|
||||||
|
"./cstoper.c",
|
||||||
|
"./def.c",
|
||||||
|
"./desig.c",
|
||||||
|
"./enter.c",
|
||||||
|
"./error.c",
|
||||||
|
"./idf.c",
|
||||||
|
"./input.c",
|
||||||
|
"./label.c",
|
||||||
|
"./LLlex.c",
|
||||||
|
"./LLmessage.c",
|
||||||
|
"./lookup.c",
|
||||||
|
"./main.c",
|
||||||
|
"./misc.c",
|
||||||
|
"./node.c",
|
||||||
|
"./options.c",
|
||||||
|
"./progs.c",
|
||||||
|
"./readwrite.c",
|
||||||
|
"./scope.c",
|
||||||
|
"./stab.c",
|
||||||
|
"./tokenname.c",
|
||||||
|
"./type.c",
|
||||||
|
"./typequiv.c",
|
||||||
"+casestat_c",
|
"+casestat_c",
|
||||||
"+chartab_c",
|
"+chartab_c",
|
||||||
"+next_c",
|
"+next_c",
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
clibrary {
|
clibrary {
|
||||||
name = "headers",
|
name = "headers",
|
||||||
hdrs = {"./*.h"}
|
hdrs = {
|
||||||
|
"./pc_err.h",
|
||||||
|
"./pc_file.h",
|
||||||
|
"./pc.h",
|
||||||
|
"./pc_math.h",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,66 @@ for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = {
|
srcs = {
|
||||||
"./*.c",
|
"./abi.c",
|
||||||
|
"./abl.c",
|
||||||
|
"./abr.c",
|
||||||
|
"./arg.c",
|
||||||
|
"./ass.c",
|
||||||
|
"./asz.c",
|
||||||
|
"./atn.c",
|
||||||
|
"./bcp.c",
|
||||||
|
"./buff.c",
|
||||||
|
"./catch.c",
|
||||||
|
"./cls.c",
|
||||||
|
"./cvt.c",
|
||||||
|
"./diag.c",
|
||||||
|
"./efl.c",
|
||||||
|
"./eln.c",
|
||||||
|
"./exp.c",
|
||||||
|
"./get.c",
|
||||||
|
"./hlt.c",
|
||||||
|
"./incpt.c",
|
||||||
|
"./ini.c",
|
||||||
|
"./log.c",
|
||||||
|
"./mdi.c",
|
||||||
|
"./mdl.c",
|
||||||
|
"./new.c",
|
||||||
|
"./nfa.c",
|
||||||
|
"./nobuff.c",
|
||||||
|
"./notext.c",
|
||||||
|
"./opn.c",
|
||||||
|
"./outcpt.c",
|
||||||
|
"./pac.c",
|
||||||
|
"./pclose.c",
|
||||||
|
"./pcreat.c",
|
||||||
|
"./pentry.c",
|
||||||
|
"./perrno.c",
|
||||||
|
"./pexit.c",
|
||||||
|
"./popen.c",
|
||||||
|
"./put.c",
|
||||||
|
"./rcka.c",
|
||||||
|
"./rdc.c",
|
||||||
|
"./rdi.c",
|
||||||
|
"./rdl.c",
|
||||||
|
"./rdr.c",
|
||||||
|
"./rf.c",
|
||||||
|
"./rln.c",
|
||||||
|
"./rnd.c",
|
||||||
|
"./sin.c",
|
||||||
|
"./sqt.c",
|
||||||
|
"./string.c",
|
||||||
|
"./unp.c",
|
||||||
|
"./uread.c",
|
||||||
|
"./uwrite.c",
|
||||||
|
"./wdw.c",
|
||||||
|
"./wf.c",
|
||||||
|
"./wrc.c",
|
||||||
|
"./wrf.c",
|
||||||
|
"./wri.c",
|
||||||
|
"./wrl.c",
|
||||||
|
"./wrr.c",
|
||||||
|
"./wrs.c",
|
||||||
|
"./wrz.c",
|
||||||
"./bts.e",
|
"./bts.e",
|
||||||
"./encaps.e",
|
"./encaps.e",
|
||||||
"./fef.e",
|
"./fef.e",
|
||||||
|
|
|
@ -93,12 +93,12 @@ main(argc, argv)
|
||||||
}
|
}
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 1: break;
|
case 1: break;
|
||||||
case 3: if ((output = fopen(argv[2], "w")) == (FILE *)0)
|
case 3: if ((output = fopen(argv[2], "wb")) == (FILE *)0)
|
||||||
fatal("Can't write %s.\n", argv[2]);
|
fatal("Can't write %s.\n", argv[2]);
|
||||||
ofile = argv[2];
|
ofile = argv[2];
|
||||||
ofile_created = 1;
|
ofile_created = 1;
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case 2: if ((input = fopen(argv[1], "r")) == (FILE *)0)
|
case 2: if ((input = fopen(argv[1], "rb")) == (FILE *)0)
|
||||||
fatal("Can't read %s.\n", argv[1]);
|
fatal("Can't read %s.\n", argv[1]);
|
||||||
break;
|
break;
|
||||||
default:fatal("Usage: %s <ack object> <riscos object>.\n", argv[0]);
|
default:fatal("Usage: %s <ack object> <riscos object>.\n", argv[0]);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
for _, plat in ipairs(vars.plats) do
|
for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = { "./*.e" },
|
srcs = { "./dummy.e", },
|
||||||
vars = { plat = plat },
|
vars = { plat = plat },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
for _, plat in ipairs(vars.plats) do
|
for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = { "./*.e" },
|
srcs = {
|
||||||
|
"./edata.e",
|
||||||
|
"./em_end.e",
|
||||||
|
"./end.e",
|
||||||
|
"./etext.e",
|
||||||
|
},
|
||||||
vars = { plat = plat },
|
vars = { plat = plat },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
12
mach/i386/as/build.lua
Normal file
12
mach/i386/as/build.lua
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
bundle {
|
||||||
|
name = "headers",
|
||||||
|
srcs = {
|
||||||
|
"./mach0.c",
|
||||||
|
"./mach1.c",
|
||||||
|
"./mach2.c",
|
||||||
|
"./mach3.c",
|
||||||
|
"./mach4.c",
|
||||||
|
"./mach5.c",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,59 @@
|
||||||
for _, plat in ipairs(vars.plats) do
|
for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = { "./*.s" }, -- csb8.s
|
srcs = {
|
||||||
|
"./adi.s",
|
||||||
|
"./and.s",
|
||||||
|
"./blm.s",
|
||||||
|
"./cii.s",
|
||||||
|
"./cms.s",
|
||||||
|
"./com.s",
|
||||||
|
"./csa4.s",
|
||||||
|
"./csa8.s",
|
||||||
|
"./csb4.s",
|
||||||
|
"./csb8.s",
|
||||||
|
"./cuu.s",
|
||||||
|
"./divrem8.s",
|
||||||
|
"./dup.s",
|
||||||
|
"./dvi8.s",
|
||||||
|
"./dvi.s",
|
||||||
|
"./dvu8.s",
|
||||||
|
"./dvu.s",
|
||||||
|
"./error.s",
|
||||||
|
"./exg.s",
|
||||||
|
"./fat.s",
|
||||||
|
"./fp8087.s",
|
||||||
|
"./gto.s",
|
||||||
|
"./iaar.s",
|
||||||
|
"./ilar.s",
|
||||||
|
"./inn.s",
|
||||||
|
"./ior.s",
|
||||||
|
"./isar.s",
|
||||||
|
"./lar4.s",
|
||||||
|
"./loi.s",
|
||||||
|
"./mli8.s",
|
||||||
|
"./mli.s",
|
||||||
|
"./mon.s",
|
||||||
|
"./ngi.s",
|
||||||
|
"./nop.s",
|
||||||
|
"./print.s",
|
||||||
|
"./rck.s",
|
||||||
|
"./rmi8.s",
|
||||||
|
"./rmi.s",
|
||||||
|
"./rmu.s",
|
||||||
|
"./rol.s",
|
||||||
|
"./ror.s",
|
||||||
|
"./sar4.s",
|
||||||
|
"./sbi.s",
|
||||||
|
"./set.s",
|
||||||
|
"./sli.s",
|
||||||
|
"./sri.s",
|
||||||
|
"./sti.s",
|
||||||
|
"./strhp.s",
|
||||||
|
"./trp.s",
|
||||||
|
"./unknown.s",
|
||||||
|
"./xor.s",
|
||||||
|
},
|
||||||
vars = { plat = plat },
|
vars = { plat = plat },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
for _, plat in ipairs(vars.plats) do
|
for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = { "./*.s" },
|
srcs = {
|
||||||
|
"./edata.s",
|
||||||
|
"./em_end.s",
|
||||||
|
"./end.s",
|
||||||
|
"./etext.s",
|
||||||
|
},
|
||||||
vars = { plat = plat },
|
vars = { plat = plat },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
8
mach/i386/ncg/build.lua
Normal file
8
mach/i386/ncg/build.lua
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
bundle {
|
||||||
|
name = "headers",
|
||||||
|
srcs = {
|
||||||
|
"./mach.c",
|
||||||
|
"./mach.h"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
12
mach/i80/as/build.lua
Normal file
12
mach/i80/as/build.lua
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
bundle {
|
||||||
|
name = "headers",
|
||||||
|
srcs = {
|
||||||
|
"./mach0.c",
|
||||||
|
"./mach1.c",
|
||||||
|
"./mach2.c",
|
||||||
|
"./mach3.c",
|
||||||
|
"./mach4.c",
|
||||||
|
"./mach5.c",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -58,7 +58,52 @@ end
|
||||||
for _, plat in ipairs(vars.plats) do
|
for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = concat("./*.s", generated),
|
srcs = {
|
||||||
|
"./aar2.s",
|
||||||
|
"./adi4.s",
|
||||||
|
"./and.s",
|
||||||
|
"./blm.s",
|
||||||
|
"./cii.s",
|
||||||
|
"./cmi4.s",
|
||||||
|
"./cmps_mag.s",
|
||||||
|
"./cmpu_mag.s",
|
||||||
|
"./cms.s",
|
||||||
|
"./com.s",
|
||||||
|
"./csa.s",
|
||||||
|
"./csb.s",
|
||||||
|
"./dup.s",
|
||||||
|
"./dvi2.s",
|
||||||
|
"./dvi4.s",
|
||||||
|
"./exg.s",
|
||||||
|
"./flp.s",
|
||||||
|
"./inn.s",
|
||||||
|
"./ior.s",
|
||||||
|
"./lar2.s",
|
||||||
|
"./loi.s",
|
||||||
|
"./mli2.s",
|
||||||
|
"./mli4.s",
|
||||||
|
"./mlu2.s",
|
||||||
|
"./ngi4.s",
|
||||||
|
"./nop.s",
|
||||||
|
"./pchl.s",
|
||||||
|
"./pro.s",
|
||||||
|
"./rck.s",
|
||||||
|
"./ret.s",
|
||||||
|
"./rol4.s",
|
||||||
|
"./ror4.s",
|
||||||
|
"./rst.s",
|
||||||
|
"./sar2.s",
|
||||||
|
"./sbi4.s",
|
||||||
|
"./set2.s",
|
||||||
|
"./set.s",
|
||||||
|
"./sli2.s",
|
||||||
|
"./sli4.s",
|
||||||
|
"./sri2.s",
|
||||||
|
"./sri4.s",
|
||||||
|
"./sti.s",
|
||||||
|
"./xor.s",
|
||||||
|
generated
|
||||||
|
},
|
||||||
vars = {
|
vars = {
|
||||||
plat = plat,
|
plat = plat,
|
||||||
["+ackcflags"] = {"-Imach/i80/libem"}
|
["+ackcflags"] = {"-Imach/i80/libem"}
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
for _, plat in ipairs(vars.plats) do
|
for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = { "./*.s" },
|
srcs = {
|
||||||
|
"./edata.s",
|
||||||
|
"./em_end.s",
|
||||||
|
"./end.s",
|
||||||
|
"./etext.s",
|
||||||
|
},
|
||||||
vars = { plat = plat },
|
vars = { plat = plat },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
8
mach/i80/ncg/build.lua
Normal file
8
mach/i80/ncg/build.lua
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
bundle {
|
||||||
|
name = "headers",
|
||||||
|
srcs = {
|
||||||
|
"./mach.c",
|
||||||
|
"./mach.h"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
12
mach/i86/as/build.lua
Normal file
12
mach/i86/as/build.lua
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
bundle {
|
||||||
|
name = "headers",
|
||||||
|
srcs = {
|
||||||
|
"./mach0.c",
|
||||||
|
"./mach1.c",
|
||||||
|
"./mach2.c",
|
||||||
|
"./mach3.c",
|
||||||
|
"./mach4.c",
|
||||||
|
"./mach5.c",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ main(argc, argv)
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 1: rd_fdopen(0);
|
case 1: rd_fdopen(0);
|
||||||
break;
|
break;
|
||||||
case 3: if ((output = fopen(argv[2], "w")) == 0) {
|
case 3: if ((output = fopen(argv[2], "wb")) == 0) {
|
||||||
fatal("Can't write %s.\n", argv[2]);
|
fatal("Can't write %s.\n", argv[2]);
|
||||||
}
|
}
|
||||||
output_file = argv[2];
|
output_file = argv[2];
|
||||||
|
|
|
@ -1,7 +1,67 @@
|
||||||
for _, plat in ipairs(vars.plats) do
|
for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = { "./*.s" },
|
srcs = {
|
||||||
|
"./adi.s",
|
||||||
|
"./and.s",
|
||||||
|
"./blm.s",
|
||||||
|
"./cii.s",
|
||||||
|
"./cmi4.s",
|
||||||
|
"./cms.s",
|
||||||
|
"./cmu4.s",
|
||||||
|
"./com.s",
|
||||||
|
"./csa2.s",
|
||||||
|
"./csa4.s",
|
||||||
|
"./csb2.s",
|
||||||
|
"./csb4.s",
|
||||||
|
"./cuu.s",
|
||||||
|
"./dup.s",
|
||||||
|
"./dvi4.s",
|
||||||
|
"./dvi.s",
|
||||||
|
"./dvu4.s",
|
||||||
|
"./dvu.s",
|
||||||
|
"./error.s",
|
||||||
|
"./exg.s",
|
||||||
|
"./fat.s",
|
||||||
|
"./fp8087.s",
|
||||||
|
"./gto.s",
|
||||||
|
"./iaar.s",
|
||||||
|
"./ilar.s",
|
||||||
|
"./inn.s",
|
||||||
|
"./ior.s",
|
||||||
|
"./isar.s",
|
||||||
|
"./lar2.s",
|
||||||
|
"./lfr6.s",
|
||||||
|
"./lfr8.s",
|
||||||
|
"./loi.s",
|
||||||
|
"./mli4.s",
|
||||||
|
"./mli.s",
|
||||||
|
"./mon.s",
|
||||||
|
"./ngi.s",
|
||||||
|
"./nop.s",
|
||||||
|
"./print.s",
|
||||||
|
"./rck.s",
|
||||||
|
"./ret6.s",
|
||||||
|
"./ret8.s",
|
||||||
|
"./retarea.s",
|
||||||
|
"./return.s",
|
||||||
|
"./rmi4.s",
|
||||||
|
"./rmi.s",
|
||||||
|
"./rmu4.s",
|
||||||
|
"./rmu.s",
|
||||||
|
"./rol.s",
|
||||||
|
"./ror.s",
|
||||||
|
"./sar2.s",
|
||||||
|
"./sbi.s",
|
||||||
|
"./set.s",
|
||||||
|
"./sli.s",
|
||||||
|
"./sri.s",
|
||||||
|
"./sti.s",
|
||||||
|
"./strhp.s",
|
||||||
|
"./trp.s",
|
||||||
|
"./unknown.s",
|
||||||
|
"./xor.s",
|
||||||
|
},
|
||||||
vars = { plat = plat },
|
vars = { plat = plat },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
for _, plat in ipairs(vars.plats) do
|
for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = { "./*.s" },
|
srcs = {
|
||||||
|
"./edata.s",
|
||||||
|
"./em_end.s",
|
||||||
|
"./end.s",
|
||||||
|
"./etext.s",
|
||||||
|
},
|
||||||
vars = { plat = plat },
|
vars = { plat = plat },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
8
mach/i86/ncg/build.lua
Normal file
8
mach/i86/ncg/build.lua
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
bundle {
|
||||||
|
name = "headers",
|
||||||
|
srcs = {
|
||||||
|
"./mach.c",
|
||||||
|
"./mach.h"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
12
mach/m68020/as/build.lua
Normal file
12
mach/m68020/as/build.lua
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
bundle {
|
||||||
|
name = "headers",
|
||||||
|
srcs = {
|
||||||
|
"./mach0.c",
|
||||||
|
"./mach1.c",
|
||||||
|
"./mach2.c",
|
||||||
|
"./mach3.c",
|
||||||
|
"./mach4.c",
|
||||||
|
"./mach5.c",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -141,12 +141,12 @@ main(argc, argv)
|
||||||
}
|
}
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 1: break;
|
case 1: break;
|
||||||
case 3: if ((output = fopen(argv[2], "w")) == (FILE *)0)
|
case 3: if ((output = fopen(argv[2], "wb")) == (FILE *)0)
|
||||||
fatal("Can't write %s.\n", argv[2]);
|
fatal("Can't write %s.\n", argv[2]);
|
||||||
output_file = argv[2];
|
output_file = argv[2];
|
||||||
outputfile_created = 1;
|
outputfile_created = 1;
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case 2: if ((input = fopen(argv[1], "r")) == (FILE *)0)
|
case 2: if ((input = fopen(argv[1], "rb")) == (FILE *)0)
|
||||||
fatal("Can't read %s.\n", argv[1]);
|
fatal("Can't read %s.\n", argv[1]);
|
||||||
break;
|
break;
|
||||||
default:fatal("Usage: %s <as object> <dl object>.\n", argv[0]);
|
default:fatal("Usage: %s <as object> <dl object>.\n", argv[0]);
|
||||||
|
|
|
@ -2,8 +2,37 @@ for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = {
|
srcs = {
|
||||||
"./*.s", -- csb8.s
|
"./aar.s",
|
||||||
"./*.c"
|
"./cii.s",
|
||||||
|
"./cmi.s",
|
||||||
|
"./cms.s",
|
||||||
|
"./cmu.s",
|
||||||
|
"./csa8.s",
|
||||||
|
"./csa.s",
|
||||||
|
"./csb8.s",
|
||||||
|
"./csb.s",
|
||||||
|
"./cuu.s",
|
||||||
|
"./cvf.s",
|
||||||
|
"./dia.s",
|
||||||
|
"./divrem8.s",
|
||||||
|
"./dvi8.s",
|
||||||
|
"./dvu8.s",
|
||||||
|
"./exg.s",
|
||||||
|
"./fat.s",
|
||||||
|
"./fp68881.s",
|
||||||
|
"./inn.s",
|
||||||
|
"./lar.s",
|
||||||
|
"./los.s",
|
||||||
|
"./mon.s",
|
||||||
|
"./nop.s",
|
||||||
|
"./rmi8.s",
|
||||||
|
"./rmu8.s",
|
||||||
|
"./sar.s",
|
||||||
|
"./set.s",
|
||||||
|
"./shp.s",
|
||||||
|
"./sts.s",
|
||||||
|
"./trp.s",
|
||||||
|
"./trpstr.c",
|
||||||
},
|
},
|
||||||
vars = { plat = plat },
|
vars = { plat = plat },
|
||||||
deps = {
|
deps = {
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
for _, plat in ipairs(vars.plats) do
|
for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = { "./*.s" },
|
srcs = {
|
||||||
|
"./edata.s",
|
||||||
|
"./em_end.s",
|
||||||
|
"./end.s",
|
||||||
|
"./etext.s",
|
||||||
|
},
|
||||||
vars = { plat = plat },
|
vars = { plat = plat },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
9
mach/m68020/ncg/build.lua
Normal file
9
mach/m68020/ncg/build.lua
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
bundle {
|
||||||
|
name = "headers",
|
||||||
|
srcs = {
|
||||||
|
"./mach.c",
|
||||||
|
"./mach.h",
|
||||||
|
"./whichone.h"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -102,12 +102,12 @@ main(argc, argv)
|
||||||
}
|
}
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 1: break;
|
case 1: break;
|
||||||
case 3: if ((output = fopen(argv[2], "w")) == (FILE *)0)
|
case 3: if ((output = fopen(argv[2], "wb")) == (FILE *)0)
|
||||||
fatal("Can't write %s.\n", argv[2]);
|
fatal("Can't write %s.\n", argv[2]);
|
||||||
ofile = argv[2];
|
ofile = argv[2];
|
||||||
ofile_created = 1;
|
ofile_created = 1;
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case 2: if ((input = fopen(argv[1], "r")) == (FILE *)0)
|
case 2: if ((input = fopen(argv[1], "rb")) == (FILE *)0)
|
||||||
fatal("Can't read %s.\n", argv[1]);
|
fatal("Can't read %s.\n", argv[1]);
|
||||||
break;
|
break;
|
||||||
default:fatal("Usage: %s <as object> <dl object>.\n", argv[0]);
|
default:fatal("Usage: %s <as object> <dl object>.\n", argv[0]);
|
||||||
|
|
|
@ -38,12 +38,12 @@ main(argc, argv)
|
||||||
program= argv[0] ;
|
program= argv[0] ;
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 1: break;
|
case 1: break;
|
||||||
case 3: if ((output = fopen(argv[2], "w")) == (FILE *)0)
|
case 3: if ((output = fopen(argv[2], "wb")) == (FILE *)0)
|
||||||
fatal("Can't write %s.\n", argv[2]);
|
fatal("Can't write %s.\n", argv[2]);
|
||||||
output_file = argv[2];
|
output_file = argv[2];
|
||||||
output_file_created = 1;
|
output_file_created = 1;
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case 2: if ((input = fopen(argv[1], "r")) == (FILE *)0)
|
case 2: if ((input = fopen(argv[1], "rb")) == (FILE *)0)
|
||||||
fatal("Can't read %s.\n", argv[1]);
|
fatal("Can't read %s.\n", argv[1]);
|
||||||
break;
|
break;
|
||||||
default:fatal("Usage: %s <as object> <dl object>.\n", argv[0]);
|
default:fatal("Usage: %s <as object> <dl object>.\n", argv[0]);
|
||||||
|
|
|
@ -36,11 +36,11 @@ main(argc,argv) char **argv; {
|
||||||
fprintf(stderr,"Usage: %s VU-a.out Bleasdale-a.out\n",argv[0]);
|
fprintf(stderr,"Usage: %s VU-a.out Bleasdale-a.out\n",argv[0]);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
if (freopen(argv[1],"r",stdin)==NULL) {
|
if (freopen(argv[1],"rb",stdin)==NULL) {
|
||||||
perror(argv[1]);
|
perror(argv[1]);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
if (freopen(argv[2],"w",stdout)==NULL) {
|
if (freopen(argv[2],"wb",stdout)==NULL) {
|
||||||
perror(argv[2]);
|
perror(argv[2]);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ main(argc, argv)
|
||||||
case 3: if (! wr_open(argv[2]))
|
case 3: if (! wr_open(argv[2]))
|
||||||
fatal("Can't write %s.\n", argv[2]);
|
fatal("Can't write %s.\n", argv[2]);
|
||||||
output_file = argv[2];
|
output_file = argv[2];
|
||||||
if ((input = fopen(argv[1], "r")) == (FILE *)0)
|
if ((input = fopen(argv[1], "rb")) == (FILE *)0)
|
||||||
fatal("Can't read %s.\n", argv[1]);
|
fatal("Can't read %s.\n", argv[1]);
|
||||||
break;
|
break;
|
||||||
default:fatal("Usage: %s <Mantra object> <ACK object>.\n", argv[0]);
|
default:fatal("Usage: %s <Mantra object> <ACK object>.\n", argv[0]);
|
||||||
|
|
|
@ -107,7 +107,7 @@ main(argc, argv)
|
||||||
argc-- ; argv++ ;
|
argc-- ; argv++ ;
|
||||||
}
|
}
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 3: if ((output = fopen(argv[2], "w")) == (FILE *)0)
|
case 3: if ((output = fopen(argv[2], "wb")) == (FILE *)0)
|
||||||
fatal("Can't write %s.\n", argv[2]);
|
fatal("Can't write %s.\n", argv[2]);
|
||||||
output_file = argv[2];
|
output_file = argv[2];
|
||||||
outputfile_created = 1;
|
outputfile_created = 1;
|
||||||
|
|
|
@ -4,3 +4,16 @@ normalrule {
|
||||||
ins = {"./mktables.lua", "./instructions.dat"},
|
ins = {"./mktables.lua", "./instructions.dat"},
|
||||||
commands = {"$(LUA) %{ins[1]} %{outs} < %{ins[2]}"}
|
commands = {"$(LUA) %{ins[1]} %{outs} < %{ins[2]}"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bundle {
|
||||||
|
name = "headers",
|
||||||
|
srcs = {
|
||||||
|
"./mach0.c",
|
||||||
|
"./mach1.c",
|
||||||
|
"./mach2.c",
|
||||||
|
"./mach3.c",
|
||||||
|
"./mach4.c",
|
||||||
|
"./mach5.c",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,19 +139,19 @@ while true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local definitionsfp = io.open(args[1], "w")
|
local definitionsfp = io.open(args[1], "wb")
|
||||||
for word, value in pairs(words) do
|
for word, value in pairs(words) do
|
||||||
definitionsfp:write("%token <y_word> OP_", tostring(value), " /* ", word, " */\n")
|
definitionsfp:write("%token <y_word> OP_", tostring(value), " /* ", word, " */\n")
|
||||||
end
|
end
|
||||||
definitionsfp:close()
|
definitionsfp:close()
|
||||||
|
|
||||||
local tokensfp = io.open(args[2], "w")
|
local tokensfp = io.open(args[2], "wb")
|
||||||
for word, value in pairs(words) do
|
for word, value in pairs(words) do
|
||||||
tokensfp:write("0, OP_", value, ", 0, \"", word, "\",\n")
|
tokensfp:write("0, OP_", value, ", 0, \"", word, "\",\n")
|
||||||
end
|
end
|
||||||
tokensfp:close()
|
tokensfp:close()
|
||||||
|
|
||||||
local rulesfp = io.open(args[3], "w")
|
local rulesfp = io.open(args[3], "wb")
|
||||||
rulesfp:write("operation\n")
|
rulesfp:write("operation\n")
|
||||||
for index, insn in ipairs(insns) do
|
for index, insn in ipairs(insns) do
|
||||||
if index == 1 then
|
if index == 1 then
|
||||||
|
|
|
@ -6,7 +6,33 @@ for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = {
|
srcs = {
|
||||||
"./*.s", -- dus4.s
|
"./aar4.s",
|
||||||
|
"./and.s",
|
||||||
|
"./bls4.s",
|
||||||
|
"./cms.s",
|
||||||
|
"./compareul.s",
|
||||||
|
"./com.s",
|
||||||
|
"./csa.s",
|
||||||
|
"./csb.s",
|
||||||
|
"./c_ud_i.s",
|
||||||
|
"./c_uf_i.s",
|
||||||
|
"./c_ui_d.s",
|
||||||
|
"./c_ui_f.s",
|
||||||
|
"./dus4.s",
|
||||||
|
"./exg.s",
|
||||||
|
"./fef8.s",
|
||||||
|
"./fif8.s",
|
||||||
|
"./inn.s",
|
||||||
|
"./ior.s",
|
||||||
|
"./lar4.s",
|
||||||
|
"./los4.s",
|
||||||
|
"./rck.s",
|
||||||
|
"./sar4.s",
|
||||||
|
"./set.s",
|
||||||
|
"./sts4.s",
|
||||||
|
"./trp.s",
|
||||||
|
"./xor.s",
|
||||||
|
"./zer.s",
|
||||||
},
|
},
|
||||||
vars = { plat = plat },
|
vars = { plat = plat },
|
||||||
deps = {
|
deps = {
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
for _, plat in ipairs(vars.plats) do
|
for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = { "./*.s" },
|
srcs = {
|
||||||
|
"./edata.s",
|
||||||
|
"./em_end.s",
|
||||||
|
"./end.s",
|
||||||
|
"./etext.s",
|
||||||
|
},
|
||||||
vars = { plat = plat },
|
vars = { plat = plat },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
7
mach/mips/mcg/build.lua
Normal file
7
mach/mips/mcg/build.lua
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
bundle {
|
||||||
|
name = "headers",
|
||||||
|
srcs = {
|
||||||
|
"./platform.c",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
12
mach/pdp/as/build.lua
Normal file
12
mach/pdp/as/build.lua
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
bundle {
|
||||||
|
name = "headers",
|
||||||
|
srcs = {
|
||||||
|
"./mach0.c",
|
||||||
|
"./mach1.c",
|
||||||
|
"./mach2.c",
|
||||||
|
"./mach3.c",
|
||||||
|
"./mach4.c",
|
||||||
|
"./mach5.c",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
cprogram {
|
cprogram {
|
||||||
name = "cv",
|
name = "cv",
|
||||||
srcs = { "./*.c" },
|
srcs = { "./cv.c" },
|
||||||
deps = {
|
deps = {
|
||||||
"h+emheaders",
|
"h+emheaders",
|
||||||
"modules/src/object+lib",
|
"modules/src/object+lib",
|
||||||
|
|
|
@ -86,7 +86,7 @@ main(argc, argv)
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 1: rd_fdopen(0);
|
case 1: rd_fdopen(0);
|
||||||
break;
|
break;
|
||||||
case 3: if ((output = fopen(argv[2], "w")) == NULL) {
|
case 3: if ((output = fopen(argv[2], "wb")) == NULL) {
|
||||||
fatal("Can't write %s.\n", argv[2]);
|
fatal("Can't write %s.\n", argv[2]);
|
||||||
}
|
}
|
||||||
output_file = argv[2];
|
output_file = argv[2];
|
||||||
|
|
|
@ -1,7 +1,79 @@
|
||||||
for _, plat in ipairs(vars.plats) do
|
for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = { "./*.s" },
|
srcs = {
|
||||||
|
"./aar.s",
|
||||||
|
"./adf.s",
|
||||||
|
"./adi.s",
|
||||||
|
"./and.s",
|
||||||
|
"./cff.s",
|
||||||
|
"./cfi.s",
|
||||||
|
"./cif.s",
|
||||||
|
"./cii.s",
|
||||||
|
"./ciu.s",
|
||||||
|
"./cmf.s",
|
||||||
|
"./cmi4.s",
|
||||||
|
"./cmi.s",
|
||||||
|
"./cms.s",
|
||||||
|
"./cmu4.s",
|
||||||
|
"./cmu.s",
|
||||||
|
"./csa.s",
|
||||||
|
"./csb.s",
|
||||||
|
"./dup.s",
|
||||||
|
"./dvf.s",
|
||||||
|
"./dvi4.s",
|
||||||
|
"./dvi.s",
|
||||||
|
"./dvu2.s",
|
||||||
|
"./dvu4.s",
|
||||||
|
"./dvu.s",
|
||||||
|
"./eret.s",
|
||||||
|
"./exg.s",
|
||||||
|
"./fef.s",
|
||||||
|
"./fif.s",
|
||||||
|
"./gto.s",
|
||||||
|
"./iaar.s",
|
||||||
|
"./ilar.s",
|
||||||
|
"./inn.s",
|
||||||
|
"./isar.s",
|
||||||
|
"./lar.s",
|
||||||
|
"./los2.s",
|
||||||
|
"./mlf.s",
|
||||||
|
"./mli4.s",
|
||||||
|
"./mli.s",
|
||||||
|
"./mlu4.s",
|
||||||
|
"./mlu.s",
|
||||||
|
"./mon.s",
|
||||||
|
"./ngf.s",
|
||||||
|
"./ngi.s",
|
||||||
|
"./nop.s",
|
||||||
|
"./prf.s",
|
||||||
|
"./printf.s",
|
||||||
|
"./rck.s",
|
||||||
|
"./ret.s",
|
||||||
|
"./rmi4.s",
|
||||||
|
"./rmi.s",
|
||||||
|
"./rmu2.s",
|
||||||
|
"./rmu4.s",
|
||||||
|
"./rmu.s",
|
||||||
|
"./rol.s",
|
||||||
|
"./ror.s",
|
||||||
|
"./RT.s",
|
||||||
|
"./sar.s",
|
||||||
|
"./save.s",
|
||||||
|
"./sbf.s",
|
||||||
|
"./sbi.s",
|
||||||
|
"./setfl.s",
|
||||||
|
"./set.s",
|
||||||
|
"./sim.s",
|
||||||
|
"./sli.s",
|
||||||
|
"./sri.s",
|
||||||
|
"./sru.s",
|
||||||
|
"./sto2.s",
|
||||||
|
"./strhp.s",
|
||||||
|
"./trp.s",
|
||||||
|
"./unknown.s",
|
||||||
|
"./xor.s",
|
||||||
|
},
|
||||||
vars = { plat = plat },
|
vars = { plat = plat },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
for _, plat in ipairs(vars.plats) do
|
for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = { "./*.s" },
|
srcs = {
|
||||||
|
"./edata.s",
|
||||||
|
"./em_end.s",
|
||||||
|
"./end.s",
|
||||||
|
"./etext.s",
|
||||||
|
},
|
||||||
vars = { plat = plat },
|
vars = { plat = plat },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -88,7 +88,7 @@ main(argc, argv)
|
||||||
argc-- ; argv++ ;
|
argc-- ; argv++ ;
|
||||||
}
|
}
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 3: if ((output = fopen(argv[2], "w")) == (FILE *)0)
|
case 3: if ((output = fopen(argv[2], "wb")) == (FILE *)0)
|
||||||
fatal("Can't write %s.\n", argv[2]);
|
fatal("Can't write %s.\n", argv[2]);
|
||||||
output_file = argv[2];
|
output_file = argv[2];
|
||||||
outputfile_created = 1;
|
outputfile_created = 1;
|
||||||
|
|
12
mach/powerpc/as/build.lua
Normal file
12
mach/powerpc/as/build.lua
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
bundle {
|
||||||
|
name = "headers",
|
||||||
|
srcs = {
|
||||||
|
"./mach0.c",
|
||||||
|
"./mach1.c",
|
||||||
|
"./mach2.c",
|
||||||
|
"./mach3.c",
|
||||||
|
"./mach4.c",
|
||||||
|
"./mach5.c",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -6,7 +6,35 @@ for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = {
|
srcs = {
|
||||||
"./*.s", -- dus4.s
|
"./aar4.s",
|
||||||
|
"./and.s",
|
||||||
|
"./bls4.s",
|
||||||
|
"./cfi8.s",
|
||||||
|
"./cfu8.s",
|
||||||
|
"./cif8.s",
|
||||||
|
"./cms.s",
|
||||||
|
"./com.s",
|
||||||
|
"./csa.s",
|
||||||
|
"./csb.s",
|
||||||
|
"./cuf8.s",
|
||||||
|
-- "./dus4.s",
|
||||||
|
"./exg.s",
|
||||||
|
"./fd_00000000.s",
|
||||||
|
"./fef4.s",
|
||||||
|
"./fef8.s",
|
||||||
|
"./fif4.s",
|
||||||
|
"./fif8.s",
|
||||||
|
"./inn.s",
|
||||||
|
"./ior.s",
|
||||||
|
"./lar4.s",
|
||||||
|
"./los4.s",
|
||||||
|
"./rck.s",
|
||||||
|
"./sar4.s",
|
||||||
|
"./set.s",
|
||||||
|
"./sts4.s",
|
||||||
|
"./trp.s",
|
||||||
|
"./xor.s",
|
||||||
|
"./zer.s",
|
||||||
},
|
},
|
||||||
vars = { plat = plat },
|
vars = { plat = plat },
|
||||||
deps = {
|
deps = {
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
for _, plat in ipairs(vars.plats) do
|
for _, plat in ipairs(vars.plats) do
|
||||||
acklibrary {
|
acklibrary {
|
||||||
name = "lib_"..plat,
|
name = "lib_"..plat,
|
||||||
srcs = { "./*.s" },
|
srcs = {
|
||||||
|
"./edata.s",
|
||||||
|
"./em_end.s",
|
||||||
|
"./end.s",
|
||||||
|
"./etext.s",
|
||||||
|
},
|
||||||
vars = { plat = plat },
|
vars = { plat = plat },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue