Update: Using Data::Lua 0.02 in 2021

It looks like it is a no-go and doesn’t work as expected. At least not in the way I expected it to.

To test my recently installed perl module Data::Lua I wrote a very small test just to see if I could get the data from the file I wanted.

#!/usr/bin/env perl

use strict;
use warnings;

# enable perl 5.10 features
use v5.10;

# use these modules
use Carp;
use Data::Dumper;

use Data::Lua;

# === TEST

my $vars = Data::Lua->parse_file('data/indata.lua');
print Dumper($vars);

exit;

This should simply take the LUA indata.lua file and parse it into a perl variable, $vars, as described in the perldoc for Data::Lua. Then Data::Dumper will just print the resulting data structure. Easy. It does run without any errors but it produces a huge output:

$ ./parsetest.pl | wc -l
9773494

This can’t be right? My input file is rather small. Something like 10kBytes and a total of 526 lines:

$ wc -l data/indata.lua
526 data/indata.lua

A difference of over 9.7 million lines is a tad bit too much to write of easily. Examining the output there is a lot of ‘undef’ lines. Like 9.7 million of them with some data sprinkled in between. Removing these lines makes it look like there is a chance to have the data I want.

$ ./parsetest.pl | grep -v undef | wc -l
526

Maybe. There is no way to verify if it is in somewhat correct format etc. unless I put in more time into this. And my input files will be much larger than this test file so producing 99.9% output data that will have to be filtered away before further processing isn’t good.

So in the end I will have to write my own parser. Probably not a generic one but one that solves this particular problem I’m facing. Maybe I’ll write an update on that when I get somewhere.

Using Data::Lua 0.02 in 2021

Today I ran into a small problem. I needed to parse some files with Lua data (not my choice!) into a database (generic, but think MySQL). Of course I probably could have done this using Lua directly but I didn’t want to spend more time on this than necessary so I went with what I’m most comfortable with; perl.

A quick look at CPAN and I found Data::Lua which should parse my Lua data quickly. Turning to my development system running Debian I quickly installed Lua and went to (locally, for my private user) install Inline::Lua and Data::Lua. That should do the trick. Except that I ran into 2 problem with the Data::Lua tests:

t/parse-file.t …… 1/8 error: [string "_INLINED_LUA"]:18: attempt to call a nil value (global 'setfenv')

and

t/parse.t ……….. 1/7 error: [string "_INLINED_LUA"]:3: attempt to call a nil value (global 'loadstring')

After examining this further I found out that these functions setfenv and loadstring was removed from Lua in version 5.2. My Debian system has version 5.3 (or was it 5.4?) installed as default.

Solution

To make this work I had to remove the default Lua version that was installed and replace it with and older 5.1.

# apt-get remove lua5.3 liblua5.3-dev
# apt-get install liblua5.1-0-dev lua5.1

Then I had to (force) rebuild Inline::Lua since it was built against the 5.3 libraries

$ cpan -f install Inline::Lua

After this Data::Lua passed all tests with no problems and installed smoothly. It remains to see if it solves my Lua data into a database via perl exercise.

Examining Data::Lua a bit

Looking into the single file that is Data::Lua it seems that adjusting the two available functions to for with modern Lua versions is a really easy fix. But from what I can make out it seems like that module is more or less abandoned by its’ author. Last update was in 2009 and it is version 0.02. I also see that my problem is reported as a bug over 2 years ago so I guess it is not getting any attention. Sad.

Using UltraEdit + Kick Assembler + Vice for C64 development

This a re-post of old information that I’ve previously posted somewhere back in 2018 but I wanted it here too for easy linking. It should still be valid in MacOs Big Sur and an slightly updated UltraEdit (I use Version: 16.10.0.22) as I used it as late as yesterday for programming som small stuff.

I followed the instructions at https://goatpower.org/projects-releases/sublime-package-kick-assembler-c64/ in order to set up my development system on Mac OS (High Sierra). But with one major difference. I had a fully licensed UltraEdit that I have been using since many years.

So this is how I set up the UltraEdit editor to use the compiler in a similar way to Sublime3:

1. Entered Tool Configuration and configured it as:

Command Line:

export PATH=$PATH:/Applications/VICE/X64.app/Contents/MacOS/ && export CLASSPATH=$CLASSPATH:/Applications/KickAssembler/KickAss.jar && mkdir -p bin && java cml.kickass.KickAssembler '%n%e' -log 'bin/%n_BuildLog.txt' -o 'bin/%n_Compiled.prg' -vicesymbols -showmem -symbolfiledir bin && x64 -moncommands 'bin/%n.vs' 'bin/%n_Compiled.prg'

