New plugin for syntax highlighting in Visual Studio for beebasm assembler

discuss pc<>acorn file transfer issues and the use of other utils
Post Reply
User avatar
tricky
Posts: 7694
Joined: Tue Jun 21, 2011 9:25 am
Contact:

New plugin for syntax highlighting in Visual Studio for beebasm assembler

Post by tricky »

I've wanted to make a plugin for visual studio that understands the beebasm flavour of 6502 assembler for the BBC Micro.
Why Visual Studio when there is already great support in VSCode, well, I don't use VSCode but am in Visual Studio all day and most evenings :)
In the old days, it meant writing literally thousands of lines of C++ using mostly barely documented APIs, the C# route was much easier, but see above argument replacing C/C++ and C# :)
Now, since 2017 I think, you can just make a textmate grammar for the language and magically you have syntax highlighting, well, just is a bit of a simplification.
Every use of textmate I could find uses a different regex engine behind the scenes and every engine and version have different features and restrictions.

Visual Studio supports two of these flavours, XML and json. Everything I tried in XML was either unsupported or worked as expected but the killer feature lookbehinds with unlimited string lengths appears to be unsupported, at least according to Visual Studio. json is a right mess, it seems to have the best support of all of the flavours and looks like it uses the C# regex engine, but who knows. So, what is wrong with that! It either doesn't work properly or I am not understanding some fundamentals. I have tried some of the simple things that don't work and they work in all engines that have explorers including the C# one.
For the last week, I've been playing, trying to first of all, learn the basics of regex (I'd never written any before) as well as battling the VS implementation that doesn't match any of the online browsers and has no help in visual studio; I probably just need another plugin!

So, what I have is what I wrote yesterday after I stopped trying to do the fancy things and just went back to basics.
It syntax highlights assembler mnemonics, beebasm keyworks and if labels or variables are on the same line as their uses, each will be coloured as such.
It tries to highlight the X and Ys in mnemonics as I find I am often looking for them and supports comments and strings.
I'm going to start using it now as see if I like it or now and what other features I would like.

I know not many if anyone here uses Visual Studio as their editor but I have attached the VSIX installer, zipped as VSIX files cannot be attached. If you are just curious, you can open the .VSIX file with 7zi por your favourite zip file browser and copy the files out as they can just be copied manually.

If you know how to make the "labels" and "variables" patterns work across multiple lines I would love to know. The docs say to use begin and end, but then the regex doesn't work, at least the ways that I have tried it.
The later "asm" patterns seem to be unreliable and sometimes highlight the wrong parts of the instruction.

One powerful feature that gets in the way a bit is that you specify colours by a hierarchy of syntax names which are then looked up using some combination of styles you supply which seem to be global and built in styles and finally through the fonts and colours dialog; so about 4 layers of indirection!

I will be doing more work on this, but maybe not for a couple of weeks by which time, I will have forgotten how the regex worked as it seems to be write only and isn't helped by specifying it in json meaning that some characters need escaping twice!
Attachments
beeb_asm.vsix.zip
(4.68 KiB) Downloaded 15 times
cmorley
Posts: 1867
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: New plugin for syntax highlighting in Visual Studio for beebasm assembler

Post by cmorley »

I use VS not VS code. For BeebASM I'd been using Notepad++ as I have a highlighter/syntax setup for that then switching windows back to VS to run the makefiles. So +1 thumbs up for a VS syntax highlighter :)
User avatar
lovebug
Posts: 1739
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: New plugin for syntax highlighting in Visual Studio for beebasm assembler

Post by lovebug »

@tricky amazing, well done :+1: :+1: :+1: :+1: :+1:


also I didn't realize that visual studio code (im on linux) supported beebasm highlighting, thanks :+1: :+1: :+1: :+1: :+1:
Image Image Image Image
Post Reply

Return to “software & utilities for the pc, mac or unix”