BNF (Grammar) for Natural


I know you can extract this with lots of work from the documentation, but did anyone actually write a real parser (ideally lex/yacc resp. flex/bison) for Natural? I know this CoCoLab thing, but I need it for a 4.x version and cannot rely on a closed-source external library here.

No, any other tool will NOT do, we have to create software that rewrites Natural programs, therefore, I need a real parser.

Thank your for any hints

Actually, the documentation doesn’t provide a lot of what you need to know how the code is interpreted in object form. For that, you need proprietary inside knowledge about what the Natural compiler does. That’s why you find ex-SAG people forming companies that attempt to do this very thing.

Since I am not sure if there is a legal or ethical way you can snag such a person, I am afraid you’re out of luck.

Here’s a related Topic with some links inside: BNF Grammar - Adabas-Natural - Software AG Tech Community & Forums


“interpreted in object form”? No that’s not what I need, I’ll not write an alternate interpreter for it, I just need to identify some statements in the Natural code which I can rewrite programmatically, and therefore I need to have the grammar. I just need a precise/complete language specification and this IS of course public as any Natural programmer uses it - but it’s documented in pieces, and I just hoped that perpahs someone already did this work and has it around. It can be figured out from the existing documentation (look for example at “DEFINE CLASS” (that’s right now open on my desk) in the docs - there you get such a grammar piece). But it’s a painful, time-wasting job :frowning:

@Matthias - Yes I’ve read this thread already, thanks anyway

Guess I am not sure what you mean, then. By re-write Natural programs, my assumption is you want to have it generate code in another language (i.e., Java) in which case you not only have to know what the syntax is but how it’s interpreted. Perhaps that’s not your intention?


no, that’s not my intention.
I write a program (in this case in C#, but that doesn’t really matter) which reads Natural sourcecode, modifies it, and writes the modifed Natural sourcecode back. Must output valid Natural of course :slight_smile:



that’s sounds intressting.
Correct me, when I’m wrong.

You want to “parse” Natural-Sourcen and build a AST. Do some refactoring on the AST and write it back as Natural.

Have you finished your projekt?

Best regards,

Markus Wessjohann

Hi Florian;

Just out of curiosity;

Is (are) the objective(s) of your project:

More efficient Natural code?

More readable Natural code?

More easily maintained Natural code?

More platform independent code?