publicvoit, to programming
@publicvoit@graz.social avatar

What happens, when you join two paths in a language when the second one is an absolute one?

join("foo", "/bar")
returns "foo/bar" or "/bar"?

The wonderful @meisterluk wrote a great article about that you might want to read: https://lukas-prokop.at/articles/2024-05-03-filepath-join-behavior

I can not tell what version I'd actually prefer. There are situations where both versions would be "proper".

#C++

thelastpsion, to retrogaming
@thelastpsion@bitbang.social avatar

Current projects:

▶️ #CTRAN: A drop-in FOSS replacement for CTRAN.EXE, the #Psion SIBO/EPOC16 OO C preprocessor on #DOS. Almost feature complete, but still work to do!
▶️ #ObjectPascal with #FreePascal: Used for CTRAN for easy development and portability. Honestly, I'm really enjoying it; it fits my needs and makes my brain happy.
▶️ RAM upgrade for 3mx to 4MB: Trying to source old DRAM isn't easy.
▶️ RAM upgrade for 5mx: Got the DRAM. Just need to solder it in place.

#RetroComputing

thelastpsion, to neovim
@thelastpsion@bitbang.social avatar

Thoughts on 3 months of usage (in ):

  • Easy to pick up and read
  • Good libraries
  • Generics
  • No closures
  • Binaries aren't small
  • LSP (pasls) isn't complete, but better than nothing; + really help
  • Docs are frustrating
  • Good forums/community
  • Targets SO MANY platforms (, 32-bit , , , )! More than Rust, Go
  • A lot of historic books and projects

Would I use again? Absolutely yes, without doubt.

thelastpsion, to retrogaming
@thelastpsion@bitbang.social avatar

Just tried compiling Wari, a game written in OO C. The project uses Make 3.6.

Got it to compile first time with my SIBO SDK setup - all good!

However... Borland Make uses 16-bit DPMI, and its extender won't load 32-bit DPMI binaries. If I pre-load the 32-bit extender, it won't load 16-bit DPMI binaries, so Make won't run!

TL;DR: I can't use the new with Borland Make 3.6.

Looks like I'll be converting that Makefile to GNU Make or a project.

thelastpsion,
@thelastpsion@bitbang.social avatar

Why can't I recompile #ctran for 16-bit #DOS? Because many of #FreePascal's libraries are too big to fit into 64 KiB data blocks, and won't compile no matter which memory model I use.

There is a chance I'll rewrite ctran in the future. #FreeVision (the #Borland #TurboVision "clone") with #ObjectPascal is certainly an option. I could also rewrite the lot in C or C++.

But today is not that day. For now, I'd rather just rewrite a Makefile.

#dosbox #retrocomputing

rvr, to programming
@rvr@floss.social avatar

GitHub - torokernel/ToroOS: This repository contains the source code of the Toro Operating System. https://github.com/torokernel/ToroOS/tree/master

ToroOS is an operating system programmed in FreePascal for educational purposes for x86 that supports one core. Supports POSIX and grub as bootloader.

andrew_chou, to random
@andrew_chou@toot.cafe avatar

apparently I'd rather spend an hour debugging an issue with Free Pascal's formatter than go to therapy

#FreePascal

thelastpsion, to random
@thelastpsion@bitbang.social avatar

Idle thought today re :

I wonder if it's worth making a little interface using (the -compatible library that comes with ) to display information about OO category (class definition) files?

Yes, I realise this is feature creep. But currently I'm outputting a lot of information to the terminal that the original CTRAN.EXE doesn't do. How much do I leave in as a "verbose" option, and how much to I move to a shiny TUI?

Something for another time.

thelastpsion, to random
@thelastpsion@bitbang.social avatar

Done a lot of work on #ctran tonight. In fact, I think we might have a working parser! I definitely need to check over what I've done, but it's looking promising.

I need to add more checks to make sure that tokens don't appear in files that aren't meant to have them (e.g. DECLARE should only be in .EXT files). Then I need to test that the tree is being built the way I think it is.

After that, it's time to do something with EXTERNALs and REQUIREs to make MANY trees.

thelastpsion,
@thelastpsion@bitbang.social avatar

I guess I could create a dynamic array of parser classes?

Is that something I can do in ? Is it even a good idea?

Thoughts for another time. For now, it's time to check I've pushed all my commits, and head to bed.

