Tads3 formal grammar

Is there a formal grammar or similar for the tads3 language available somewhere? (Not the std lib but for the compiler itself).

I can’t be 100% sure, but I don’t think anyone has ever made one.

I was suspecting as much.

I’ve been trying to create an Antlr grammar for the language in order to provide a platform for creating language tools such as outliners, code assisting etc. It’s a little challenging to get the grammar right though, so I was hoping for some kind of guideline when it comes to the most intricate details of the language.

But now when I think about it I wonder if somehow exporting the complete AST with the help of the original source code might be a shorter route to the same result. Not entirely sure that’s any easier though.

Or maybe there’s already something available that could be used for this somewhere in the source.

1 Like

It’s probably gonna be complicated. The source code is parsed pretty much “by hand” (no BNF or anything like that, it’s loops, ifs, labels and gotos) and produces a parse tree where the objects of the tree act as code generators. The parser code is spread across files beginning with tcp* in the tads3 directory.

I think in the end it’s probably easier to construct a formal grammar from the language documentation rather than the source code.