Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lua block parsing inside macro is not aware of being inside lua block, applying sjasmplus parsing rules (colons!) #224

Open
ped7g opened this issue Nov 24, 2023 · 1 comment
Assignees
Labels
Milestone

Comments

@ped7g
Copy link
Collaborator

ped7g commented Nov 24, 2023

v1.20.3 all platforms

when colon is used inside lua code which is defined inside macro, it doesn't work (probably the line gets split as macro parser is not sensitive to lua blocks).

Needs example, there is 7.4 in docs with colons, something similar, using same block of lua inside/outside of macro to verify the bug exists and to debug it (I'm too busy/lazy to write it now).

@ped7g ped7g added bug help wanted input from new users needed, or simple-enough tasks for new contributors labels Nov 24, 2023
@specke
Copy link

specke commented Feb 19, 2024

This is a simple example to illustrates the issue above:

		DEVICE ZXSPECTRUM48

		ORG 32768

		; three ways to detect length of a file using LUA

		; 1. direct LUA (this works)
	LUA PASS3
		local f = io.open("macro_lua.asm", "rb")
		local file_len = f:seek("end")
		f.close(f)
		print("'macro_lua.asm' is " .. file_len .. " bytes long")
	ENDLUA

		; 2. LUA inside of macro (this does not work)
	MACRO LUA.FileLength1
	LUA PASS3
		local f = io.open("macro_lua.asm", "rb")
		local file_len = f:seek("end")
		f.close(f)
		print("'macro_lua.asm' is " .. file_len .. " bytes long")
	ENDLUA
	ENDM
		; LUA.FileLength1

		; if line above is uncommented, the following error message is generated:
		; macro_lua.asm(20): error: [LUA] attempt to call a nil value (global 'seek')
		; macro_lua.asm(24): ^ emitted from here

		; 3. a temporary work around for the above problem (it works)
	MACRO LUA.FileLength2
	LUA PASS3
		local f = io.open("macro_lua.asm", "rb")
		local file_len = f.seek(f, "end")	--; explicit call to the class method avoids using colon
		f.close(f)
		print("'macro_lua.asm' is " .. file_len .. " bytes long")
	ENDLUA
	ENDM
		LUA.FileLength2

(Please note that I assume that the whole of the above snippet of code is residing in a file named macro_lua.asm).

@ped7g ped7g removed the help wanted input from new users needed, or simple-enough tasks for new contributors label Aug 29, 2024
@ped7g ped7g added this to the v1.21.0 milestone Aug 29, 2024
@ped7g ped7g self-assigned this Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants