cortav  Check-in [f673b2abfe]

Overview
Comment:add workaround for broken luac
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f673b2abfe779c4bba7a493076762d965be8cbc0817f250604ac2ef7fd3b988b
User & Date: lexi on 2022-12-14 08:43:47
Other Links: manifest | tags
Context
2022-12-14
08:54
fix some bugs in luac.lua check-in: 72cb09e451 user: lexi tags: trunk
08:43
add workaround for broken luac check-in: f673b2abfe user: lexi tags: trunk
2022-09-30
21:15
beginning to hack in fixes to the hideously broken refid resolver check-in: c50482b020 user: lexi tags: trunk
Changes

Modified cortav.ct from [607ec9b33c] to [e74ca97d6f].

578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
...
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
*** [`narrative]
*** [`screenplay]: uses asides to denote actions, quotes for dialogue
*** [`stageplay]: uses asides to denote actions, quotes for dialogue
*** [`manual]
*** [`glossary]
*** [`news]
*** [`book]: section depths 1-3 gain additional semantics
***: [*part]: the section gets a page to itself to announce the beginning of a new part or appendix
***: [*chapter]: the section is preceded by a page break
***: [*heading]: the section can occur on the same page as text and  headings from other sections
** {d pragma accent} specifies an accent hue (in degrees around the color wheel) for renderers which support colorized output
** {d pragma accent-spread} is a factor that controls the "spread" of hues used in the document. if 0, only the accent color will be used; if larger, other hues will be used in addition to the primary accent color.
** {d pragma dark-on-light on\|off} controls whether the color scheme used should be light-on-dark or dark-on-light
** {d pragma page-width} indicates how wide the pages should be
** {d pragma title-page} specifies a section to use as a title page, for renderer backends that support pagination
................................................................................
the following excerpts of text were recovered from a partially erased hard drive found in the Hawthorne manor in the weeks after the Incident. context is unknown.

> —spoke to the man under the bridge again, the one who likes to bite the heads off the fish, and he suggested i take a brief sabbatical and journey to the Wandering Oak (where all paths meet) in search of inspiration and the forsaken sword of Pirate Queen Granuaile. a capital idea! i shall depart upon the morrow, having honored the Lord Odin and poisoned my accursed minstrels as is tradition—
> —can't smell my soul anymore, but that's beside the point entirely—
> —that second moon (always have wondered why nobody else seems to notice the damn fool thing except on Michaelmas day). alas, my luck did not endure, and i was soon to find myself knee-deep in—
> —just have to see about that, won't we!—

the nearest surviving relative of Lord Hawthorne is believed to be a wandering beggar with a small pet meerkat who sells cursed wooden trinkets to unwary children. she will not be contacted, as the officers of the Yard fear her.
~~~

~~~links & notes #lnr [cortav] ~~~
this sentence contains a [>zombo link] to zombo com. you can do anything[^any] at zombo com.
	zombo: https://zombo.com
	any: anything you want
~~~







|







 







|







578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
...
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
*** [`narrative]
*** [`screenplay]: uses asides to denote actions, quotes for dialogue
*** [`stageplay]: uses asides to denote actions, quotes for dialogue
*** [`manual]
*** [`glossary]
*** [`news]
*** [`book]: section depths 1-3 gain additional semantics
***: [*part]: the section gets a page to itself to announce the beginning of a new part or appendix. the first part is treated as the title page.
***: [*chapter]: the section is preceded by a page break
***: [*heading]: the section can occur on the same page as text and  headings from other sections
** {d pragma accent} specifies an accent hue (in degrees around the color wheel) for renderers which support colorized output
** {d pragma accent-spread} is a factor that controls the "spread" of hues used in the document. if 0, only the accent color will be used; if larger, other hues will be used in addition to the primary accent color.
** {d pragma dark-on-light on\|off} controls whether the color scheme used should be light-on-dark or dark-on-light
** {d pragma page-width} indicates how wide the pages should be
** {d pragma title-page} specifies a section to use as a title page, for renderer backends that support pagination
................................................................................
the following excerpts of text were recovered from a partially erased hard drive found in the Hawthorne manor in the weeks after the Incident. context is unknown.