You probably want to save the file before running the assembler:

And show the Terminal/Console for any assembler output:

2. Assigned a new hotkey for ‘User Tool 1’ in the preferences for keybindings, I picked F7.

3. Installed the following as mos6502.uew (Preferences → Display → Syntax Highlightning)

/L99"MOS6502 Assembly" Line Comment Num = 2// Block Comment On = /* Block Comment Off = */ String Chars = " File Extensions = asm
/Colors = 0,8421376,8421376,8421504,0,
/Colors Back = 16777215,16777215,16777215,16777215,16777215,
/Colors Auto Back = 1,1,1,1,1,
/Font Style = 0,0,0,0,0,
/C1"MOS6502 OpCodes" Colors = 16711680 Colors Back = 16777215 Colors Auto Back = 1 Font Style = 0
adc ahx alr anc anc2 and arr asl axs
bcc bcs beq bit bmi bne bpl bra brk bvc bvs
clc cld cli clv cmp cpx cpy
dcp dec dex dey
eor
inc inx iny isc
jmp jsr
las lax lda ldx ldy lsr
nop
ora
pha php pla plp
rla rol ror rra rti rts
sac sax sbc sbc2 sec sed sei shx shy sir slo sre sta stx sty
tas tax tay tsx txa txs tya
xaa
/C2"Registers" Colors = 255 Colors Back = 16777215 Colors Auto Back = 1 Font Style = 0
x
y
(
)
*
/C3"KickAss Directives" Colors = 33023 Colors Back = 16777215 Colors Auto Back = 1 Font Style = 0
.align .assert .byte .const .enum .error .eval .fill .for .function .if .import .macro .pc .print .pseudocommand .pseuodpc .return .struct .text .var .word
:BasicUpstart 
*Matrix *Vector
abs acos add asin asmCommandSize atan atan2 AT_ABSOLUTE AT_ABSOLUTEX AT_ABSOLUTE_Y AT_IMMEDIATE AT_INDIRECT AT_IZEROPAGEX AT_IZEROPAGEY AT_NONE author
BF_BITMAP_SINGLECOLOR BF_C64FILE BF_FLI BF_KOALA binary BLACK BNE_REL BLUE BROWN
c64 cbrt ceil copyright cos cosh CYAN
DARK_GRAY
else exp expm1
floor
get getData getMulticolorByte getPixel getSinglecolorByte getType getValue getX getY getZ GRAY GREEN
Hashtable height hypot
IEEEremainder init
JMP_IND
keys
LoadPicture LDA_ABS LDA_ABSX LDA_ABSY LDA_IMM LDA_IND LDA_IZPX LDA_IZPY LDA_ZP LDA_ZPX LDA_ZPY List LIGHT_BLUE LIGHT_GRAY LIGHT_GREEN LIGHT_RED LoadBinary location log log10 log1p
Matrix max min mod MoveMatrix
name
ORANGE
PerspectiveMatrix play pow PURPLE put
random RED remove round RotationMatrix RTS
ScaleMatrix set shuffle signum sin sinh size songs source sqrt startSong
tan tanh toDegress toRadians text
Vector
WHITE width
YELLOW
{
}
/C4"C64 Custom Regs" Colors = 32768 Colors Back = 16777215 Colors Auto Back = 1 Font Style = 0
$d000 $d001 $d002 $d003 $d004 $d005 $d006 $d007 $d008 $d009 $d00a $d00b $d00c $d00d $d00e $d00F $d010 $d011 $d012 $d013 $d014 $d015 $d016 $d017 $d018 $d019 $d01a $d01b $d01c $d01d $d01e $d01F $d020 $d021 $d022 $d023 $d024 $d025 $d026 $d027 $d028 $d029 $d02a $d02b $d02c $d02d $d02e $d400 $d401 $d402 $d403 $d404 $d405 $d406 $d407 $d408 $d409 $d40a $d40b $d40c $d40d $d40e $d40F $d410 $d411 $d412 $d413 $d414 $d415 $d416 $d417 $d418 $d419 $d41a $d41b $d41c $dc00 $dc01 $dc02 $dc03 $dc04 $dc05 $dc06 $dc07 $dc08 $dc09 $dc0a $dc0b $dc0c $dc0d $dc0e $dc0F $dd00 $dd01 $dd02 $dd03 $dd04 $dd05 $dd06 $dd07 $dd08 $dd09 $dd0a $dd0b $dd0c $dd0d $dd0e $dd0f $fffe $ffff

And that was it. Make some code in UltraEdit and hit F7 to compile and run it in Vice. Very Neat!