Tree-sitter-hicad

Creating a grammar for a legacy programming language

Since I am not a professional software engineer, this was a challenging but fun project.

HiCAD is the CAD software we use at work. The automation tools have a API in C# already for a long time. However, there is still a lot of functionality written in a much older langage called HCGS. We have a lot of legacy code so I decided to create a few tools around it first, to at least have a bit of help when dealing with this code.

The result

Is this grammar:

tree-sitter-hicad

And a vim plugin:

nvim-hicad

Its far from perfect and has a lot of errors. But it already helped me to find dead code. You know such as:

IF TRUE GOTO 10
  WAIT This is never reached
IFEND
10: WAIT Continue here

The road

Why tooling in the first place you may think? Didn't your colleagues got it without that?

Yes and No I may say. The problem with legacy code is, that there is already something out there. Which has its purpose, it works and its much harder to touch something that is actually working, rather than defining it from scratch.

But yes it can be challenging not to go down a rabbit hole. Especially because the language itself is proprietary and there is no exact specification of it. So I was guessing a lot.

What I learned

It was my first project that I was allowed to open source while doing parts of it at work. It took some courage to ask for it, and I am greatfull that I got a "yes do it".

The grammar itself. Well as many projects: "If only I could start from scratch again". But considering this is not in my expertise, I'm actually quite proud of it.

It didn't got much attention though, but thats not what I intended. The idea is to help at work. If thats of any usecase for someone else, maybe in the future, thats fine.

I had some fun programming, even if it was JavaScript 😰