> —spoke to the man under the bridge again, the one who likes to bite the heads off the fish, and he suggested i take a brief sabbatical and journey to the Wandering Oak (where all paths meet) in search of inspiration and the forsaken sword of Pirate Queen Granuaile. a capital idea! i shall depart upon the morrow, having honored the Lord Odin and poisoned my accursed minstrels as is tradition—
> —can't smell my soul anymore, but that's beside the point entirely—
> —that second moon (always have wondered why nobody else seems to notice the damn fool thing except on Michaelmas day). alas, my luck did not endure, and i was soon to find myself knee-deep in—
> —just have to see about that, won't we!—

the nearest surviving relative of Lord Hawthorne is believed to be a wandering beggar with a small slow loris for a pet who sells cursed wooden trinkets to unwary children. she will not be contacted, as the officers of the Yard fear her.
~~~

~~~links & notes #lnr [cortav] ~~~
this sentence contains a [>zombo link] to zombo com. you can do anything[^any] at zombo com.
	zombo: https://zombo.com
	any: anything you want
~~~

Modified cortav.lua from [49893a127f] to [1054336dd5].

158
159
160
161
162
163
164





165
166
167
168





169
170
171
172
173
174
175
...
221
222
223
224
225
226
227

228
229
230
231
232
233
234
...
355
356
357
358
359
360
361

362
363
364
365
366
367
368
....
1004
1005
1006
1007
1008
1009
1010





























1011
1012
1013
1014
1015
1016
1017
				if not id:find'%.' then
					if sec then
						local rid = sec.refs[id]
						if rid then
							return rid, id, sec
						end
					end






					if doc.sections[id] then
						return nil, id, doc.sections[id]
					end





				else
					local secid, ref = string.match(id, "(.-)%.(.+)")
					local s
					s = s or doc.sections[secid]
					if s then
						if s.refs[ref] then
							return s.refs[ref], ref, s
................................................................................
}