thelastpsion,
@thelastpsion@bitbang.social avatar

Quick update:

✅ Expose the "tree" as read-only properties, as 5 separate arrays.

I thought this was going to be awkward. won't let you create a property that is an "array of" some type. I assumed I'd have to do a load of rewriting to accommodate new custom types.

Turns out I just needed to create the new types and put them in the relevant public/private declarations. And for the three "array of string" variables, I just used TStringArray. No other changes. It Just Worked.

thelastpsion,
@thelastpsion@bitbang.social avatar

Mmm... Shiny goodness alongside shiny goodness.

Exactly the same code on both, just using 's cross-compiler for 32-bit DOS. Zero changes needed.

image/png

thelastpsion, to random
@thelastpsion@bitbang.social avatar

Musing on .

I'm starting to wonder if there's any point in having the lexer and parser as two separate classes.

Other than testing, the lexer is only ever going to be called by the parser, and only once during the process.

It might be better to just have a lexer-parser class that grabs a file, tokenises it, then (if it's happy with the file it's tokenised) immediately turns it into a tree.

Is there a really good reason why they should be separate classes?

thelastpsion,
@thelastpsion@bitbang.social avatar

About 30 lines of code later, and I can now pull lines of tokens, one by one. I've also been able to remove the generation of newline tokens, as they're no longer needed.

I didn't realise in that Result is preserved in a function! I'm having to nil one of the dynamic arrays every time, otherwise it remembers what it generated last time.

's parser has now been disabled because it relied on newlines, but that's fine. It's about to be torn apart.

ALT text explains the output.

thelastpsion, to random
@thelastpsion@bitbang.social avatar

Been thinking about #ctran and ASTs today. I've realised that I might be approaching this wrong.

#Psion OO C files are definition files. They're glorified mark-up, wrapping around snippets of C code that just gets copied to new files. There's no logic in them at all.

I basically need two arrays per file: a list of "classes" and their contents, and a list of "includes" and how they're, uh, included (EXTERNAL, INCLUDE, or REQUIRE).

It's still a tree, but it's got two distinct parts. Wonky tree.

thelastpsion,
@thelastpsion@bitbang.social avatar

Actually, I wonder if variant records would be useful for building a tree, or at least an array containing elements of different types? Need to read up on them.

thelastpsion,
@thelastpsion@bitbang.social avatar

I say "maybe", because it looks like variant records have a fixed size. If that's the case, the might not like me having a dynamic array of variant records, where some of the variant records contain dynamic arrays of AnsiStrings. Unless Free Pascal does some clever memory management in the background.

Another option is to add an "item number" variable to each record, then searching for the next one so that they're processed in order.

thelastpsion, to VintageOSes
@thelastpsion@bitbang.social avatar

Interesting... I'd assumed that #FreePascal's 16-bit #DOS cross-compiler was just ignoring the memory model I was setting. Turns out it wasn't, and I hadn't been reading the error messages properly. They're all failing for different reasons!

Surely I must be doing something wrong?

I'm struggling to find any information on issues like this, largely because hardly anyone uses it.

I might end up switching to the 32-bit DOS compiler, just to get something working.

#MSDOS #retrodev

thelastpsion,
@thelastpsion@bitbang.social avatar
thelastpsion,
@thelastpsion@bitbang.social avatar

Well, the #FreePascal community have kindly responded on the Lazarus forum, and it seems that the Classes unit just won't fit into 64K and there's no way around it.

So, we are basically where I (and others on Mastodon) thought I'd be. Either extract individual parts from the Free Pascal libraries, or roll my own solutions.

There's also Free Vision (a FOSS API-compatible replacement for Borland's Turbo Vision framework), which I've been told includes some alternative lists.

thelastpsion, to random
@thelastpsion@bitbang.social avatar

#CTRAN currently has a lot of repetitive code in the #tokeniser. I really want to refactor it so that it's both tidier and more readable. I also know that I'm going to need to reuse a lot of the tokeniser code to process #Psion's .EXT files, which are a sort of cut-down version of the class/category files.

I'm in a position where the tokeniser works well, so I think I can afford to shift things around. I think it's time to put the tokeniser in a class.

#ObjectPascal #FreePascal

thelastpsion,
@thelastpsion@bitbang.social avatar

