commit
						33ce9169b4
					
				
					 340 changed files with 7739 additions and 34687 deletions
				
			
		| 
						 | 
				
			
			@ -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
 | 
			
		||||
AllowShortFunctionsOnASingleLine: 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:
 | 
			
		||||
    - uses: actions/checkout@v3
 | 
			
		||||
    - 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
 | 
			
		||||
      run: make LUA=lua
 | 
			
		||||
      run: make
 | 
			
		||||
 | 
			
		||||
  build-macos:
 | 
			
		||||
    runs-on: macos-latest
 | 
			
		||||
    steps:
 | 
			
		||||
    - uses: actions/checkout@v3
 | 
			
		||||
    - name: brew
 | 
			
		||||
      run: brew install ninja lua@5.1 luarocks
 | 
			
		||||
    - name: luarocks
 | 
			
		||||
      run: |
 | 
			
		||||
        luarocks install --lua-version 5.1 luaposix 33.0.0-1
 | 
			
		||||
      run: brew install ninja lua@5.4
 | 
			
		||||
    - name: make
 | 
			
		||||
      run: |
 | 
			
		||||
        eval $(luarocks --lua-version 5.1 path)
 | 
			
		||||
        make LUA=/usr/local/bin/lua5.1
 | 
			
		||||
        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-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))
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
$(build-file): first/ackbuilder.lua Makefile
 | 
			
		||||
$(build-file): first/ackbuilder.lua Makefile $(lua-files)
 | 
			
		||||
	@mkdir -p $(BUILDDIR)
 | 
			
		||||
	@$(LUA) first/ackbuilder.lua \
 | 
			
		||||
		first/build.lua build.lua \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								README
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								README
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -2,7 +2,7 @@
 | 
			
		|||
                     ===================================
 | 
			
		||||
 | 
			
		||||
                  © 1987-2005 Vrije Universiteit, Amsterdam
 | 
			
		||||
                                2018-02-23
 | 
			
		||||
                                2022-06-18
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
INTRODUCTION
 | 
			
		||||