ct.sec = declare {
	ident = 'section';
	mk = function() return {
		blocks = {};
		refs = {};

		depth = 0;
		kind = 'ordinary';
	} end;
	construct = function(self, id, depth)
		self.id = id
		self.depth = depth or self.depth
	end;
................................................................................
			nctx.line = ctx.line
			nctx.docDepth = (ctx.docDepth or 0) + ctx.sec.depth - 1
			return newdoc, nctx
		end;
	};
	mk = function(...) return {
		sections = {};

		secorder = {};
		embed = {};
		meta = {};
		vars = {};
		parents = {...};
		ext = {
			inhibit = {};
................................................................................
ct.directives = {
	author = dsetmeta;
	license = dsetmeta;
	keywords = dsetmeta;
	desc = dsetmeta;
	when = dcond;
	unless = dcond;





























	pragma = function(w,c)
	end;
	lang = function(w,c)
		local _, op, l = w(2)
		local langstack = c.doc.stage.langstack
		if op == 'is' then
			langstack[math.max(1, #langstack)] = l







>
>
>
>
>




>
>
>
>
>







 







>







 







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
...
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
...
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
....
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
				if not id:find'%.' then
					if sec then
						local rid = sec.refs[id]
						if rid then
							return rid, id, sec
						end
					end

					for _, i in ipairs(sec.imports) do
						local rr, ri, rs = checkFromSec(i, doc)
						if ri then return rr, ri, rs end
					end

					if doc.sections[id] then
						return nil, id, doc.sections[id]
					end

					for _, i in ipairs(doc.globals) do
						local rr, ri, rs = checkFromSec(i, doc)
						if ri then return rr, ri, rs end
					end
				else
					local secid, ref = string.match(id, "(.-)%.(.+)")
					local s
					s = s or doc.sections[secid]
					if s then
						if s.refs[ref] then
							return s.refs[ref], ref, s
................................................................................
}

ct.sec = declare {
	ident = 'section';
	mk = function() return {
		blocks = {};
		refs = {};
		imports = {};
		depth = 0;
		kind = 'ordinary';
	} end;
	construct = function(self, id, depth)
		self.id = id
		self.depth = depth or self.depth
	end;
................................................................................
			nctx.line = ctx.line
			nctx.docDepth = (ctx.docDepth or 0) + ctx.sec.depth - 1
			return newdoc, nctx
		end;
	};
	mk = function(...) return {
		sections = {};
		globals = {};
		secorder = {};
		embed = {};
		meta = {};
		vars = {};
		parents = {...};
		ext = {
			inhibit = {};
................................................................................
ct.directives = {
	author = dsetmeta;
	license = dsetmeta;
	keywords = dsetmeta;
	desc = dsetmeta;
	when = dcond;
	unless = dcond;
	with = function(w,c)
		local _,str = w(2)
		local aka, name = str:match '^([^=])=(.*)$'
		if aka == nil then name=str aka=name end

		local o,id,s = c:ref(name)
		if o then -- import object
			c.sec.import.objs[aka] = o
		else -- import scope
			table.insert(c.sec.import.scope, s)
		end
	end;
	global = function(w,c)
		local _,str = w(2)
		if str ~= nil and str ~= '' then
			local aka, name = str:match '^([^=])=(.*)$'
			if aka == nil then name=str aka=name end

			local o,id,s = c:ref(name)

			if o then
				c.doc.globals.objs[aka] = name
			else
				table.insert(c.doc.globals, s)
			end
		else
			table.insert(c.doc.globals, c.sec)
		end
	end;
	pragma = function(w,c)
	end;
	lang = function(w,c)
		local _, op, l = w(2)
		local langstack = c.doc.stage.langstack
		if op == 'is' then
			langstack[math.max(1, #langstack)] = l

Modified ext/transmogrify.lua from [b92020d7d8] to [3dcf8ba97f].

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
			['--->'] = '⟶';
			['<---'] = '⟵';
			['----'] = '⸻';
      };

		{
			['<==>'] = '⟺';
			['===>'] = '';
			['<==='] = '⟸';
		};

		{
			['<->'] = '↔';
			['-->'] = '→';
			['<--'] = '←';







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
			['--->'] = '⟶';
			['<---'] = '⟵';
			['----'] = '⸻';
      };

		{
			['<==>'] = '⟺';
			['===>'] = '';
			['<==='] = '⟸';
		};

		{
			['<->'] = '↔';
			['-->'] = '→';
			['<--'] = '←';

Modified makefile from [97fc0b1491] to [a11f003028].

57
58
59
60
61
62
63
64
65
66



67
68
69
70
71
72
73
..
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
...
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
lua-standalone = $(if $(lua-lib-prefix),$(lua-lib-prefix)/liblua.a,-llua)
lua-bindeps = -lm -ldl

ifneq ($(filter net,$(binds-names)),)
    lua-bindeps += -lcurl
endif

dbg-flags-luac = $(if $(debug),,-s)
dbg-flags-cc = $(if $(debug),-g,-s)





# by default, we fetch and parse information about encodings we
# support so that cortav can do fancy things like format math
# equations by character class (e.g. italicizing variables)
# this is not necessary for parsing the format, and can be
# disabled by blanking the encoding-data list when building
# ($ make encoding-data=)
................................................................................
	cat $< >>$@
	chmod +x $@

# raw bytecode without shebang header, must be run as `lua cortav.lc`
$(build)/$(executable).lc: sirsem.lua $(encoding-files) cortav.lua $(rendrs) $(extens) cli.lua | $(build)/
	@echo ' » building with extensions $(extens-names)'
	@echo ' » building with renderers $(rendrs-names)'
	$(luac) $(dbg-flags-luac) -o $@ $^

# true standalone binary, wraps bytecode file and (optionally) lua
$(build)/$(executable).bin: $(build)/$(executable).lc tool/makeshim.lua $(binds)
	$(lua) tool/makeshim.lua $< "" $(binds-names) |\
		$(CC) -s -o$@ -xc - -xnone $(binds) $(lua-standalone) $(lua-bindeps)

# loadable lua modules for binds, mainly useful for testing
................................................................................

%/:
	mkdir -p $@

$(build)/unicode.txt: | $(build)/
	curl $(encoding-data-ucs-url) > $@
$(build)/ucstbls.lc: $(encoding-data-ucs) tool/ucs.lua | $(build)/
	$(lua) tool/ucs.lua $< | $(luac) -o $@ -

.PHONY: install
install: $(build)/cortav $(build)/cortav-view.sh $(build)/velartrill-cortav-view.desktop | $(bin-prefix)/
	install $(build)/$(executable)  $(bin-prefix)
	install $(build)/cortav-view.sh $(bin-prefix)
	xdg-mime         install desk/velartrill-cortav.xml
	xdg-desktop-menu install $(build)/velartrill-cortav-view.desktop







|
|
<
>
>
>







 







|







 







|







57
58
59
60
61
62
63
64
65

66
67
68
69
70
71
72
73
74
75
..
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
...
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
lua-standalone = $(if $(lua-lib-prefix),$(lua-lib-prefix)/liblua.a,-llua)
lua-bindeps = -lm -ldl

ifneq ($(filter net,$(binds-names)),)
    lua-bindeps += -lcurl
endif

ifneq (luac-broken,)
    comp-lua = $(if $(debug),,env strip=1) $(lua) tool/luac.lua $1 $(if $2,>$2)

else
    comp-lua = $(luac) $(if $(debug),,-s) -o $(if $2,$2,-) $1
endif

# by default, we fetch and parse information about encodings we
# support so that cortav can do fancy things like format math
# equations by character class (e.g. italicizing variables)
# this is not necessary for parsing the format, and can be
# disabled by blanking the encoding-data list when building
# ($ make encoding-data=)
................................................................................
	cat $< >>$@
	chmod +x $@

# raw bytecode without shebang header, must be run as `lua cortav.lc`
$(build)/$(executable).lc: sirsem.lua $(encoding-files) cortav.lua $(rendrs) $(extens) cli.lua | $(build)/
	@echo ' » building with extensions $(extens-names)'
	@echo ' » building with renderers $(rendrs-names)'
	$(call comp-lua,$^,$@)

# true standalone binary, wraps bytecode file and (optionally) lua
$(build)/$(executable).bin: $(build)/$(executable).lc tool/makeshim.lua $(binds)
	$(lua) tool/makeshim.lua $< "" $(binds-names) |\
		$(CC) -s -o$@ -xc - -xnone $(binds) $(lua-standalone) $(lua-bindeps)

# loadable lua modules for binds, mainly useful for testing
................................................................................

%/:
	mkdir -p $@

$(build)/unicode.txt: | $(build)/
	curl $(encoding-data-ucs-url) > $@
$(build)/ucstbls.lc: $(encoding-data-ucs) tool/ucs.lua | $(build)/
	$(lua) tool/ucs.lua $< >$@

.PHONY: install
install: $(build)/cortav $(build)/cortav-view.sh $(build)/velartrill-cortav-view.desktop | $(bin-prefix)/
	install $(build)/$(executable)  $(bin-prefix)
	install $(build)/cortav-view.sh $(bin-prefix)
	xdg-mime         install desk/velartrill-cortav.xml
	xdg-desktop-menu install $(build)/velartrill-cortav-view.desktop

Added tool/luac.lua version [e99572ed87].











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
-- luac is broken in some distributions, and cannot take more than one
-- argument without crashing on a double free or similar. this
-- completely breaks the cortav build process, so we supply our own
-- ultra-simplistic and painfully primitive luac replacement.
-- this does not generate very good object code.
-- pass luac-broken=1 when building to use
local pgm = ""
local strip = os.getenv("strip")=="1"
if #arg > 1 then
	local chunks = {}
	for i, f in ipairs(arg) do
		local nc = assert(loadfile(f))
		nc = string.format("load%q(...)", string.dump(nc))
		table.insert(chunks, nc)
	end
	pgm = assert(string.dump(load(table.concat(chunks))))
else
	pgm = assert(string.dump(loadfile(arg[1])))
end

io.stdout:write(pgm)

Modified tool/ucs.lua from [cf6aee3c65] to [ccdca620ac].

151
152
153
154
155
156
157
158

local tab = {}
local top = 1
for k,v in pairs(ranges) do
	tab[top] = string.format('{0x%x,0x%x,%u}',table.unpack(v))
	top = top + 1
end
io.stdout:write(string.format(tpl, table.concat(tab,',\n')))







|
151
152
153
154
155
156
157
158

local tab = {}
local top = 1
for k,v in pairs(ranges) do
	tab[top] = string.format('{0x%x,0x%x,%u}',table.unpack(v))
	top = top + 1
end
io.stdout:write(string.dump(load(string.format(tpl, table.concat(tab,',\n')))))