Well, the tokeniser is now in a class and still works! Procedures and functions have been pulled in and simplified, and private things are strict private. Tidying the code will now be much easier.

Have a look at the code so far on GitHub. Feel free to critique - I know there's much to be improved, but I could have missed something.

https://github.com/PocketNerdIO/ctran

thelastpsion, to random
@thelastpsion@bitbang.social avatar

Currently trying to decide whether I should work on getting the #FreePascal 16-bit DOS cross-compiler to work with the medium memory model, or if I should just keep ploughing on with coding without really knowing if the code I'm writing works on DOS.

The cross-compiler should just work. I'm using the binaries, fpc.cfg matches the wiki, and I've checked my command line switches (-WmMedium). It sticks stubbornly with the small memory model.

thelastpsion, to random
@thelastpsion@bitbang.social avatar

#ObjectPascal can load an entire file into memory as a TStringList, automatically splitting files into separate lines.

Is that cheating? Because it feels like cheating.

I'm going to give it a try.

thelastpsion,
@thelastpsion@bitbang.social avatar

Hmm, adding uses Classes to get TStringList has made the executable even bigger. And for some reason the #FreePascal 16-bit DOS cross-compiler is stuck in small memory model, no matter what switches I provide. fpc.cfg looks right when compared to the wiki, and I have all the necessary units installed from the binary distribution.

I'll have to come back to that.

I guess if I wanted something small, I'd have written it in C from the start and rolled my own nice-to-have libraries.

thelastpsion, to random
@thelastpsion@bitbang.social avatar

"Modern #ObjectPascal Introduction for Programmers"

https://castle-engine.io/modern_pascal

Thank you to @rvr for sending me this. I've had a quick read through and it looks to be exactly what I need. Especially the section "7.2. Containers (lists, dictionaries) using generics".

#FreePascal #Pascal

louis, to random
@louis@emacs.ch avatar

Turns out that Free Pascal already has a very good HTTP server and JSON de/serialization library (with JSON<>Object serialization) as part of their stdlib.

I played around with them a bit and I'm impressed with the performance. The compiler is also amazingly fast.

Don't be fooled, Object Pascal is not a "students" language anymore. They all moved to "React" now. ;-)

#FreePascal

thelastpsion, to neovim
@thelastpsion@bitbang.social avatar

It's taken me a couple of hours to get an #LSP for #Pascal working in #NeoVim on Linux, but we're there!

I will document this (I need to do it again for the laptop), but in short:

  • Install Lazarus 3.0.0 beta
  • Get latest Lazarus trunk source
  • git clone the LSP source
  • Fix an issue with LSP source that's in an unmerged pull request
  • Build the LSP as per README
  • Set a couple of env variables
  • Copy the pasls binary to your path
  • Add zero-lsp.nvim plugin
  • enable pasls in zero-lsp config
thelastpsion,
@thelastpsion@bitbang.social avatar
thelastpsion, to retrocomputing
@thelastpsion@bitbang.social avatar

OK, the new sidequest...

I've decided to rewrite CTRAN, the OO C preprocessor from the SIBO C SDK.

In .

And this time I've actually written some code.

https://github.com/PocketNerdIO/ctran

thelastpsion,
@thelastpsion@bitbang.social avatar

#FreePascal compiles for almost everything (See the picture), including 16-bit DOS.

It's also still maintained, with an active community.

Using #ObjectPascal (which is basically what Free Pascal is), I can get the logic written for a lexer, an AST, and then a few code generators, without worrying about how I'm going to allocate memory for an array, let alone an entire tree.

thelastpsion,
@thelastpsion@bitbang.social avatar

With #FreePascal I can write code on Linux, compile it on Linux, and then cross-compile for DOS with no change to the code so that it can be used with the existing SDK.

And I have.

Test CTRAN code running inside DOSBox Staging.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • provamag3
  • thenastyranch
  • magazineikmin
  • InstantRegret
  • GTA5RPClips
  • ethstaker
  • Youngstown
  • everett
  • slotface
  • osvaldo12
  • rosin
  • mdbf
  • kavyap
  • DreamBathrooms
  • megavids
  • ngwrru68w68
  • Durango
  • modclub
  • cubers
  • khanakhh
  • Leos
  • tacticalgear
  • cisconetworking
  • vwfavf
  • tester
  • anitta
  • normalnudes
  • JUstTest
  • All magazines