| 
						 | 
				
			
			@ -45,7 +45,8 @@ 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:
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										46
									
								
								build.lua
									
										
									
									
									
								
							
							
						
						
									
										46
									
								
								build.lua
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -28,6 +28,13 @@ vars.plats_with_tests = {
 | 
			
		|||
	"pc86",
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local is_windows = os.getenv("OS") == "Windows_NT"
 | 
			
		||||
 | 
			
		||||
local int = {}
 | 
			
		||||
if not is_windows then
 | 
			
		||||
	int[#int+1] = "util/int+pkg"
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
installable {
 | 
			
		||||
	name = "ack-common",
 | 
			
		||||
	map = {
 | 
			
		||||
| 
						 | 
				
			
			@ -41,10 +48,10 @@ installable {
 | 
			
		|||
		"util/arch+pkg",
 | 
			
		||||
		"util/ass+pkg",
 | 
			
		||||
		"util/ego+pkg",
 | 
			
		||||
		"util/int+pkg",
 | 
			
		||||
		"util/led+pkg",
 | 
			
		||||
		"util/misc+pkg",
 | 
			
		||||
		"util/opt+pkg",
 | 
			
		||||
		int
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -75,16 +82,29 @@ installable {
 | 
			
		|||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
normalrule {
 | 
			
		||||
	name = "tests",
 | 
			
		||||
	ins = {
 | 
			
		||||
		"first/testsummary.sh",
 | 
			
		||||
		test_packages
 | 
			
		||||
	},
 | 
			
		||||
	outleaves = {
 | 
			
		||||
		"stamp"
 | 
			
		||||
	},
 | 
			
		||||
	commands = {
 | 
			
		||||
		"%{ins}"
 | 
			
		||||
if not is_windows then
 | 
			
		||||
	normalrule {
 | 
			
		||||
		name = "tests",
 | 
			
		||||
		ins = {
 | 
			
		||||
			"first/testsummary.sh",
 | 
			
		||||
			test_packages
 | 
			
		||||
		},
 | 
			
		||||
		outleaves = {
 | 
			
		||||
			"stamp"
 | 
			
		||||
		},
 | 
			
		||||
		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 }
 | 
			
		||||
-- }
 | 
			
		||||
 | 
			
		||||
local posix = require("posix")
 | 
			
		||||
local emitter = {}
 | 
			
		||||
local rules = {}
 | 
			
		||||
local targets = {}
 | 
			
		||||
| 
						 | 
				
			
			@ -21,6 +20,24 @@ local loadingstack = {}
 | 
			
		|||
-- Forward references
 | 
			
		||||
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_no_nl(list)
 | 
			
		||||
		for _, s in ipairs(list) do
 | 
			
		||||
| 
						 | 
				
			
			@ -125,7 +142,7 @@ local function concatpath(...)
 | 
			
		|||
end
 | 
			
		||||
 | 
			
		||||
-- 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 o = {}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -226,9 +243,6 @@ local function abspath(...)
 | 
			
		|||
	return dotocollection({...},
 | 
			
		||||
		function(filename)
 | 
			
		||||
			assertString(filename, 1)
 | 
			
		||||
			if not filename:find("^[/$]") then
 | 
			
		||||
				filename = concatpath(posix.getcwd(), filename)
 | 
			
		||||
			end
 | 
			
		||||
			return filename
 | 
			
		||||
		end
 | 
			
		||||
	)
 | 
			
		||||
| 
						 | 
				
			
			@ -345,11 +359,10 @@ local function templateexpand(list, vars)
 | 
			
		|||
		o[#o+1] = s:gsub("%%%b{}",
 | 
			
		||||
			function(expr)
 | 
			
		||||
				expr = expr:sub(3, -2)
 | 
			
		||||
				local chunk, e = loadstring("return ("..expr..")", expr)
 | 
			
		||||
				local chunk, e = loadf("return ("..expr..")", expr, nil, vars)
 | 
			
		||||
				if e then
 | 
			
		||||
					error(string.format("error evaluating expression: %s", e))
 | 
			
		||||
				end
 | 
			
		||||
				setfenv(chunk, vars)
 | 
			
		||||
				local value = chunk()
 | 
			
		||||
				if (value == nil) then
 | 
			
		||||
					error(string.format("template expression '%s' expands to nil (probably an undefined variable)", expr))
 | 
			
		||||
| 
						 | 
				
			
			@ -381,10 +394,7 @@ local function loadbuildfile(filename)
 | 
			
		|||
				local thisglobals = {}
 | 
			
		||||
				thisglobals._G = thisglobals
 | 
			
		||||
				setmetatable(thisglobals, {__index = globals})
 | 
			
		||||
				chunk, e = loadstring(data, "@"..filename)
 | 
			
		||||
				if not e then
 | 
			
		||||
					setfenv(chunk, thisglobals)
 | 
			
		||||
				end
 | 
			
		||||
				chunk, e = loadf(data, filename, nil, thisglobals)
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
		if e then
 | 
			
		||||
| 
						 | 
				
			
			@ -401,13 +411,17 @@ end
 | 
			
		|||
 | 
			
		||||
local function loadbuildfilefor(filepart, targetpart)
 | 
			
		||||
	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)
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	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)
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
| 
						 | 
				
			
			@ -424,10 +438,7 @@ loadtarget = function(targetname)
 | 
			
		|||
	if not targetname:find("%+") then
 | 
			
		||||
		local files
 | 
			
		||||
		if targetname:find("[?*]") then
 | 
			
		||||
			files = posix.glob(targetname)
 | 
			
		||||
			if not files then
 | 
			
		||||
				files = {}
 | 
			
		||||
			end
 | 
			
		||||
			error("wildcards not supported")
 | 
			
		||||
		else
 | 
			
		||||
			files = {targetname}
 | 
			
		||||
		end
 | 
			
		||||
| 
						 | 
				
			
			@ -823,8 +834,6 @@ local function parse_arguments(argmap, arg)
 | 
			
		|||
end
 | 
			
		||||
 | 
			
		||||
globals = {
 | 
			
		||||
	posix = posix,
 | 
			
		||||
 | 
			
		||||
	abspath = abspath,
 | 
			
		||||
	asstring = asstring,
 | 
			
		||||
	basename = basename,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,10 @@
 | 
			
		|||
definerule("yacc",
 | 
			
		||||
definerule("bison",
 | 
			
		||||
	{
 | 
			
		||||
		srcs = { type="targets" },
 | 
			
		||||
		commands = {
 | 
			
		||||
			type="strings",
 | 
			
		||||
			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 {
 | 
			
		||||
	name = "emheaders",
 | 
			
		||||
	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",
 | 
			
		||||
		"+em_path",
 | 
			
		||||
		"+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);
 | 
			
		||||
	if (pass1) {
 | 
			
		||||
		if (useroif) {
 | 
			
		||||
			if ((hashin = fopen(oifile, "r")) == NULL)
 | 
			
		||||
			if ((hashin = fopen(oifile, "rb")) == NULL)
 | 
			
		||||
				fatal("bad ignore/only file: %s",oifile);
 | 
			
		||||
			buildhash();
 | 
			
		||||
			fclose(hashin);
 | 
			
		||||
		}
 | 
			
		||||
		input = stdin;
 | 
			
		||||
		output = fdopen(scanout[1], "w");
 | 
			
		||||
		output = fdopen(scanout[1], "wb");
 | 
			
		||||
		nfiles = argc;
 | 
			
		||||
		setjmp(env);
 | 
			
		||||
		while (argc--)
 | 
			
		||||
| 
						 | 
				
			
			@ -203,9 +203,9 @@ scan(s) char *s;
 | 
			
		|||
				oifsuf++;
 | 
			
		||||
		if (lastc != oifile[oifsuf] ) {
 | 
			
		||||
			oifile[oifsuf] = lastc;
 | 
			
		||||
			if ((hashin = fopen(oifile, "r")) == NULL) {
 | 
			
		||||
			if ((hashin = fopen(oifile, "rb")) == NULL) {
 | 
			
		||||
				oifile[oifsuf] = 'x';
 | 
			
		||||
				if ((hashin = fopen(oifile, "r")) == NULL)
 | 
			
		||||
				if ((hashin = fopen(oifile, "rb")) == NULL)
 | 
			
		||||
					fatal("cannot open %s",oifile);
 | 
			
		||||
			}
 | 
			
		||||
			buildhash();
 | 
			
		||||
| 
						 | 
				
			
			@ -215,7 +215,7 @@ scan(s) char *s;
 | 
			
		|||
	if (s[0]=='-' && s[1]=='\0')
 | 
			
		||||
		input = stdin;
 | 
			
		||||
	else
 | 
			
		||||
		if ((input = fopen(s, "r")) == NULL)
 | 
			
		||||
		if ((input = fopen(s, "rb")) == NULL)
 | 
			
		||||
			fatal("cannot open %s",s);
 | 
			
		||||
	switch (type) {
 | 
			
		||||
	case 'x': 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,7 +45,7 @@ extern const char* modulename;
 | 
			
		|||
extern int paramsize;
 | 
			
		||||
extern struct	hshtab hshtab[HSHSIZ];
 | 
			
		||||
extern int	hshused;
 | 
			
		||||
extern int	eof;
 | 
			
		||||
extern int	ateof;
 | 
			
		||||
extern int	peekc;
 | 
			
		||||
extern const char* ctab;
 | 
			
		||||
extern struct	hshtab *bsym;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,7 @@ int string_part;
 | 
			
		|||
int paramsize;
 | 
			
		||||
struct	hshtab hshtab[HSHSIZ];
 | 
			
		||||
int	hshused;
 | 
			
		||||
int	eof;
 | 
			
		||||
int	ateof;
 | 
			
		||||
int	peekc;
 | 
			
		||||
const char* ctab;
 | 
			
		||||
struct	hshtab *bsym;
 | 
			
		||||
| 
						 | 
				
			
			@ -129,7 +129,7 @@ main(int argc, char *argv[])
 | 
			
		|||
	string_part = 0;
 | 
			
		||||
	code_part = C_getid();
 | 
			
		||||
	C_beginpart(code_part);
 | 
			
		||||
	while (!eof) {
 | 
			
		||||
	while (!ateof) {
 | 
			
		||||
		extdef();
 | 
			
		||||
		blkend();
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -368,12 +368,12 @@ symbol(void)
 | 
			
		|||
		c = peekc;
 | 
			
		||||
		peekc = 0;
 | 
			
		||||
	} else
 | 
			
		||||
		if (eof)
 | 
			
		||||
		if (ateof)
 | 
			
		||||
			return EOFC;
 | 
			
		||||
		else
 | 
			
		||||
			c = getchar();
 | 
			
		||||
	if (c==EOF) {
 | 
			
		||||
		eof++;
 | 
			
		||||
		ateof++;
 | 
			
		||||
		return(EOFC);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -453,7 +453,7 @@ loop:
 | 
			
		|||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		eof++;
 | 
			
		||||
		ateof++;
 | 
			
		||||
		error("Nonterminated comment");
 | 
			
		||||
		return EOFC;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -820,7 +820,7 @@ stmt:
 | 
			
		|||
	if ((o = symbol()) == LBRACE) {
 | 
			
		||||
		if (d)
 | 
			
		||||
			blkhed();
 | 
			
		||||
		while (!eof) {
 | 
			
		||||
		while (!ateof) {
 | 
			
		||||
			if ((o = symbol()) == RBRACE)
 | 
			
		||||
				goto bend;
 | 
			
		||||
			pushsym(o);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,10 +2,11 @@
 | 
			
		|||
cprogram {
 | 
			
		||||
	name = "em_b",
 | 
			
		||||
	srcs = {
 | 
			
		||||
		"./*.c",
 | 
			
		||||
		"./b0.c",
 | 
			
		||||
		"./b1.c",
 | 
			
		||||
	},
 | 
			
		||||
	deps = {
 | 
			
		||||
		"./*.h",
 | 
			
		||||
		"./b.h",
 | 
			
		||||
		"modules+headers",
 | 
			
		||||
		"modules/src/alloc+lib",
 | 
			
		||||
		"modules/src/data+lib",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,12 +4,12 @@ for _, plat in ipairs(vars.plats) do
 | 
			
		|||
    acklibrary {
 | 
			
		||||
        name = "lib_"..plat,
 | 
			
		||||
        srcs = {
 | 
			
		||||
			"./*.c",
 | 
			
		||||
			"./*.e",
 | 
			
		||||
			"./init.c",
 | 
			
		||||
			"./main.c",
 | 
			
		||||
        },
 | 
			
		||||
		hdrs = {}, -- must be empty
 | 
			
		||||
		deps = {
 | 
			
		||||
			"./*.h",
 | 
			
		||||
			"./b.h",
 | 
			
		||||
			"h+emheaders",
 | 
			
		||||
			"lang/cem/libcc.ansi/headers+pkg",
 | 
			
		||||
			"plat/"..plat.."/include+pkg",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,15 +4,47 @@ for _, plat in ipairs(vars.plats) do
 | 
			
		|||
    acklibrary {
 | 
			
		||||
        name = "lib_"..plat,
 | 
			
		||||
        srcs = {
 | 
			
		||||
			"./*.c",
 | 
			
		||||
			"./*.e",
 | 
			
		||||
			"./abs.c",
 | 
			
		||||
			"./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
 | 
			
		||||
		deps = {
 | 
			
		||||
			"h+emheaders",
 | 
			
		||||
			"lang/cem/libcc.ansi/headers+pkg",
 | 
			
		||||
			"plat/"..plat.."/include+pkg",
 | 
			
		||||
			"./*.h",
 | 
			
		||||
			"./bc_io.h",
 | 
			
		||||
			"./lib.h",
 | 
			
		||||
		},
 | 
			
		||||
        vars = { plat = plat }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -76,19 +76,19 @@ void _opnchn(int reclen, String* fname, String* mode)
 | 
			
		|||
	{
 | 
			
		||||
		case 'O':
 | 
			
		||||
		case 'o':
 | 
			
		||||
			if ((f = fopen(fname->strval, "w")) == NULL)
 | 
			
		||||
			if ((f = fopen(fname->strval, "wb")) == NULL)
 | 
			
		||||
				error(28);
 | 
			
		||||
			m = OMODE;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'I':
 | 
			
		||||
		case 'i':
 | 
			
		||||
			if ((f = fopen(fname->strval, "r")) == NULL)
 | 
			
		||||
			if ((f = fopen(fname->strval, "rb")) == NULL)
 | 
			
		||||
				error(28);
 | 
			
		||||
			m = IMODE;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'r':
 | 
			
		||||
		case 'R':
 | 
			
		||||
			if ((f = fopen(fname->strval, "a")) == NULL)
 | 
			
		||||
			if ((f = fopen(fname->strval, "ab")) == NULL)
 | 
			
		||||
				error(28);
 | 
			
		||||
			m = RMODE;
 | 
			
		||||
			break;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -572,6 +572,7 @@ int yylex(void)
 | 
			
		|||
		/* handle double operators */
 | 
			
		||||
		case ' ':
 | 
			
		||||
		case '\t':
 | 
			
		||||
		case '\r':
 | 
			
		||||
			cptr++;
 | 
			
		||||
			return(yylex());
 | 
			
		||||
		case '&':
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,30 +2,48 @@ include("util/LLgen/build.lua")
 | 
			
		|||
 | 
			
		||||
llgen {
 | 
			
		||||
	name = "llgen",
 | 
			
		||||
	srcs = { "./*.g" }
 | 
			
		||||
	srcs = { "./basic.g" }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
normalrule {
 | 
			
		||||
	name = "tokentab_h",
 | 
			
		||||
	ins = {
 | 
			
		||||
		"./maketokentab",
 | 
			
		||||
		"util/cmisc+ed",
 | 
			
		||||
		matching(filenamesof("+llgen"), "/Lpars.h$"),
 | 
			
		||||
	},
 | 
			
		||||
	outleaves = { "tokentab.h" },
 | 
			
		||||
	commands = {
 | 
			
		||||
		"%{ins} %{outs}"
 | 
			
		||||
		"%{ins[1]} < %{ins[2]} > %{outs}"
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cprogram {
 | 
			
		||||
	name = "em_bem",
 | 
			
		||||
	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$"),
 | 
			
		||||
	},
 | 
			
		||||
	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",
 | 
			
		||||
		"+tokentab_h",
 | 
			
		||||
		"h+emheaders",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,17 +1,6 @@
 | 
			
		|||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
$1 -s "${2:-Lpars.h}" > $3 <<'+'
 | 
			
		||||
1d
 | 
			
		||||
1,$s/# *define //
 | 
			
		||||
1,$s/ ...$//
 | 
			
		||||
1,$s/^/	"/
 | 
			
		||||
1,$-1s/$/",/
 | 
			
		||||
$s/$/"/
 | 
			
		||||
0a
 | 
			
		||||
char *tokentab[] = {
 | 
			
		||||
.
 | 
			
		||||
$a
 | 
			
		||||
};
 | 
			
		||||
.
 | 
			
		||||
1,$p
 | 
			
		||||
+
 | 
			
		||||
echo "char* tokentab[] = {"
 | 
			
		||||
awk '/^#define/ { print "\"" $2 "\"," }'
 | 
			
		||||
echo "};"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,135 +1,135 @@
 | 
			
		|||
!File: lint.h
 | 
			
		||||
/*#define	LINT		1	*//* if defined, 'lint' is produced	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: pathlength.h
 | 
			
		||||
#define PATHLENGTH	1024	/* max. length of path to file		*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: errout.h
 | 
			
		||||
#define	ERROUT		STDERR	/* file pointer for writing messages	*/
 | 
			
		||||
#define	ERR_SHADOW	5	/* a syntax error overshadows error messages
 | 
			
		||||
					until ERR_SHADOW symbols have been
 | 
			
		||||
					accepted without syntax error */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: idfsize.h
 | 
			
		||||
#define	IDFSIZE	64	/* maximum significant length of an identifier	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: numsize.h
 | 
			
		||||
#define	NUMSIZE	256	/* maximum length of a numeric constant		*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: nparams.h
 | 
			
		||||
#define	NPARAMS 32	/* maximum number of parameters 		*/
 | 
			
		||||
#define	STDC_NPARAMS 31	/* ANSI limit on number of parameters		*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: ifdepth.h
 | 
			
		||||
#define	IFDEPTH	256	/* maximum number of nested if-constructions	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: density.h
 | 
			
		||||
#define	DENSITY	3	/* see switch.[ch] for an explanation		*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: macbuf.h
 | 
			
		||||
#define	LAPBUF	128	/* initial size of macro replacement buffer	*/
 | 
			
		||||
#define ARGBUF	128	/* initial size of macro parameter buffer(s)	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: strsize.h
 | 
			
		||||
#define ISTRSIZE	32	/* minimum number of bytes allocated for
 | 
			
		||||
					storing a string		*/
 | 
			
		||||
#define RSTRSIZE	16	/* step size in enlarging the memory for
 | 
			
		||||
					the storage of a string		*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: trgt_sizes.h
 | 
			
		||||
#define MAXSIZE		8	/* the maximum of the SZ_* constants	*/
 | 
			
		||||
 | 
			
		||||
/* target machine sizes	*/
 | 
			
		||||
#define	SZ_CHAR		1
 | 
			
		||||
#define	SZ_SHORT	2
 | 
			
		||||
#define SZ_WORD		4
 | 
			
		||||
#define	SZ_INT		4
 | 
			
		||||
#define	SZ_LONG		4
 | 
			
		||||
#define	SZ_LNGLNG	-1
 | 
			
		||||
#define	SZ_FLOAT	4
 | 
			
		||||
#define	SZ_DOUBLE	8
 | 
			
		||||
#define	SZ_LNGDBL	8	/* for now */
 | 
			
		||||
#define	SZ_POINTER	4
 | 
			
		||||
 | 
			
		||||
/* target machine alignment requirements	*/
 | 
			
		||||
#define	AL_CHAR		1
 | 
			
		||||
#define	AL_SHORT	SZ_SHORT
 | 
			
		||||
#define AL_WORD		SZ_WORD
 | 
			
		||||
#define	AL_INT		SZ_WORD
 | 
			
		||||
#define	AL_LONG		SZ_WORD
 | 
			
		||||
#define	AL_LNGLNG	SZ_WORD
 | 
			
		||||
#define	AL_FLOAT	SZ_WORD
 | 
			
		||||
#define	AL_DOUBLE	SZ_WORD
 | 
			
		||||
#define	AL_LNGDBL	SZ_WORD
 | 
			
		||||
#define	AL_POINTER	SZ_WORD
 | 
			
		||||
#define AL_STRUCT	1
 | 
			
		||||
#define AL_UNION	1
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: botch_free.h
 | 
			
		||||
/*#define BOTCH_FREE	1*	*//* when defined, botch freed memory, as a check	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: dataflow.h
 | 
			
		||||
#define DATAFLOW	1	/* produce some compile-time xref	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: debug.h
 | 
			
		||||
/*#define DEBUG		1	*//* perform various self-tests		*/
 | 
			
		||||
#define NDEBUG		1	/* disable assertions			*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: use_tmp.h
 | 
			
		||||
#define PREPEND_SCOPES	1	/* collect exa, exp, ina and inp commands
 | 
			
		||||
					and if USE_TMP is defined let them
 | 
			
		||||
					precede the rest of the generated
 | 
			
		||||
					compact code	*/
 | 
			
		||||
#define USE_TMP		1	/* use C_insertpart, C_endpart mechanism
 | 
			
		||||
					to generate EM-code in the order needed
 | 
			
		||||
					for the code-generators. If not defined,
 | 
			
		||||
					the old-style peephole optimizer is
 | 
			
		||||
					needed.	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: parbufsize.h
 | 
			
		||||
#define PARBUFSIZE	1024
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: textsize.h
 | 
			
		||||
#define ITEXTSIZE	32	/* 1st piece of memory for repl. text	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: inputtype.h
 | 
			
		||||
#define INP_READ_IN_ONE	1	/* read input file in one	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: nobitfield.h
 | 
			
		||||
/*#define NOBITFIELD	1	*//* if NOT defined, implement bitfields	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: static.h
 | 
			
		||||
#define GSTATIC			/* for large global "static" arrays */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: nocross.h
 | 
			
		||||
/*#define NOCROSS		1	*//* if NOT defined, cross compiler */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: regcount.h
 | 
			
		||||
/*#define REGCOUNT		1	*//* count occurrences for register messages */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: dbsymtab.h
 | 
			
		||||
#define DBSYMTAB	1	/* ability to produce symbol table for debugger */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: lint.h
 | 
			
		||||
/*#define	LINT		1	*//* if defined, 'lint' is produced	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: pathlength.h
 | 
			
		||||
#define PATHLENGTH	1024	/* max. length of path to file		*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: errout.h
 | 
			
		||||
#define	ERROUT		STDERR	/* file pointer for writing messages	*/
 | 
			
		||||
#define	ERR_SHADOW	5	/* a syntax error overshadows error messages
 | 
			
		||||
					until ERR_SHADOW symbols have been
 | 
			
		||||
					accepted without syntax error */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: idfsize.h
 | 
			
		||||
#define	IDFSIZE	64	/* maximum significant length of an identifier	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: numsize.h
 | 
			
		||||
#define	NUMSIZE	256	/* maximum length of a numeric constant		*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: nparams.h
 | 
			
		||||
#define	NPARAMS 32	/* maximum number of parameters 		*/
 | 
			
		||||
#define	STDC_NPARAMS 31	/* ANSI limit on number of parameters		*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: ifdepth.h
 | 
			
		||||
#define	IFDEPTH	256	/* maximum number of nested if-constructions	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: density.h
 | 
			
		||||
#define	DENSITY	3	/* see switch.[ch] for an explanation		*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: macbuf.h
 | 
			
		||||
#define	LAPBUF	128	/* initial size of macro replacement buffer	*/
 | 
			
		||||
#define ARGBUF	128	/* initial size of macro parameter buffer(s)	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: strsize.h
 | 
			
		||||
#define ISTRSIZE	32	/* minimum number of bytes allocated for
 | 
			
		||||
					storing a string		*/
 | 
			
		||||
#define RSTRSIZE	16	/* step size in enlarging the memory for
 | 
			
		||||
					the storage of a string		*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: trgt_sizes.h
 | 
			
		||||
#define MAXSIZE		8	/* the maximum of the SZ_* constants	*/
 | 
			
		||||
 | 
			
		||||
/* target machine sizes	*/
 | 
			
		||||
#define	SZ_CHAR		1
 | 
			
		||||
#define	SZ_SHORT	2
 | 
			
		||||
#define SZ_WORD		4
 | 
			
		||||
#define	SZ_INT		4
 | 
			
		||||
#define	SZ_LONG		4
 | 
			
		||||
#define	SZ_LNGLNG	-1
 | 
			
		||||
#define	SZ_FLOAT	4
 | 
			
		||||
#define	SZ_DOUBLE	8
 | 
			
		||||
#define	SZ_LNGDBL	8	/* for now */
 | 
			
		||||
#define	SZ_POINTER	4
 | 
			
		||||
 | 
			
		||||
/* target machine alignment requirements	*/
 | 
			
		||||
#define	AL_CHAR		1
 | 
			
		||||
#define	AL_SHORT	SZ_SHORT
 | 
			
		||||
#define AL_WORD		SZ_WORD
 | 
			
		||||
#define	AL_INT		SZ_WORD
 | 
			
		||||
#define	AL_LONG		SZ_WORD
 | 
			
		||||
#define	AL_LNGLNG	SZ_WORD
 | 
			
		||||
#define	AL_FLOAT	SZ_WORD
 | 
			
		||||
#define	AL_DOUBLE	SZ_WORD
 | 
			
		||||
#define	AL_LNGDBL	SZ_WORD
 | 
			
		||||
#define	AL_POINTER	SZ_WORD
 | 
			
		||||
#define AL_STRUCT	1
 | 
			
		||||
#define AL_UNION	1
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: botch_free.h
 | 
			
		||||
/*#define BOTCH_FREE	1*	*//* when defined, botch freed memory, as a check	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: dataflow.h
 | 
			
		||||
#define DATAFLOW	1	/* produce some compile-time xref	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: debug.h
 | 
			
		||||
/*#define DEBUG		1	*//* perform various self-tests		*/
 | 
			
		||||
#define NDEBUG		1	/* disable assertions			*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: use_tmp.h
 | 
			
		||||
#define PREPEND_SCOPES	1	/* collect exa, exp, ina and inp commands
 | 
			
		||||
					and if USE_TMP is defined let them
 | 
			
		||||
					precede the rest of the generated
 | 
			
		||||
					compact code	*/
 | 
			
		||||
#define USE_TMP		1	/* use C_insertpart, C_endpart mechanism
 | 
			
		||||
					to generate EM-code in the order needed
 | 
			
		||||
					for the code-generators. If not defined,
 | 
			
		||||
					the old-style peephole optimizer is
 | 
			
		||||
					needed.	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: parbufsize.h
 | 
			
		||||
#define PARBUFSIZE	1024
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: textsize.h
 | 
			
		||||
#define ITEXTSIZE	32	/* 1st piece of memory for repl. text	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: inputtype.h
 | 
			
		||||
#define INP_READ_IN_ONE	1	/* read input file in one	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: nobitfield.h
 | 
			
		||||
/*#define NOBITFIELD	1	*//* if NOT defined, implement bitfields	*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: static.h
 | 
			
		||||
#define GSTATIC			/* for large global "static" arrays */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: nocross.h
 | 
			
		||||
/*#define NOCROSS		1	*//* if NOT defined, cross compiler */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: regcount.h
 | 
			
		||||
/*#define REGCOUNT		1	*//* count occurrences for register messages */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!File: dbsymtab.h
 | 
			
		||||
#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 = {}
 | 
			
		||||
 | 
			
		||||
for _, f in ipairs(str_files) do
 | 
			
		||||
	local bf = f:gsub("%.str$", "")
 | 
			
		||||
for _, f in ipairs(str_bases) do
 | 
			
		||||
	local bf = f:gsub("%.str$", ""):gsub("^$./", "")
 | 
			
		||||
	str_targets[#str_targets+1] = normalrule {
 | 
			
		||||
		name = "allocd_header/"..bf,
 | 
			
		||||
		ins = { "./make.allocd", "./"..f },
 | 
			
		||||
| 
						 | 
				
			
			@ -32,7 +55,7 @@ normalrule {
 | 
			
		|||
	name = "next-c",
 | 
			
		||||
	ins = {
 | 
			
		||||
		"./make.next",
 | 
			
		||||
		"./*.str",
 | 
			
		||||
		str_files
 | 
			
		||||
	},
 | 
			
		||||
	outleaves = { "next.c" },
 | 
			
		||||
	commands = {
 | 
			
		||||
| 
						 | 
				
			
			@ -78,7 +101,11 @@ llgen {
 | 
			
		|||
	name = "llgen",
 | 
			
		||||
	srcs = {
 | 
			
		||||
		"+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.
 | 
			
		||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
			
		||||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
/*	EXPRESSION SYNTAX PARSER	*/
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
#include	<alloc.h>
 | 
			
		||||
#include	"parameters.h"
 | 
			
		||||
#include	<flt_arith.h>
 | 
			
		||||
#include	"arith.h"
 | 
			
		||||
#include	"LLlex.h"
 | 
			
		||||
#include	"type.h"
 | 
			
		||||
#include	"label.h"
 | 
			
		||||
#include	"expr.h"
 | 
			
		||||
#include	"code.h"
 | 
			
		||||
#include    "error.h"
 | 
			
		||||
#include    "ch3.h"
 | 
			
		||||
#include    "ch3bin.h"
 | 
			
		||||
#include    "ch3mon.h"
 | 
			
		||||
#include    "proto.h"
 | 
			
		||||
#include	"sizes.h"
 | 
			
		||||
 | 
			
		||||
extern struct expr *intexpr();
 | 
			
		||||
int InSizeof = 0;	/* inside a sizeof- expression */
 | 
			
		||||
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
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Such is life.
 | 
			
		||||
 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* 3.3.1 */
 | 
			
		||||
primary(register struct expr **expp;) :
 | 
			
		||||
	IDENTIFIER
 | 
			
		||||
	{dot2expr(expp);}
 | 
			
		||||
|
 | 
			
		||||
	constant(expp)
 | 
			
		||||
|
 | 
			
		||||
	string(expp)
 | 
			
		||||
|
 | 
			
		||||
	'(' expression(expp) ')'
 | 
			
		||||
	{ (*expp)->ex_flags |= EX_PARENS; }
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Character string literals that are adjacent tokens
 | 
			
		||||
 * are concatenated into a single character string
 | 
			
		||||
 * literal.
 | 
			
		||||
 */
 | 
			
		||||
string(register struct expr **expp;)
 | 
			
		||||
	{	register int i, len;
 | 
			
		||||
		register char *str;
 | 
			
		||||
		register int fund;
 | 
			
		||||
	}
 | 
			
		||||
:
 | 
			
		||||
	STRING
 | 
			
		||||
	{	str = dot.tk_bts;
 | 
			
		||||
		len = dot.tk_len;
 | 
			
		||||
		fund = dot.tk_fund;
 | 
			
		||||
	}
 | 
			
		||||
	[
 | 
			
		||||
		STRING
 | 
			
		||||
		{	/* A pasted string keeps the type of the first
 | 
			
		||||
			 * string literal.
 | 
			
		||||
			 * The pasting of normal strings and wide
 | 
			
		||||
			 * character strings are stated as having an
 | 
			
		||||
			 * undefined behaviour.
 | 
			
		||||
			 */
 | 
			
		||||
			if (dot.tk_fund != fund)
 | 
			
		||||
				warning("illegal pasting of string literals");
 | 
			
		||||
			str = Realloc(str, (unsigned) (--len + dot.tk_len));
 | 
			
		||||
			for (i = 0; i < dot.tk_len; i++)
 | 
			
		||||
				str[len++] = dot.tk_bts[i];
 | 
			
		||||
		}
 | 
			
		||||
	]*
 | 
			
		||||
	{ string2expr(expp, str, len); }
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* 3.3.2 */
 | 
			
		||||
postfix_expression(register struct expr **expp;)
 | 
			
		||||
	{ int oper; 
 | 
			
		||||
	  struct expr *e1 = 0;
 | 
			
		||||
	  struct idf *idf;
 | 
			
		||||
	}
 | 
			
		||||
:
 | 
			
		||||
	primary(expp)
 | 
			
		||||
	[
 | 
			
		||||
		'[' expression(&e1) ']'
 | 
			
		||||
			{ ch3bin(expp, '[', e1); e1 = 0; }
 | 
			
		||||
	|
 | 
			
		||||
		'(' parameter_list(&e1)? ')'
 | 
			
		||||
			{ ch3bin(expp, '(', e1); call_proto(expp); e1 = 0; }
 | 
			
		||||
	|
 | 
			
		||||
		[ '.' | ARROW ]			{ oper = DOT; }
 | 
			
		||||
		identifier(&idf)		{ ch3sel(expp, oper, idf); }
 | 
			
		||||
	|
 | 
			
		||||
		[
 | 
			
		||||
			PLUSPLUS	{ oper = POSTINCR; }
 | 
			
		||||
		|
 | 
			
		||||
			MINMIN		{ oper = POSTDECR; }
 | 
			
		||||
		]
 | 
			
		||||
		    { ch3incr(expp, oper); }
 | 
			
		||||
	]*
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
parameter_list(struct expr **expp;)
 | 
			
		||||
	{struct expr *e1 = 0;}
 | 
			
		||||
:
 | 
			
		||||
	assignment_expression(expp)
 | 
			
		||||
	{any2opnd(expp, PARCOMMA);}
 | 
			
		||||
	[ %persistent
 | 
			
		||||
		','
 | 
			
		||||
		assignment_expression(&e1)
 | 
			
		||||
		{any2opnd(&e1, PARCOMMA);}
 | 
			
		||||
		{ch3bin(expp, PARCOMMA, e1);}
 | 
			
		||||
	]*
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
%first	first_of_type_specifier, type_specifier;
 | 
			
		||||
 | 
			
		||||
/* 3.3.3 & 3.3.4 */
 | 
			
		||||
unary(register struct expr **expp;)
 | 
			
		||||
	{struct type *tp; int oper;}
 | 
			
		||||
:
 | 
			
		||||
%if (first_of_type_specifier(AHEAD) && AHEAD != IDENTIFIER)
 | 
			
		||||
	cast(&tp) unary(expp)
 | 
			
		||||
	{	ch3cast(expp, CAST, tp);
 | 
			
		||||
		(*expp)->ex_flags |= EX_CAST;
 | 
			
		||||
		if (int_size != pointer_size)
 | 
			
		||||
			(*expp)->ex_flags &= ~EX_PTRDIFF;
 | 
			
		||||
	}
 | 
			
		||||
|
 | 
			
		||||
	postfix_expression(expp)
 | 
			
		||||
|
 | 
			
		||||
	unop(&oper) unary(expp)
 | 
			
		||||
	{ch3mon(oper, expp);}
 | 
			
		||||
|
 | 
			
		||||
	size_of(expp)
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* When an identifier is used in a sizeof()-expression, we must stil not
 | 
			
		||||
 * mark it as used.
 | 
			
		||||
 * extern int i;  ....  sizeof(i)  .... need not have a definition for i
 | 
			
		||||
 */
 | 
			
		||||
size_of(register struct expr **expp;)
 | 
			
		||||
	{struct type *tp;}
 | 
			
		||||
:
 | 
			
		||||
	SIZEOF { InSizeof++; }	/* handle (sizeof(sizeof(int))) too */
 | 
			
		||||
	[%if (first_of_type_specifier(AHEAD) && AHEAD != IDENTIFIER)
 | 
			
		||||
		cast(&tp)
 | 
			
		||||
		{
 | 
			
		||||
			*expp = intexpr(size_of_type(tp, "type"), UNSIGNED);
 | 
			
		||||
			(*expp)->ex_flags |= EX_SIZEOF;
 | 
			
		||||
		}
 | 
			
		||||
	|
 | 
			
		||||
		unary(expp)
 | 
			
		||||
		{ch3mon(SIZEOF, expp);}
 | 
			
		||||
	]
 | 
			
		||||
	{ InSizeof--; }
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* 3.3.5-3.3.17 */
 | 
			
		||||
/*	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
 | 
			
		||||
	anymore). The standard describes this in phrase-structure-grammar,
 | 
			
		||||
	which we are unable to parse. The description that follows comes
 | 
			
		||||
	from the old C-compiler.
 | 
			
		||||
 | 
			
		||||
	In principle each operator is assigned a rank, ranging
 | 
			
		||||
	from 1 to 15.  Such an expression can be parsed by a construct
 | 
			
		||||
	like:
 | 
			
		||||
		binary_expression(int maxrank;)
 | 
			
		||||
			{int oper;}
 | 
			
		||||
		:
 | 
			
		||||
			binary_expression(maxrank - 1)
 | 
			
		||||
			[%if (rank_of(DOT) <= maxrank)
 | 
			
		||||
				binop(&oper)
 | 
			
		||||
				binary_expression(rank_of(oper)-1)
 | 
			
		||||
			]?
 | 
			
		||||
		;
 | 
			
		||||
	except that some call of 'unary' is necessary, depending on the
 | 
			
		||||
	grammar.
 | 
			
		||||
	
 | 
			
		||||
	This simple view is marred by three complications:
 | 
			
		||||
	1.	Level 15 (comma operator) is not allowed in many
 | 
			
		||||
		contexts and is different.
 | 
			
		||||
	2.	Level 13 (conditional operator) is a ternary operator,
 | 
			
		||||
		which does not fit this scheme at all.
 | 
			
		||||
	3.	Level 14 (assignment operators) group right-to-left, as
 | 
			
		||||
		opposed to 2-12, which group left-to-right (or are
 | 
			
		||||
		immaterial).
 | 
			
		||||
	4.	The operators in level 14 start with operators in levels
 | 
			
		||||
		2-13 (RM 7.14: The two parts of a compound assignment
 | 
			
		||||
		operator are separate tokens.)  This causes LL1 problems.
 | 
			
		||||
	This forces us to have four rules:
 | 
			
		||||
		binary_expression	for level 2-12
 | 
			
		||||
		conditional_expression	for level 13
 | 
			
		||||
		assignment_expression	for level 14 and
 | 
			
		||||
		expression		for the most general expression
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
binary_expression(int maxrank; struct expr **expp;)
 | 
			
		||||
	{int oper, OldResultKnown; struct expr *e1;}
 | 
			
		||||
:
 | 
			
		||||
	unary(expp)
 | 
			
		||||
	[%while (rank_of(DOT) <= maxrank )
 | 
			
		||||
		/*	'?', '=', and ',' are no binops
 | 
			
		||||
		 */
 | 
			
		||||
		binop(&oper)
 | 
			
		||||
		{ OldResultKnown = ResultKnown;
 | 
			
		||||
		  if (oper == OR || oper == AND) {
 | 
			
		||||
			  if (is_cp_cst(*expp) || is_fp_cst(*expp)) {
 | 
			
		||||
				  if (is_zero_cst(*expp)) {
 | 
			
		||||
					  if (oper == AND) ResultKnown++;
 | 
			
		||||
				  } else if (oper == OR) ResultKnown++;
 | 
			
		||||
			  }
 | 
			
		||||
		  }
 | 
			
		||||
		}
 | 
			
		||||
		binary_expression(rank_of(oper)-1, &e1)
 | 
			
		||||
		{
 | 
			
		||||
			ch3bin(expp, oper, e1);
 | 
			
		||||
			ResultKnown = OldResultKnown;
 | 
			
		||||
		}
 | 
			
		||||
	]*
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* 3.3.15 */
 | 
			
		||||
conditional_expression(struct expr **expp;)
 | 
			
		||||
	{struct expr *e1 = 0, *e2 = 0; int OldResultKnown, ConstExpr=0;}
 | 
			
		||||
:
 | 
			
		||||
	/* allow all binary operators */
 | 
			
		||||
	binary_expression(rank_of('?') - 1, expp)
 | 
			
		||||
	[	'?'
 | 
			
		||||
		{ OldResultKnown = ResultKnown;
 | 
			
		||||
		  if (is_cp_cst(*expp) || is_fp_cst(*expp)) {
 | 
			
		||||
			  ConstExpr++;
 | 
			
		||||
			  if (is_zero_cst(*expp)) ResultKnown++;
 | 
			
		||||
		  }
 | 
			
		||||
		}
 | 
			
		||||
		expression(&e1)
 | 
			
		||||
		':'
 | 
			
		||||
		{ if (ConstExpr) {
 | 
			
		||||
			if (OldResultKnown == ResultKnown) ResultKnown++;
 | 
			
		||||
			else ResultKnown = OldResultKnown;
 | 
			
		||||
		  }
 | 
			
		||||
		}
 | 
			
		||||
		conditional_expression(&e2)
 | 
			
		||||
		{	
 | 
			
		||||
			ResultKnown = OldResultKnown;
 | 
			
		||||
			ch3bin(&e1, ':', e2);
 | 
			
		||||
			opnd2test(expp, '?');
 | 
			
		||||
			ch3bin(expp, '?', e1);
 | 
			
		||||
		}
 | 
			
		||||
	]?
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* 3.3.16 */
 | 
			
		||||
assignment_expression(struct expr **expp;)
 | 
			
		||||
	{ int oper;
 | 
			
		||||
	  struct expr *e1 = 0;
 | 
			
		||||
	}
 | 
			
		||||
:
 | 
			
		||||
	conditional_expression(expp)
 | 
			
		||||
	[
 | 
			
		||||
		asgnop(&oper)
 | 
			
		||||
		assignment_expression(&e1)
 | 
			
		||||
		{ch3asgn(expp, oper, e1);}
 | 
			
		||||
	|
 | 
			
		||||
		empty		/* LLgen artefact ??? */
 | 
			
		||||
	]
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* 3.3.17 */
 | 
			
		||||
expression(struct expr **expp;)
 | 
			
		||||
	{struct expr *e1;}
 | 
			
		||||
:
 | 
			
		||||
	assignment_expression(expp)
 | 
			
		||||
	[	','
 | 
			
		||||
		assignment_expression(&e1)
 | 
			
		||||
		{
 | 
			
		||||
			ch3bin(expp, ',', e1);
 | 
			
		||||
		}
 | 
			
		||||
	]*
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
unop(int *oper;) :
 | 
			
		||||
	['*' | '&' | '-' | '+' | '!' | '~' | PLUSPLUS | MINMIN]
 | 
			
		||||
	{   if (DOT == '&') DOT = ADDRESSOF;
 | 
			
		||||
	    *oper = DOT;
 | 
			
		||||
	}
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
multop:
 | 
			
		||||
	'*' | '/' | '%'
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
addop:
 | 
			
		||||
	'+' | '-'
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
shiftop:
 | 
			
		||||
	LEFT | RIGHT
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
relop:
 | 
			
		||||
	'<' | '>' | LESSEQ | GREATEREQ
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
eqop:
 | 
			
		||||
	EQUAL | NOTEQUAL
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
arithop:
 | 
			
		||||
	multop | addop | shiftop
 | 
			
		||||
|
 | 
			
		||||
	'&' | '^' | '|'
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
binop(int *oper;) :
 | 
			
		||||
	[ arithop | relop | eqop | AND | OR ]
 | 
			
		||||
	{*oper = DOT;}
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
asgnop(register int *oper;):
 | 
			
		||||
	[ '=' | PLUSAB | MINAB | TIMESAB | DIVAB | MODAB 
 | 
			
		||||
	| LEFTAB | RIGHTAB | ANDAB | XORAB | ORAB ]
 | 
			
		||||
	{ *oper = DOT; }
 | 
			
		||||
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
constant(struct expr **expp;) :
 | 
			
		||||
[
 | 
			
		||||
	INTEGER
 | 
			
		||||
|
 | 
			
		||||
	FLOATING
 | 
			
		||||
]	{dot2expr(expp);}
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* 3.4 */
 | 
			
		||||
constant_expression (struct expr **expp;) :
 | 
			
		||||
	conditional_expression(expp)
 | 
			
		||||
	{ chk_cst_expr(expp); }
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
identifier(struct idf **idfp;) :
 | 
			
		||||
[ IDENTIFIER
 | 
			
		||||
| TYPE_IDENTIFIER
 | 
			
		||||
]
 | 
			
		||||
	{ *idfp = dot.tk_idf; }
 | 
			
		||||
;
 | 
			
		||||
/*
 | 
			
		||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
			
		||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
			
		||||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
/*	EXPRESSION SYNTAX PARSER	*/
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
#include	<alloc.h>
 | 
			
		||||
#include	"parameters.h"
 | 
			
		||||
#include	<flt_arith.h>
 | 
			
		||||
#include	"arith.h"
 | 
			
		||||
#include	"LLlex.h"
 | 
			
		||||
#include	"type.h"
 | 
			
		||||
#include	"label.h"
 | 
			
		||||
#include	"expr.h"
 | 
			
		||||
#include	"code.h"
 | 
			
		||||
#include    "error.h"
 | 
			
		||||
#include    "ch3.h"
 | 
			
		||||
#include    "ch3bin.h"
 | 
			
		||||
#include    "ch3mon.h"
 | 
			
		||||
#include    "proto.h"
 | 
			
		||||
#include	"sizes.h"
 | 
			
		||||
 | 
			
		||||
extern struct expr *intexpr();
 | 
			
		||||
int InSizeof = 0;	/* inside a sizeof- expression */
 | 
			
		||||
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
 | 
			
		||||
 * 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.
 | 
			
		||||
 * Such is life.
 | 
			
		||||
 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* 3.3.1 */
 | 
			
		||||
primary(register struct expr **expp;) :
 | 
			
		||||
	IDENTIFIER
 | 
			
		||||
	{dot2expr(expp);}
 | 
			
		||||
|
 | 
			
		||||
	constant(expp)
 | 
			
		||||
|
 | 
			
		||||
	string(expp)
 | 
			
		||||
|
 | 
			
		||||
	'(' expression(expp) ')'
 | 
			
		||||
	{ (*expp)->ex_flags |= EX_PARENS; }
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Character string literals that are adjacent tokens
 | 
			
		||||
 * are concatenated into a single character string
 | 
			
		||||
 * literal.
 | 
			
		||||
 */
 | 
			
		||||
string(register struct expr **expp;)
 | 
			
		||||
	{	register int i, len;
 | 
			
		||||
		register char *str;
 | 
			
		||||
		register int fund;
 | 
			
		||||
	}
 | 
			
		||||
:
 | 
			
		||||
	STRING
 | 
			
		||||
	{	str = dot.tk_bts;
 | 
			
		||||
		len = dot.tk_len;
 | 
			
		||||
		fund = dot.tk_fund;
 | 
			
		||||
	}
 | 
			
		||||
	[
 | 
			
		||||
		STRING
 | 
			
		||||
		{	/* A pasted string keeps the type of the first
 | 
			
		||||
			 * string literal.
 | 
			
		||||
			 * The pasting of normal strings and wide
 | 
			
		||||
			 * character strings are stated as having an
 | 
			
		||||
			 * undefined behaviour.
 | 
			
		||||
			 */
 | 
			
		||||
			if (dot.tk_fund != fund)
 | 
			
		||||
				warning("illegal pasting of string literals");
 | 
			
		||||
			str = Realloc(str, (unsigned) (--len + dot.tk_len));
 | 
			
		||||
			for (i = 0; i < dot.tk_len; i++)
 | 
			
		||||
				str[len++] = dot.tk_bts[i];
 | 
			
		||||
		}
 | 
			
		||||
	]*
 | 
			
		||||
	{ string2expr(expp, str, len); }
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* 3.3.2 */
 | 
			
		||||
postfix_expression(register struct expr **expp;)
 | 
			
		||||
	{ int oper; 
 | 
			
		||||
	  struct expr *e1 = 0;
 | 
			
		||||
	  struct idf *idf;
 | 
			
		||||
	}
 | 
			
		||||
:
 | 
			
		||||
	primary(expp)
 | 
			
		||||
	[
 | 
			
		||||
		'[' expression(&e1) ']'
 | 
			
		||||
			{ ch3bin(expp, '[', e1); e1 = 0; }
 | 
			
		||||
	|
 | 
			
		||||
		'(' parameter_list(&e1)? ')'
 | 
			
		||||
			{ ch3bin(expp, '(', e1); call_proto(expp); e1 = 0; }
 | 
			
		||||
	|
 | 
			
		||||
		[ '.' | ARROW ]			{ oper = DOT; }
 | 
			
		||||
		identifier(&idf)		{ ch3sel(expp, oper, idf); }
 | 
			
		||||
	|
 | 
			
		||||
		[
 | 
			
		||||
			PLUSPLUS	{ oper = POSTINCR; }
 | 
			
		||||
		|
 | 
			
		||||
			MINMIN		{ oper = POSTDECR; }
 | 
			
		||||
		]
 | 
			
		||||
		    { ch3incr(expp, oper); }
 | 
			
		||||
	]*
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
parameter_list(struct expr **expp;)
 | 
			
		||||
	{struct expr *e1 = 0;}
 | 
			
		||||
:
 | 
			
		||||
	assignment_expression(expp)
 | 
			
		||||
	{any2opnd(expp, PARCOMMA);}
 | 
			
		||||
	[ %persistent
 | 
			
		||||
		','
 | 
			
		||||
		assignment_expression(&e1)
 | 
			
		||||
		{any2opnd(&e1, PARCOMMA);}
 | 
			
		||||
		{ch3bin(expp, PARCOMMA, e1);}
 | 
			
		||||
	]*
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
%first	first_of_type_specifier, type_specifier;
 | 
			
		||||
 | 
			
		||||
/* 3.3.3 & 3.3.4 */
 | 
			
		||||
unary(register struct expr **expp;)
 | 
			
		||||
	{struct type *tp; int oper;}
 | 
			
		||||
:
 | 
			
		||||
%if (first_of_type_specifier(AHEAD) && AHEAD != IDENTIFIER)
 | 
			
		||||
	cast(&tp) unary(expp)
 | 
			
		||||
	{	ch3cast(expp, CAST, tp);
 | 
			
		||||
		(*expp)->ex_flags |= EX_CAST;
 | 
			
		||||
		if (int_size != pointer_size)
 | 
			
		||||
			(*expp)->ex_flags &= ~EX_PTRDIFF;
 | 
			
		||||
	}
 | 
			
		||||
|
 | 
			
		||||
	postfix_expression(expp)
 | 
			
		||||
|
 | 
			
		||||
	unop(&oper) unary(expp)
 | 
			
		||||
	{ch3mon(oper, expp);}
 | 
			
		||||
|
 | 
			
		||||
	size_of(expp)
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* When an identifier is used in a sizeof()-expression, we must stil not
 | 
			
		||||
 * mark it as used.
 | 
			
		||||
 * extern int i;  ....  sizeof(i)  .... need not have a definition for i
 | 
			
		||||
 */
 | 
			
		||||
size_of(register struct expr **expp;)
 | 
			
		||||
	{struct type *tp;}
 | 
			
		||||
:
 | 
			
		||||
	SIZEOF { InSizeof++; }	/* handle (sizeof(sizeof(int))) too */
 | 
			
		||||
	[%if (first_of_type_specifier(AHEAD) && AHEAD != IDENTIFIER)
 | 
			
		||||
		cast(&tp)
 | 
			
		||||
		{
 | 
			
		||||
			*expp = intexpr(size_of_type(tp, "type"), UNSIGNED);
 | 
			
		||||
			(*expp)->ex_flags |= EX_SIZEOF;
 | 
			
		||||
		}
 | 
			
		||||
	|
 | 
			
		||||
		unary(expp)
 | 
			
		||||
		{ch3mon(SIZEOF, expp);}
 | 
			
		||||
	]
 | 
			
		||||
	{ InSizeof--; }
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* 3.3.5-3.3.17 */
 | 
			
		||||
/*	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
 | 
			
		||||
	anymore). The standard describes this in phrase-structure-grammar,
 | 
			
		||||
	which we are unable to parse. The description that follows comes
 | 
			
		||||
	from the old C-compiler.
 | 
			
		||||
 | 
			
		||||
	In principle each operator is assigned a rank, ranging
 | 
			
		||||
	from 1 to 15.  Such an expression can be parsed by a construct
 | 
			
		||||
	like:
 | 
			
		||||
		binary_expression(int maxrank;)
 | 
			
		||||
			{int oper;}
 | 
			
		||||
		:
 | 
			
		||||
			binary_expression(maxrank - 1)
 | 
			
		||||
			[%if (rank_of(DOT) <= maxrank)
 | 
			
		||||
				binop(&oper)
 | 
			
		||||
				binary_expression(rank_of(oper)-1)
 | 
			
		||||
			]?
 | 
			
		||||
		;
 | 
			
		||||
	except that some call of 'unary' is necessary, depending on the
 | 
			
		||||
	grammar.
 | 
			
		||||
	
 | 
			
		||||
	This simple view is marred by three complications:
 | 
			
		||||
	1.	Level 15 (comma operator) is not allowed in many
 | 
			
		||||
		contexts and is different.
 | 
			
		||||
	2.	Level 13 (conditional operator) is a ternary operator,
 | 
			
		||||
		which does not fit this scheme at all.
 | 
			
		||||
	3.	Level 14 (assignment operators) group right-to-left, as
 | 
			
		||||
		opposed to 2-12, which group left-to-right (or are
 | 
			
		||||
		immaterial).
 | 
			
		||||
	4.	The operators in level 14 start with operators in levels
 | 
			
		||||
		2-13 (RM 7.14: The two parts of a compound assignment
 | 
			
		||||
		operator are separate tokens.)  This causes LL1 problems.
 | 
			
		||||
	This forces us to have four rules:
 | 
			
		||||
		binary_expression	for level 2-12
 | 
			
		||||
		conditional_expression	for level 13
 | 
			
		||||
		assignment_expression	for level 14 and
 | 
			
		||||
		expression		for the most general expression
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
binary_expression(int maxrank; struct expr **expp;)
 | 
			
		||||
	{int oper, OldResultKnown; struct expr *e1;}
 | 
			
		||||
:
 | 
			
		||||
	unary(expp)
 | 
			
		||||
	[%while (rank_of(DOT) <= maxrank )
 | 
			
		||||
		/*	'?', '=', and ',' are no binops
 | 
			
		||||
		 */
 | 
			
		||||
		binop(&oper)
 | 
			
		||||
		{ OldResultKnown = ResultKnown;
 | 
			
		||||
		  if (oper == OR || oper == AND) {
 | 
			
		||||
			  if (is_cp_cst(*expp) || is_fp_cst(*expp)) {
 | 
			
		||||
				  if (is_zero_cst(*expp)) {
 | 
			
		||||
					  if (oper == AND) ResultKnown++;
 | 
			
		||||
				  } else if (oper == OR) ResultKnown++;
 | 
			
		||||
			  }
 | 
			
		||||
		  }
 | 
			
		||||
		}
 | 
			
		||||
		binary_expression(rank_of(oper)-1, &e1)
 | 
			
		||||
		{
 | 
			
		||||
			ch3bin(expp, oper, e1);
 | 
			
		||||
			ResultKnown = OldResultKnown;
 | 
			
		||||
		}
 | 
			
		||||
	]*
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* 3.3.15 */
 | 
			
		||||
conditional_expression(struct expr **expp;)
 | 
			
		||||
	{struct expr *e1 = 0, *e2 = 0; int OldResultKnown, ConstExpr=0;}
 | 
			
		||||
:
 | 
			
		||||
	/* allow all binary operators */
 | 
			
		||||
	binary_expression(rank_of('?') - 1, expp)
 | 
			
		||||
	[	'?'
 | 
			
		||||
		{ OldResultKnown = ResultKnown;
 | 
			
		||||
		  if (is_cp_cst(*expp) || is_fp_cst(*expp)) {
 | 
			
		||||
			  ConstExpr++;
 | 
			
		||||
			  if (is_zero_cst(*expp)) ResultKnown++;
 | 
			
		||||
		  }
 | 
			
		||||
		}
 | 
			
		||||
		expression(&e1)
 | 
			
		||||
		':'
 | 
			
		||||
		{ if (ConstExpr) {
 | 
			
		||||
			if (OldResultKnown == ResultKnown) ResultKnown++;
 | 
			
		||||
			else ResultKnown = OldResultKnown;
 | 
			
		||||
		  }
 | 
			
		||||
		}
 | 
			
		||||
		conditional_expression(&e2)
 | 
			
		||||
		{	
 | 
			
		||||
			ResultKnown = OldResultKnown;
 | 
			
		||||
			ch3bin(&e1, ':', e2);
 | 
			
		||||
			opnd2test(expp, '?');
 | 
			
		||||
			ch3bin(expp, '?', e1);
 | 
			
		||||
		}
 | 
			
		||||
	]?
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* 3.3.16 */
 | 
			
		||||
assignment_expression(struct expr **expp;)
 | 
			
		||||
	{ int oper;
 | 
			
		||||
	  struct expr *e1 = 0;
 | 
			
		||||
	}
 | 
			
		||||
:
 | 
			
		||||
	conditional_expression(expp)
 | 
			
		||||
	[
 | 
			
		||||
		asgnop(&oper)
 | 
			
		||||
		assignment_expression(&e1)
 | 
			
		||||
		{ch3asgn(expp, oper, e1);}
 | 
			
		||||
	|
 | 
			
		||||
		empty		/* LLgen artefact ??? */
 | 
			
		||||
	]
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* 3.3.17 */
 | 
			
		||||
expression(struct expr **expp;)
 | 
			
		||||
	{struct expr *e1;}
 | 
			
		||||
:
 | 
			
		||||
	assignment_expression(expp)
 | 
			
		||||
	[	','
 | 
			
		||||
		assignment_expression(&e1)
 | 
			
		||||
		{
 | 
			
		||||
			ch3bin(expp, ',', e1);
 | 
			
		||||
		}
 | 
			
		||||
	]*
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
unop(int *oper;) :
 | 
			
		||||
	['*' | '&' | '-' | '+' | '!' | '~' | PLUSPLUS | MINMIN]
 | 
			
		||||
	{   if (DOT == '&') DOT = ADDRESSOF;
 | 
			
		||||
	    *oper = DOT;
 | 
			
		||||
	}
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
multop:
 | 
			
		||||
	'*' | '/' | '%'
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
addop:
 | 
			
		||||
	'+' | '-'
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
shiftop:
 | 
			
		||||
	LEFT | RIGHT
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
relop:
 | 
			
		||||
	'<' | '>' | LESSEQ | GREATEREQ
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
eqop:
 | 
			
		||||
	EQUAL | NOTEQUAL
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
arithop:
 | 
			
		||||
	multop | addop | shiftop
 | 
			
		||||
|
 | 
			
		||||
	'&' | '^' | '|'
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
binop(int *oper;) :
 | 
			
		||||
	[ arithop | relop | eqop | AND | OR ]
 | 
			
		||||
	{*oper = DOT;}
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
asgnop(register int *oper;):
 | 
			
		||||
	[ '=' | PLUSAB | MINAB | TIMESAB | DIVAB | MODAB 
 | 
			
		||||
	| LEFTAB | RIGHTAB | ANDAB | XORAB | ORAB ]
 | 
			
		||||
	{ *oper = DOT; }
 | 
			
		||||
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
constant(struct expr **expp;) :
 | 
			
		||||
[
 | 
			
		||||
	INTEGER
 | 
			
		||||
|
 | 
			
		||||
	FLOATING
 | 
			
		||||
]	{dot2expr(expp);}
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* 3.4 */
 | 
			
		||||
constant_expression (struct expr **expp;) :
 | 
			
		||||
	conditional_expression(expp)
 | 
			
		||||
	{ chk_cst_expr(expp); }
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
identifier(struct idf **idfp;) :
 | 
			
		||||
[ IDENTIFIER
 | 
			
		||||
| TYPE_IDENTIFIER
 | 
			
		||||
]
 | 
			
		||||
	{ *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.
 | 
			
		||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
			
		||||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
/* PROGRAM PARSER */
 | 
			
		||||
 | 
			
		||||
/*	The presence of typedef declarations renders it impossible to
 | 
			
		||||
	make a context-free grammar of C. Consequently we need
 | 
			
		||||
	context-sensitive parsing techniques, the simplest one being
 | 
			
		||||
	a subtle cooperation between the parser and the lexical scanner.
 | 
			
		||||
	The lexical scanner has to know whether to return IDENTIFIER
 | 
			
		||||
	or TYPE_IDENTIFIER for a given tag, and it obtains this information
 | 
			
		||||
	from the definition list, as constructed by the parser.
 | 
			
		||||
	The present grammar is essentially LL(2), and is processed by
 | 
			
		||||
	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)
 | 
			
		||||
	ambiguities, the lexical scanner does a one symbol look-ahead.
 | 
			
		||||
	This symbol, however, cannot always be correctly assessed, since
 | 
			
		||||
	the present symbol may cause a change in the definition list
 | 
			
		||||
	which causes the identification of the look-ahead symbol to be
 | 
			
		||||
	invalidated.
 | 
			
		||||
	The lexical scanner relies on the parser (or its routines) to
 | 
			
		||||
	detect this situation and then update 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
 | 
			
		||||
	would be more beautiful but less correct, since then for a short
 | 
			
		||||
	while there would be a discrepancy between the look-ahead symbol
 | 
			
		||||
	and the definition list; I think it would nevertheless work in
 | 
			
		||||
	correct programs.
 | 
			
		||||
	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
 | 
			
		||||
	isn't. We would have to fill that in afterwards.
 | 
			
		||||
 | 
			
		||||
	At block exit the situation is even worse. Upon reading the
 | 
			
		||||
	closing brace, the names declared inside the function are cleared
 | 
			
		||||
	from the name list. This action may expose a type identifier that
 | 
			
		||||
	is the same as the identifier in the look-ahead symbol. This
 | 
			
		||||
	situation certainly invalidates the third solution, and casts
 | 
			
		||||
	doubts upon the second.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
%lexical	LLlex;
 | 
			
		||||
%start		C_program, program;
 | 
			
		||||
%start		If_expr, control_if_expression;
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
#include	"parameters.h"
 | 
			
		||||
#include	<flt_arith.h>
 | 
			
		||||
#include	"arith.h"
 | 
			
		||||
#include	"LLlex.h"
 | 
			
		||||
#include	"label.h"
 | 
			
		||||
#include	"type.h"
 | 
			
		||||
#include	"declar.h"
 | 
			
		||||
#include	"decspecs.h"
 | 
			
		||||
#include	"code.h"
 | 
			
		||||
#include	"expr.h"
 | 
			
		||||
#include	"def.h"
 | 
			
		||||
#include    "idf.h"
 | 
			
		||||
#include    "declarator.h"
 | 
			
		||||
#include    "stack.h"
 | 
			
		||||
#include    "proto.h"
 | 
			
		||||
#include    "error.h"
 | 
			
		||||
#ifdef	LINT
 | 
			
		||||
#include	"l_lint.h"
 | 
			
		||||
#endif	/* LINT */
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
control_if_expression
 | 
			
		||||
	{
 | 
			
		||||
		struct expr *exprX;
 | 
			
		||||
	}
 | 
			
		||||
:
 | 
			
		||||
	constant_expression(&exprX)
 | 
			
		||||
		{
 | 
			
		||||
		}
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* 3.7 */
 | 
			
		||||
program:
 | 
			
		||||
	[%persistent external_definition]*
 | 
			
		||||
	{ unstack_world(); }
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/*	A C identifier definition is remarkable in that it formulates
 | 
			
		||||
	the declaration in a way different from most other languages:
 | 
			
		||||
	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
 | 
			
		||||
	pointer-to-integer.  This has profound consequences, both for the
 | 
			
		||||
	structure of an identifier definition and for the compiler.
 | 
			
		||||
	
 | 
			
		||||
	A definition starts with a decl_specifiers, which contains things
 | 
			
		||||
	like
 | 
			
		||||
		typedef int
 | 
			
		||||
	which is implicitly repeated for every definition in the list, and
 | 
			
		||||
	then for each identifier a declarator is given, of the form
 | 
			
		||||
		*a()
 | 
			
		||||
	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
 | 
			
		||||
	declarator, only to be passed to declare_idf together with the
 | 
			
		||||
	struct decspecs.
 | 
			
		||||
 | 
			
		||||
	With the introduction of prototypes, extra problems for the scope
 | 
			
		||||
	administration were introduced as well.  We can have, for example,
 | 
			
		||||
	int x(double x);
 | 
			
		||||
	and
 | 
			
		||||
	int x(double x) { ... use(x) ... }
 | 
			
		||||
	In the first case, the parameter name can be forgotten, whereas in
 | 
			
		||||
	the second case, the parameter should have a block scope.  The
 | 
			
		||||
	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 end of the list.  Our solution is as follows:
 | 
			
		||||
	1-  In case of a declaration, throw the parameter identifier away
 | 
			
		||||
	    before the declaration of the outer x.
 | 
			
		||||
	2-  In case of a definition, the function begin_proc() changes the
 | 
			
		||||
	    def list for the identifier.  This means that declare_idf()
 | 
			
		||||
	    contains an extra test in case we already saw a declaration of
 | 
			
		||||
	    such a function, because this function is called before
 | 
			
		||||
	    begin_proc().
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
external_definition
 | 
			
		||||
	{	struct decspecs Ds;
 | 
			
		||||
		struct	declarator Dc;
 | 
			
		||||
	}
 | 
			
		||||
:
 | 
			
		||||
	{	Ds = null_decspecs;
 | 
			
		||||
		Dc = null_declarator;
 | 
			
		||||
	}
 | 
			
		||||
	[ %if (DOT != IDENTIFIER || AHEAD == IDENTIFIER)
 | 
			
		||||
		decl_specifiers(&Ds)
 | 
			
		||||
	|
 | 
			
		||||
		{do_decspecs(&Ds);}
 | 
			
		||||
	]
 | 
			
		||||
	[
 | 
			
		||||
		declarator(&Dc)
 | 
			
		||||
		{
 | 
			
		||||
			declare_idf(&Ds, &Dc, level);
 | 
			
		||||
#ifdef	LINT
 | 
			
		||||
			lint_ext_def(Dc.dc_idf, Ds.ds_sc);
 | 
			
		||||
#endif	/* LINT */
 | 
			
		||||
		}
 | 
			
		||||
		[
 | 
			
		||||
			function(&Ds, &Dc)
 | 
			
		||||
		|
 | 
			
		||||
			{	if (! Ds.ds_sc_given && ! Ds.ds_typequal &&
 | 
			
		||||
				    Ds.ds_notypegiven) {
 | 
			
		||||
					strict("declaration specifiers missing");
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			non_function(&Ds, &Dc)
 | 
			
		||||
		]
 | 
			
		||||
	|
 | 
			
		||||
		{	if (! Ds.ds_sc_given && ! Ds.ds_typequal &&
 | 
			
		||||
			    Ds.ds_notypegiven) {
 | 
			
		||||
				strict("declaration missing");
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		';'
 | 
			
		||||
	]
 | 
			
		||||
	{remove_declarator(&Dc); flush_strings(); }
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
non_function(register struct decspecs *ds; register struct declarator *dc;)
 | 
			
		||||
:
 | 
			
		||||
	{	reject_params(dc);
 | 
			
		||||
	}
 | 
			
		||||
	[
 | 
			
		||||
		initializer(dc->dc_idf, ds->ds_sc)
 | 
			
		||||
	|
 | 
			
		||||
		{ code_declaration(dc->dc_idf, (struct expr *) 0, level, ds->ds_sc); }
 | 
			
		||||
	]
 | 
			
		||||
	{
 | 
			
		||||
#ifdef	LINT
 | 
			
		||||
		lint_non_function_decl(ds, dc);
 | 
			
		||||
#endif	/* LINT */
 | 
			
		||||
	}
 | 
			
		||||
	[
 | 
			
		||||
		','
 | 
			
		||||
		init_declarator(ds)
 | 
			
		||||
	]*
 | 
			
		||||
	';'
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* 3.7.1 */
 | 
			
		||||
function(struct decspecs *ds; struct declarator *dc;)
 | 
			
		||||
	{
 | 
			
		||||
		arith fbytes;
 | 
			
		||||
		register struct idf *idf = dc->dc_idf;
 | 
			
		||||
	}
 | 
			
		||||
:
 | 
			
		||||
	{
 | 
			
		||||
#ifdef	LINT
 | 
			
		||||
		lint_start_function();
 | 
			
		||||
#endif	/* LINT */
 | 
			
		||||
		idf_initialized(idf);
 | 
			
		||||
		stack_level();		/* L_FORMAL1 declarations */
 | 
			
		||||
		declare_params(dc);
 | 
			
		||||
		begin_proc(ds, idf);	/* sets global function info */
 | 
			
		||||
		stack_level();		/* L_FORMAL2 declarations */
 | 
			
		||||
		declare_protos(dc);
 | 
			
		||||
	}
 | 
			
		||||
	declaration*
 | 
			
		||||
	{
 | 
			
		||||
		check_formals(idf, dc);		/* check style-mixtures */
 | 
			
		||||
		declare_formals(idf, &fbytes);
 | 
			
		||||
#ifdef	LINT
 | 
			
		||||
		lint_formals();
 | 
			
		||||
#endif	/* LINT */
 | 
			
		||||
	}
 | 
			
		||||
	compound_statement
 | 
			
		||||
	{
 | 
			
		||||
		end_proc(fbytes);
 | 
			
		||||
#ifdef	LINT
 | 
			
		||||
		lint_implicit_return();
 | 
			
		||||
#endif	/* LINT */
 | 
			
		||||
		unstack_level();	/* L_FORMAL2 declarations */
 | 
			
		||||
#ifdef	LINT
 | 
			
		||||
		lint_end_formals();
 | 
			
		||||
#endif	/* LINT */
 | 
			
		||||
		unstack_level();	/* L_FORMAL1 declarations */
 | 
			
		||||
#ifdef	LINT
 | 
			
		||||
		lint_end_function();
 | 
			
		||||
#endif	/* LINT */
 | 
			
		||||
	}
 | 
			
		||||
;
 | 
			
		||||
/*
 | 
			
		||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
			
		||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
			
		||||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
/* PROGRAM PARSER */
 | 
			
		||||
 | 
			
		||||
/*	The presence of typedef declarations renders it impossible to
 | 
			
		||||
	make a context-free grammar of C. Consequently we need
 | 
			
		||||
	context-sensitive parsing techniques, the simplest one being
 | 
			
		||||
	a subtle cooperation between the parser and the lexical scanner.
 | 
			
		||||
	The lexical scanner has to know whether to return IDENTIFIER
 | 
			
		||||
	or TYPE_IDENTIFIER for a given tag, and it obtains this information
 | 
			
		||||
	from the definition list, as constructed by the parser.
 | 
			
		||||
	The present grammar is essentially LL(2), and is processed by
 | 
			
		||||
	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)
 | 
			
		||||
	ambiguities, the lexical scanner does a one symbol look-ahead.
 | 
			
		||||
	This symbol, however, cannot always be correctly assessed, since
 | 
			
		||||
	the present symbol may cause a change in the definition list
 | 
			
		||||
	which causes the identification of the look-ahead symbol to be
 | 
			
		||||
	invalidated.
 | 
			
		||||
	The lexical scanner relies on the parser (or its routines) to
 | 
			
		||||
	detect this situation and then update 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
 | 
			
		||||
	would be more beautiful but less correct, since then for a short
 | 
			
		||||
	while there would be a discrepancy between the look-ahead symbol
 | 
			
		||||
	and the definition list; I think it would nevertheless work in
 | 
			
		||||
	correct programs.
 | 
			
		||||
	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
 | 
			
		||||
	isn't. We would have to fill that in afterwards.
 | 
			
		||||
 | 
			
		||||
	At block exit the situation is even worse. Upon reading the
 | 
			
		||||
	closing brace, the names declared inside the function are cleared
 | 
			
		||||
	from the name list. This action may expose a type identifier that
 | 
			
		||||
	is the same as the identifier in the look-ahead symbol. This
 | 
			
		||||
	situation certainly invalidates the third solution, and casts
 | 
			
		||||
	doubts upon the second.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
%lexical	LLlex;
 | 
			
		||||
%start		C_program, program;
 | 
			
		||||
%start		If_expr, control_if_expression;
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
#include	"parameters.h"
 | 
			
		||||
#include	<flt_arith.h>
 | 
			
		||||
#include	"arith.h"
 | 
			
		||||
#include	"LLlex.h"
 | 
			
		||||
#include	"label.h"
 | 
			
		||||
#include	"type.h"
 | 
			
		||||
#include	"declar.h"
 | 
			
		||||
#include	"decspecs.h"
 | 
			
		||||
#include	"code.h"
 | 
			
		||||
#include	"expr.h"
 | 
			
		||||
#include	"def.h"
 | 
			
		||||
#include    "idf.h"
 | 
			
		||||
#include    "declarator.h"
 | 
			
		||||
#include    "stack.h"
 | 
			
		||||
#include    "proto.h"
 | 
			
		||||
#include    "error.h"
 | 
			
		||||
#ifdef	LINT
 | 
			
		||||
#include	"l_lint.h"
 | 
			
		||||
#endif	/* LINT */
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
control_if_expression
 | 
			
		||||
	{
 | 
			
		||||
		struct expr *exprX;
 | 
			
		||||
	}
 | 
			
		||||
:
 | 
			
		||||
	constant_expression(&exprX)
 | 
			
		||||
		{
 | 
			
		||||
		}
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* 3.7 */
 | 
			
		||||
program:
 | 
			
		||||
	[%persistent external_definition]*
 | 
			
		||||
	{ unstack_world(); }
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/*	A C identifier definition is remarkable in that it formulates
 | 
			
		||||
	the declaration in a way different from most other languages:
 | 
			
		||||
	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
 | 
			
		||||
	pointer-to-integer.  This has profound consequences, both for the
 | 
			
		||||
	structure of an identifier definition and for the compiler.
 | 
			
		||||
	
 | 
			
		||||
	A definition starts with a decl_specifiers, which contains things
 | 
			
		||||
	like
 | 
			
		||||
		typedef int
 | 
			
		||||
	which is implicitly repeated for every definition in the list, and
 | 
			
		||||
	then for each identifier a declarator is given, of the form
 | 
			
		||||
		*a()
 | 
			
		||||
	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
 | 
			
		||||
	declarator, only to be passed to declare_idf together with the
 | 
			
		||||
	struct decspecs.
 | 
			
		||||
 | 
			
		||||
	With the introduction of prototypes, extra problems for the scope
 | 
			
		||||
	administration were introduced as well.  We can have, for example,
 | 
			
		||||
	int x(double x);
 | 
			
		||||
	and
 | 
			
		||||
	int x(double x) { ... use(x) ... }
 | 
			
		||||
	In the first case, the parameter name can be forgotten, whereas in
 | 
			
		||||
	the second case, the parameter should have a block scope.  The
 | 
			
		||||
	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 end of the list.  Our solution is as follows:
 | 
			
		||||
	1-  In case of a declaration, throw the parameter identifier away
 | 
			
		||||
	    before the declaration of the outer x.
 | 
			
		||||
	2-  In case of a definition, the function begin_proc() changes the
 | 
			
		||||
	    def list for the identifier.  This means that declare_idf()
 | 
			
		||||
	    contains an extra test in case we already saw a declaration of
 | 
			
		||||
	    such a function, because this function is called before
 | 
			
		||||
	    begin_proc().
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
external_definition
 | 
			
		||||
	{	struct decspecs Ds;
 | 
			
		||||
		struct	declarator Dc;
 | 
			
		||||
	}
 | 
			
		||||
:
 | 
			
		||||
	{	Ds = null_decspecs;
 | 
			
		||||
		Dc = null_declarator;
 | 
			
		||||
	}
 | 
			
		||||
	[ %if (DOT != IDENTIFIER || AHEAD == IDENTIFIER)
 | 
			
		||||
		decl_specifiers(&Ds)
 | 
			
		||||
	|
 | 
			
		||||
		{do_decspecs(&Ds);}
 | 
			
		||||
	]
 | 
			
		||||
	[
 | 
			
		||||
		declarator(&Dc)
 | 
			
		||||
		{
 | 
			
		||||
			declare_idf(&Ds, &Dc, level);
 | 
			
		||||
#ifdef	LINT
 | 
			
		||||
			lint_ext_def(Dc.dc_idf, Ds.ds_sc);
 | 
			
		||||
#endif	/* LINT */
 | 
			
		||||
		}
 | 
			
		||||
		[
 | 
			
		||||
			function(&Ds, &Dc)
 | 
			
		||||
		|
 | 
			
		||||
			{	if (! Ds.ds_sc_given && ! Ds.ds_typequal &&
 | 
			
		||||
				    Ds.ds_notypegiven) {
 | 
			
		||||
					strict("declaration specifiers missing");
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			non_function(&Ds, &Dc)
 | 
			
		||||
		]
 | 
			
		||||
	|
 | 
			
		||||
		{	if (! Ds.ds_sc_given && ! Ds.ds_typequal &&
 | 
			
		||||
			    Ds.ds_notypegiven) {
 | 
			
		||||
				strict("declaration missing");
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		';'
 | 
			
		||||
	]
 | 
			
		||||
	{remove_declarator(&Dc); flush_strings(); }
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
non_function(register struct decspecs *ds; register struct declarator *dc;)
 | 
			
		||||
:
 | 
			
		||||
	{	reject_params(dc);
 | 
			
		||||
	}
 | 
			
		||||
	[
 | 
			
		||||
		initializer(dc->dc_idf, ds->ds_sc)
 | 
			
		||||
	|
 | 
			
		||||
		{ code_declaration(dc->dc_idf, (struct expr *) 0, level, ds->ds_sc); }
 | 
			
		||||
	]
 | 
			
		||||
	{
 | 
			
		||||
#ifdef	LINT
 | 
			
		||||
		lint_non_function_decl(ds, dc);
 | 
			
		||||
#endif	/* LINT */
 | 
			
		||||
	}
 | 
			
		||||
	[
 | 
			
		||||
		','
 | 
			
		||||
		init_declarator(ds)
 | 
			
		||||
	]*
 | 
			
		||||
	';'
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
/* 3.7.1 */
 | 
			
		||||
function(struct decspecs *ds; struct declarator *dc;)
 | 
			
		||||
	{
 | 
			
		||||
		arith fbytes;
 | 
			
		||||
		register struct idf *idf = dc->dc_idf;
 | 
			
		||||
	}
 | 
			
		||||
:
 | 
			
		||||
	{
 | 
			
		||||
#ifdef	LINT
 | 
			
		||||
		lint_start_function();
 | 
			
		||||
#endif	/* LINT */
 | 
			
		||||
		idf_initialized(idf);
 | 
			
		||||
		stack_level();		/* L_FORMAL1 declarations */
 | 
			
		||||
		declare_params(dc);
 | 
			
		||||
		begin_proc(ds, idf);	/* sets global function info */
 | 
			
		||||
		stack_level();		/* L_FORMAL2 declarations */
 | 
			
		||||
		declare_protos(dc);
 | 
			
		||||
	}
 | 
			
		||||
	declaration*
 | 
			
		||||
	{
 | 
			
		||||
		check_formals(idf, dc);		/* check style-mixtures */
 | 
			
		||||
		declare_formals(idf, &fbytes);
 | 
			
		||||
#ifdef	LINT
 | 
			
		||||
		lint_formals();
 | 
			
		||||
#endif	/* LINT */
 | 
			
		||||
	}
 | 
			
		||||
	compound_statement
 | 
			
		||||
	{
 | 
			
		||||
		end_proc(fbytes);
 | 
			
		||||
#ifdef	LINT
 | 
			
		||||
		lint_implicit_return();
 | 
			
		||||
#endif	/* LINT */
 | 
			
		||||
		unstack_level();	/* L_FORMAL2 declarations */
 | 
			
		||||
#ifdef	LINT
 | 
			
		||||
		lint_end_formals();
 | 
			
		||||
#endif	/* LINT */
 | 
			
		||||
		unstack_level();	/* L_FORMAL1 declarations */
 | 
			
		||||
#ifdef	LINT
 | 
			
		||||
		lint_end_function();
 | 
			
		||||
#endif	/* LINT */
 | 
			
		||||
	}
 | 
			
		||||
;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
						 | 
				
			
			@ -1,16 +1,16 @@
 | 
			
		|||
	default:
 | 
			
		||||
		if (tok <= 0) return "end of file";
 | 
			
		||||
		if (tok < 040 || tok >= 0177) {
 | 
			
		||||
			return "bad token";
 | 
			
		||||
		}
 | 
			
		||||
		/* fall through */
 | 
			
		||||
	case '\n':
 | 
			
		||||
	case '\f':
 | 
			
		||||
	case '\v':
 | 
			
		||||
	case '\r':
 | 
			
		||||
	case '\t':
 | 
			
		||||
		index = (index+2) & (SIZBUF-1);
 | 
			
		||||
		buf[index] = tok;
 | 
			
		||||
		return &buf[index];
 | 
			
		||||
	}
 | 
			
		||||
	default:
 | 
			
		||||
		if (tok <= 0) return "end of file";
 | 
			
		||||
		if (tok < 040 || tok >= 0177) {
 | 
			
		||||
			return "bad token";
 | 
			
		||||
		}
 | 
			
		||||
		/* fall through */
 | 
			
		||||
	case '\n':
 | 
			
		||||
	case '\f':
 | 
			
		||||
	case '\v':
 | 
			
		||||
	case '\r':
 | 
			
		||||
	case '\t':
 | 
			
		||||
		index = (index+2) & (SIZBUF-1);
 | 
			
		||||
		buf[index] = tok;
 | 
			
		||||
		return &buf[index];
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,12 +1,12 @@
 | 
			
		|||
/* Generated by make.tokcase */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
#include "Lpars.h"
 | 
			
		||||
 | 
			
		||||
char *symbol2str(int tok)
 | 
			
		||||
{
 | 
			
		||||
#define SIZBUF	8
 | 
			
		||||
	/* allow for a few invocations in f.i. an argument list */
 | 
			
		||||
	static char buf[SIZBUF];
 | 
			
		||||
	static int index;
 | 
			
		||||
 | 
			
		||||
	switch (tok) {
 | 
			
		||||
/* Generated by make.tokcase */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
#include "Lpars.h"
 | 
			
		||||
 | 
			
		||||
char *symbol2str(int tok)
 | 
			
		||||
{
 | 
			
		||||
#define SIZBUF	8
 | 
			
		||||
	/* allow for a few invocations in f.i. an argument list */
 | 
			
		||||
	static char buf[SIZBUF];
 | 
			
		||||
	static int index;
 | 
			
		||||
 | 
			
		||||
	switch (tok) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -58,7 +58,8 @@ normalrule {
 | 
			
		|||
	name = "next_c",
 | 
			
		||||
	ins = {
 | 
			
		||||
		"./make.next",
 | 
			
		||||
		"./*.str",
 | 
			
		||||
		"./macro.str",
 | 
			
		||||
		"./replace.str",
 | 
			
		||||
	},
 | 
			
		||||
	outleaves = { "next.c" },
 | 
			
		||||
	commands = {
 | 
			
		||||
| 
						 | 
				
			
			@ -82,7 +83,22 @@ tabgen {
 | 
			
		|||
cprogram {
 | 
			
		||||
	name = "cpp",
 | 
			
		||||
	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$"),
 | 
			
		||||
		"+next_c",
 | 
			
		||||
		"+symbol2str_c",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,24 +33,163 @@ for _, plat in ipairs(vars.plats) do
 | 
			
		|||
		srcs = {
 | 
			
		||||
			"+ctype_files",
 | 
			
		||||
			"+ctype_tab",
 | 
			
		||||
			"./core/ctype/*.c",
 | 
			
		||||
			"./core/errno/*.c",
 | 
			
		||||
			"./core/locale/*.c",
 | 
			
		||||
			"./core/math/*.c",
 | 
			
		||||
			"./core/math/*.e",
 | 
			
		||||
			"./core/misc/*.c",
 | 
			
		||||
			"./core/printf/*.c",
 | 
			
		||||
			"./core/scanf/*.c",
 | 
			
		||||
			"./core/setjmp/*.c",
 | 
			
		||||
			"./core/setjmp/*.e",
 | 
			
		||||
			"./core/stdlib/*.c",
 | 
			
		||||
			"./core/stdio/*.c",
 | 
			
		||||
			"./core/string/*.c",
 | 
			
		||||
			"./core/time/*.c",
 | 
			
		||||
			"./sys/exit/*.c",
 | 
			
		||||
			"./sys/malloc/*.c",
 | 
			
		||||
			"./sys/misc/*.c",
 | 
			
		||||
			"./sys/stdio/*.c",
 | 
			
		||||
			"./core/ctype/tolower.c",
 | 
			
		||||
			"./core/ctype/toupper.c",
 | 
			
		||||
			"./core/errno/errlist.c",
 | 
			
		||||
			"./core/errno/perror.c",
 | 
			
		||||
			"./core/errno/strerror.c",
 | 
			
		||||
			"./core/locale/localeconv.c",
 | 
			
		||||
			"./core/locale/setlocale.c",
 | 
			
		||||
			"./core/math/asin.c",
 | 
			
		||||
			"./core/math/atan2.c",
 | 
			
		||||
			"./core/math/atan.c",
 | 
			
		||||
			"./core/math/ceil.c",
 | 
			
		||||
			"./core/math/exp.c",
 | 
			
		||||
			"./core/math/fabs.c",
 | 
			
		||||
			"./core/math/floor.c",
 | 
			
		||||
			"./core/math/fmod.c",
 | 
			
		||||
			"./core/math/frexp.e",
 | 
			
		||||
			"./core/math/hugeval.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
 | 
			
		||||
		deps = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,9 +11,38 @@ local function addheader(dir, list)
 | 
			
		|||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
addheader("", filenamesof("./*.h"))
 | 
			
		||||
addheader("sys/", filenamesof("./sys/*.h"))
 | 
			
		||||
addheader("ack/", filenamesof("./ack/*.h"))
 | 
			
		||||
addheader("", filenamesof(
 | 
			
		||||
		"./assert.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 {
 | 
			
		||||
	name = "headers",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,6 +18,7 @@
 | 
			
		|||
#include	<alloc.h>
 | 
			
		||||
#include	<em_arith.h>
 | 
			
		||||
#include	<em_label.h>
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include 	"parameters.h"
 | 
			
		||||
#include	"idf.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,10 @@ llgen {
 | 
			
		|||
	srcs = {
 | 
			
		||||
		-- order here is important
 | 
			
		||||
		"+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 {
 | 
			
		||||
	name = "next_c",
 | 
			
		||||
	ins = {
 | 
			
		||||
		"./make.next",
 | 
			
		||||
		"./*.xh",
 | 
			
		||||
		"./*.xc",
 | 
			
		||||
	},
 | 
			
		||||
	outleaves = { "next.c" },
 | 
			
		||||
	commands = {
 | 
			
		||||
| 
						 | 
				
			
			@ -94,22 +65,39 @@ tabgen {
 | 
			
		|||
cprogram {
 | 
			
		||||
	name = "em_m2",
 | 
			
		||||
	srcs = {
 | 
			
		||||
		"./*.c",
 | 
			
		||||
		"+casestat_c",
 | 
			
		||||
		"+next_c",
 | 
			
		||||
		"+scope_c",
 | 
			
		||||
		"+symbol2str_c",
 | 
			
		||||
		"+tmpvar_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$"),
 | 
			
		||||
	},
 | 
			
		||||
	deps = {
 | 
			
		||||
		"+def_h",
 | 
			
		||||
		"+llgen",
 | 
			
		||||
		"+node_h",
 | 
			
		||||
		"+parameters_h",
 | 
			
		||||
		"+real_h",
 | 
			
		||||
		"+type_h",
 | 
			
		||||
		"h+emheaders",
 | 
			
		||||
		"lang/m2/include+headers",
 | 
			
		||||
		"modules+headers",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,6 +19,7 @@
 | 
			
		|||
#include 	"parameters.h"
 | 
			
		||||
#include	"debug.h"
 | 
			
		||||
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include	<assert.h>
 | 
			
		||||
#include	"em_label.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 *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	"debug.h"
 | 
			
		||||
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include	<assert.h>
 | 
			
		||||
#include	"em_arith.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)
 | 
			
		||||
| 
						 | 
				
			
			@ -150,4 +151,4 @@ struct def * DefineLocalModule(struct idf *id);
 | 
			
		|||
void CheckWithDef(register struct def *df, struct type *tp);
 | 
			
		||||
void end_definition_list(register struct def **pdf);
 | 
			
		||||
 | 
			
		||||
#endif /* DEF_H_ */
 | 
			
		||||
#endif /* DEF_H_ */
 | 
			
		||||
| 
						 | 
				
			
			@ -19,6 +19,7 @@
 | 
			
		|||
#include	"parameters.h"
 | 
			
		||||
#include	"debug.h"
 | 
			
		||||
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include	<assert.h>
 | 
			
		||||
#include	"em_arith.h"
 | 
			
		||||
#include	"em_label.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,6 +23,7 @@
 | 
			
		|||
#include	<varargs.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include	<system.h>
 | 
			
		||||
#include	<em_arith.h>
 | 
			
		||||
#include	<em_label.h>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,6 +15,7 @@
 | 
			
		|||
#include	<em_arith.h>
 | 
			
		||||
#include	<em_label.h>
 | 
			
		||||
#include	<assert.h>
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include	"lookup.h"
 | 
			
		||||
#include	"LLlex.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,6 +13,7 @@
 | 
			
		|||
#include	"debug.h"
 | 
			
		||||
 | 
			
		||||
#include	<assert.h>
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include	"system.h"
 | 
			
		||||
#include	"em_arith.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	<alloc.h>
 | 
			
		||||
#include	<system.h>
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include	"LLlex.h"
 | 
			
		||||
#include	"def.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -52,9 +52,8 @@ struct node {
 | 
			
		|||
#define nd_RVAL		nd_token.TOK_RVAL
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* ALLOCDEF "node" 50 */
 | 
			
		||||
#define	new_node() ((struct node*) calloc(1, sizeof(struct node)))
 | 
			
		||||
#define	free_node(p) free(p)
 | 
			
		||||
 | 
			
		||||
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 PNodeCrash(struct node **expp, int flags);
 | 
			
		||||
 | 
			
		||||
#endif /* NODE_H_ */
 | 
			
		||||
#endif /* NODE_H_ */
 | 
			
		||||
| 
						 | 
				
			
			@ -14,6 +14,7 @@
 | 
			
		|||
#include	<em_arith.h>
 | 
			
		||||
#include	<em_label.h>
 | 
			
		||||
#include	<alloc.h>
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include	"type.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;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* 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	"debug.h"
 | 
			
		||||
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include	<assert.h>
 | 
			
		||||
#include	"alloc.h"
 | 
			
		||||
#include	"em_arith.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -31,9 +32,11 @@ struct scopelist *CurrVis, *GlobalVis;
 | 
			
		|||
extern int proclevel;
 | 
			
		||||
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;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -25,6 +25,7 @@
 | 
			
		|||
#include	<em_reg.h>
 | 
			
		||||
#include	<alloc.h>
 | 
			
		||||
#include	<assert.h>
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include	"LLlex.h"
 | 
			
		||||
#include	"def.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -32,13 +33,15 @@
 | 
			
		|||
#include	"scope.h"
 | 
			
		||||
#include	"tmpvar.h"
 | 
			
		||||
#include	"main.h"
 | 
			
		||||
#include	"tmpvar.h"
 | 
			
		||||
 | 
			
		||||
struct tmpvar {
 | 
			
		||||
	struct tmpvar	*t_next;
 | 
			
		||||
	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 */
 | 
			
		||||
			*TmpPtrs;	/* for pointer temporaries */
 | 
			
		||||
| 
						 | 
				
			
			@ -9,6 +9,7 @@
 | 
			
		|||
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include	"parameters.h"
 | 
			
		||||
#include	"tokenname.h"
 | 
			
		||||
#include	"Lpars.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,6 +12,7 @@
 | 
			
		|||
#include	"parameters.h"
 | 
			
		||||
#include	"debug.h"
 | 
			
		||||
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include	<assert.h>
 | 
			
		||||
#include	<ack_string.h>
 | 
			
		||||
#include	<alloc.h>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,8 +24,8 @@ struct paramlist {		/* structure for parameterlist of a PROCEDURE */
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
struct paramlist;
 | 
			
		||||
 | 
			
		||||
/* ALLOCDEF "paramlist" 20 */
 | 
			
		||||
#define	new_paramlist() ((struct paramlist*) calloc(1, sizeof(struct paramlist)))
 | 
			
		||||
#define	free_paramlist(p) free(p)
 | 
			
		||||
 | 
			
		||||
struct enume {
 | 
			
		||||
	struct def *en_enums;	/* Definitions of enumeration literals */
 | 
			
		||||
| 
						 | 
				
			
			@ -36,7 +36,8 @@ struct enume {
 | 
			
		|||
#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 {
 | 
			
		||||
	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
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* ALLOCDEF "subrange" 5 */
 | 
			
		||||
#define	new_subrange() ((struct subrange*) calloc(1, sizeof(struct subrange)))
 | 
			
		||||
#define	free_subrange(p) free(p)
 | 
			
		||||
 | 
			
		||||
struct array {
 | 
			
		||||
	struct type *ar_elem;	/* type of elements */
 | 
			
		||||
| 
						 | 
				
			
			@ -61,7 +63,8 @@ struct array {
 | 
			
		|||
#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 scope *rc_scope;	/* scope of this record */
 | 
			
		||||
| 
						 | 
				
			
			@ -126,7 +129,8 @@ 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 
 | 
			
		||||
	*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	"debug.h"
 | 
			
		||||
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include	<em_arith.h>
 | 
			
		||||
#include	<em_label.h>
 | 
			
		||||
#include	<assert.h>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,7 @@
 | 
			
		|||
clibrary {
 | 
			
		||||
	name = "headers",
 | 
			
		||||
	hdrs = {"./*.h"}
 | 
			
		||||
	hdrs = {
 | 
			
		||||
		"./libm2.h",
 | 
			
		||||
		"./m2_traps.h",
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,34 @@ local function addheader(dir, list)
 | 
			
		|||
	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 {
 | 
			
		||||
	name = "headers",
 | 
			
		||||
| 
						 | 
				
			
			@ -20,8 +47,47 @@ for _, plat in ipairs(vars.plats) do
 | 
			
		|||
    acklibrary {
 | 
			
		||||
        name = "lib_"..plat,
 | 
			
		||||
        srcs = {
 | 
			
		||||
			"./*.c",
 | 
			
		||||
			"./*.mod",
 | 
			
		||||
			"./absd.c",
 | 
			
		||||
			"./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",
 | 
			
		||||
			"./LtoUset.e",
 | 
			
		||||
			"./absf.e",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,10 @@ llgen {
 | 
			
		|||
	srcs = {
 | 
			
		||||
		-- order here is important
 | 
			
		||||
		"+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$", "")
 | 
			
		||||
	normalrule {
 | 
			
		||||
		name = name.."_h",
 | 
			
		||||
| 
						 | 
				
			
			@ -46,7 +57,12 @@ for _, f in ipairs(filenamesof("./*.xh")) do
 | 
			
		|||
	}
 | 
			
		||||
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$", "")
 | 
			
		||||
	normalrule {
 | 
			
		||||
		name = name.."_c",
 | 
			
		||||
| 
						 | 
				
			
			@ -65,8 +81,8 @@ normalrule {
 | 
			
		|||
	name = "next_c",
 | 
			
		||||
	ins = {
 | 
			
		||||
		"./make.next",
 | 
			
		||||
		"./*.xh",
 | 
			
		||||
		"./*.xc",
 | 
			
		||||
		xh_files,
 | 
			
		||||
		xc_files
 | 
			
		||||
	},
 | 
			
		||||
	outleaves = { "next.c" },
 | 
			
		||||
	commands = {
 | 
			
		||||
| 
						 | 
				
			
			@ -94,7 +110,31 @@ tabgen {
 | 
			
		|||
cprogram {
 | 
			
		||||
	name = "em_pc",
 | 
			
		||||
	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",
 | 
			
		||||
		"+chartab_c",
 | 
			
		||||
		"+next_c",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,9 @@
 | 
			
		|||
clibrary {
 | 
			
		||||
	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 {
 | 
			
		||||
        name = "lib_"..plat,
 | 
			
		||||
        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",
 | 
			
		||||
			"./encaps.e",
 | 
			
		||||
			"./fef.e",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -93,12 +93,12 @@ main(argc, argv)
 | 
			
		|||
	}
 | 
			
		||||
	switch (argc) {
 | 
			
		||||
	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]);
 | 
			
		||||
		ofile = argv[2];
 | 
			
		||||
		ofile_created = 1;
 | 
			
		||||
		/* 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]);
 | 
			
		||||
		break;
 | 
			
		||||
	default:fatal("Usage: %s <ack object> <riscos object>.\n", argv[0]);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
for _, plat in ipairs(vars.plats) do
 | 
			
		||||
	acklibrary {
 | 
			
		||||
		name = "lib_"..plat,
 | 
			
		||||
		srcs = { "./*.e" },
 | 
			
		||||
		srcs = { "./dummy.e", },
 | 
			
		||||
		vars = { plat = plat },
 | 
			
		||||
	}
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,12 @@
 | 
			
		|||
for _, plat in ipairs(vars.plats) do
 | 
			
		||||
	acklibrary {
 | 
			
		||||
		name = "lib_"..plat,
 | 
			
		||||
		srcs = { "./*.e" },
 | 
			
		||||
		srcs = {
 | 
			
		||||
			"./edata.e",
 | 
			
		||||
			"./em_end.e",
 | 
			
		||||
			"./end.e",
 | 
			
		||||
			"./etext.e",
 | 
			
		||||
		},
 | 
			
		||||
		vars = { plat = plat },
 | 
			
		||||
	}
 | 
			
		||||
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
 | 
			
		||||
	acklibrary {
 | 
			
		||||
		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 },
 | 
			
		||||
	}
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,12 @@
 | 
			
		|||
for _, plat in ipairs(vars.plats) do
 | 
			
		||||
	acklibrary {
 | 
			
		||||
		name = "lib_"..plat,
 | 
			
		||||
		srcs = { "./*.s" },
 | 
			
		||||
		srcs = {
 | 
			
		||||
			"./edata.s",
 | 
			
		||||
			"./em_end.s",
 | 
			
		||||
			"./end.s",
 | 
			
		||||
			"./etext.s",
 | 
			
		||||
		},
 | 
			
		||||
		vars = { plat = plat },
 | 
			
		||||
	}
 | 
			
		||||
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
 | 
			
		||||
	acklibrary {
 | 
			
		||||
		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 = {
 | 
			
		||||
			plat = plat,
 | 
			
		||||
			["+ackcflags"] = {"-Imach/i80/libem"}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,12 @@
 | 
			
		|||
for _, plat in ipairs(vars.plats) do
 | 
			
		||||
	acklibrary {
 | 
			
		||||
		name = "lib_"..plat,
 | 
			
		||||
		srcs = { "./*.s" },
 | 
			
		||||
		srcs = {
 | 
			
		||||
			"./edata.s",
 | 
			
		||||
			"./em_end.s",
 | 
			
		||||
			"./end.s",
 | 
			
		||||
			"./etext.s",
 | 
			
		||||
		},
 | 
			
		||||
		vars = { plat = plat },
 | 
			
		||||
	}
 | 
			
		||||
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) {
 | 
			
		||||
	case 1: rd_fdopen(0);
 | 
			
		||||
		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]);
 | 
			
		||||
		}
 | 
			
		||||
		output_file = argv[2];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,67 @@
 | 
			
		|||
for _, plat in ipairs(vars.plats) do
 | 
			
		||||
	acklibrary {
 | 
			
		||||
		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 },
 | 
			
		||||
	}
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,12 @@
 | 
			
		|||
for _, plat in ipairs(vars.plats) do
 | 
			
		||||
	acklibrary {
 | 
			
		||||
		name = "lib_"..plat,
 | 
			
		||||
		srcs = { "./*.s" },
 | 
			
		||||
		srcs = {
 | 
			
		||||
			"./edata.s",
 | 
			
		||||
			"./em_end.s",
 | 
			
		||||
			"./end.s",
 | 
			
		||||
			"./etext.s",
 | 
			
		||||
		},
 | 
			
		||||
		vars = { plat = plat },
 | 
			
		||||
	}
 | 
			
		||||
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) {
 | 
			
		||||
	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]);
 | 
			
		||||
		output_file = argv[2];
 | 
			
		||||
		outputfile_created = 1;
 | 
			
		||||
		/* 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]);
 | 
			
		||||
		break;
 | 
			
		||||
	default:fatal("Usage: %s <as object> <dl object>.\n", argv[0]);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,8 +2,37 @@ for _, plat in ipairs(vars.plats) do
 | 
			
		|||
	acklibrary {
 | 
			
		||||
		name = "lib_"..plat,
 | 
			
		||||
		srcs = {
 | 
			
		||||
			"./*.s", -- csb8.s
 | 
			
		||||
			"./*.c"
 | 
			
		||||
			"./aar.s",
 | 
			
		||||
			"./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 },
 | 
			
		||||
		deps = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,12 @@
 | 
			
		|||
for _, plat in ipairs(vars.plats) do
 | 
			
		||||
	acklibrary {
 | 
			
		||||
		name = "lib_"..plat,
 | 
			
		||||
		srcs = { "./*.s" },
 | 
			
		||||
		srcs = {
 | 
			
		||||
			"./edata.s",
 | 
			
		||||
			"./em_end.s",
 | 
			
		||||
			"./end.s",
 | 
			
		||||
			"./etext.s",
 | 
			
		||||
		},
 | 
			
		||||
		vars = { plat = plat },
 | 
			
		||||
	}
 | 
			
		||||
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) {
 | 
			
		||||
	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]);
 | 
			
		||||
		ofile = argv[2];
 | 
			
		||||
		ofile_created = 1;
 | 
			
		||||
		/* 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]);
 | 
			
		||||
		break;
 | 
			
		||||
	default:fatal("Usage: %s <as object> <dl object>.\n", argv[0]);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,12 +38,12 @@ main(argc, argv)
 | 
			
		|||
	program= argv[0] ;
 | 
			
		||||
	switch (argc) {
 | 
			
		||||
	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]);
 | 
			
		||||
		output_file = argv[2];
 | 
			
		||||
		output_file_created = 1;
 | 
			
		||||
		/* 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]);
 | 
			
		||||
		break;
 | 
			
		||||
	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]);
 | 
			
		||||
		exit(-1);
 | 
			
		||||
	}
 | 
			
		||||
	if (freopen(argv[1],"r",stdin)==NULL) {
 | 
			
		||||
	if (freopen(argv[1],"rb",stdin)==NULL) {
 | 
			
		||||
		perror(argv[1]);
 | 
			
		||||
		exit(-1);
 | 
			
		||||
	}
 | 
			
		||||
	if (freopen(argv[2],"w",stdout)==NULL) {
 | 
			
		||||
	if (freopen(argv[2],"wb",stdout)==NULL) {
 | 
			
		||||
		perror(argv[2]);
 | 
			
		||||
		exit(-1);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -108,7 +108,7 @@ main(argc, argv)
 | 
			
		|||
	case 3:	if (! wr_open(argv[2]))
 | 
			
		||||
			fatal("Can't write %s.\n", 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]);
 | 
			
		||||
		break;
 | 
			
		||||
	default:fatal("Usage: %s <Mantra object> <ACK object>.\n", argv[0]);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -107,7 +107,7 @@ main(argc, argv)
 | 
			
		|||
		argc-- ; argv++ ;
 | 
			
		||||
	}
 | 
			
		||||
	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]);
 | 
			
		||||
		output_file = argv[2];
 | 
			
		||||
		outputfile_created = 1;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,3 +4,16 @@ normalrule {
 | 
			
		|||
    ins = {"./mktables.lua", "./instructions.dat"},
 | 
			
		||||
    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
 | 
			
		||||
 | 
			
		||||
local definitionsfp = io.open(args[1], "w")
 | 
			
		||||
local definitionsfp = io.open(args[1], "wb")
 | 
			
		||||
for word, value in pairs(words) do
 | 
			
		||||
	definitionsfp:write("%token <y_word> OP_", tostring(value), " /* ", word, " */\n")
 | 
			
		||||
end
 | 
			
		||||
definitionsfp:close()
 | 
			
		||||
 | 
			
		||||
local tokensfp = io.open(args[2], "w")
 | 
			
		||||
local tokensfp = io.open(args[2], "wb")
 | 
			
		||||
for word, value in pairs(words) do
 | 
			
		||||
	tokensfp:write("0, OP_", value, ", 0, \"", word, "\",\n")
 | 
			
		||||
end
 | 
			
		||||
tokensfp:close()
 | 
			
		||||
 | 
			
		||||
local rulesfp = io.open(args[3], "w")
 | 
			
		||||
local rulesfp = io.open(args[3], "wb")
 | 
			
		||||
rulesfp:write("operation\n")
 | 
			
		||||
for index, insn in ipairs(insns) do
 | 
			
		||||
	if index == 1 then
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,33 @@ for _, plat in ipairs(vars.plats) do
 | 
			
		|||
	acklibrary {
 | 
			
		||||
		name = "lib_"..plat,
 | 
			
		||||
		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 },
 | 
			
		||||
		deps = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,12 @@
 | 
			
		|||
for _, plat in ipairs(vars.plats) do
 | 
			
		||||
	acklibrary {
 | 
			
		||||
		name = "lib_"..plat,
 | 
			
		||||
		srcs = { "./*.s" },
 | 
			
		||||
		srcs = {
 | 
			
		||||
			"./edata.s",
 | 
			
		||||
			"./em_end.s",
 | 
			
		||||
			"./end.s",
 | 
			
		||||
			"./etext.s",
 | 
			
		||||
		},
 | 
			
		||||
		vars = { plat = plat },
 | 
			
		||||
	}
 | 
			
		||||
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 {
 | 
			
		||||
    name = "cv",
 | 
			
		||||
    srcs = { "./*.c" },
 | 
			
		||||
    srcs = { "./cv.c" },
 | 
			
		||||
    deps = {
 | 
			
		||||
        "h+emheaders",
 | 
			
		||||
        "modules/src/object+lib",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -86,7 +86,7 @@ main(argc, argv)
 | 
			
		|||
	switch (argc) {
 | 
			
		||||
	case 1: rd_fdopen(0);
 | 
			
		||||
		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]);
 | 
			
		||||
		}
 | 
			
		||||
		output_file = argv[2];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,79 @@
 | 
			
		|||
for _, plat in ipairs(vars.plats) do
 | 
			
		||||
	acklibrary {
 | 
			
		||||
		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 },
 | 
			
		||||
	}
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,12 @@
 | 
			
		|||
for _, plat in ipairs(vars.plats) do
 | 
			
		||||
	acklibrary {
 | 
			
		||||
		name = "lib_"..plat,
 | 
			
		||||
		srcs = { "./*.s" },
 | 
			
		||||
		srcs = {
 | 
			
		||||
			"./edata.s",
 | 
			
		||||
			"./em_end.s",
 | 
			
		||||
			"./end.s",
 | 
			
		||||
			"./etext.s",
 | 
			
		||||
		},
 | 
			
		||||
		vars = { plat = plat },
 | 
			
		||||
	}
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -88,7 +88,7 @@ main(argc, argv)
 | 
			
		|||
		argc-- ; argv++ ;
 | 
			
		||||
	}
 | 
			
		||||
	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]);
 | 
			
		||||
		output_file = argv[2];
 | 
			
		||||
		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 {
 | 
			
		||||
		name = "lib_"..plat,
 | 
			
		||||
		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 },
 | 
			
		||||
		deps = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,12 @@
 | 
			
		|||
for _, plat in ipairs(vars.plats) do
 | 
			
		||||
	acklibrary {
 | 
			
		||||
		name = "lib_"..plat,
 | 
			
		||||
		srcs = { "./*.s" },
 | 
			
		||||
		srcs = {
 | 
			
		||||
			"./edata.s",
 | 
			
		||||
			"./em_end.s",
 | 
			
		||||
			"./end.s",
 | 
			
		||||
			"./etext.s",
 | 
			
		||||
		},
 | 
			
		||||
		vars = { plat = plat },
 | 
			
		||||
	}
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		
		Reference in a new issue