# BNF (Grammar) for Natural

**URL:** <https://techcommunity.softwareag.com/t/bnf-grammar-for-natural/99179>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-News-and-General-Topics\
**Created:** [December 8, 2011, 12:14pm UTC](https://techcommunity.softwareag.com/t/bnf-grammar-for-natural/99179 "2011-12-08T12:14:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Florian\_Stohr](https://avatars.discourse-cdn.com/v4/letter/f/d6d6ee/32.png) [@Florian\_Stohr](https://techcommunity.softwareag.com/u/Florian_Stohr)\
**Post date:** [December 8, 2011, 12:14pm UTC](https://techcommunity.softwareag.com/t/bnf-grammar-for-natural/99179/1 "2011-12-08T12:14:49Z")

</div>

Hi,

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  
Florian

---

<div class="post-metadata">

**Author:** ![Brian\_Johnson1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/brian_johnson1/32/163_2.png) [@Brian\_Johnson1](https://techcommunity.softwareag.com/u/Brian_Johnson1)\
**Post date:** [December 8, 2011, 5:08pm UTC](https://techcommunity.softwareag.com/t/bnf-grammar-for-natural/99179/2 "2011-12-08T17:08:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [December 9, 2011, 8:18am UTC](https://techcommunity.softwareag.com/t/bnf-grammar-for-natural/99179/3 "2011-12-09T08:18:38Z")

</div>

Here’s a related Topic with some links inside: [BNF Grammar - Adabas-Natural - Software AG Tech Community & Forums](http://tech.forums.softwareag.com/techjforum/posts/list/14018.page)

---

<div class="post-metadata">

**Author:** ![Florian\_Stohr](https://avatars.discourse-cdn.com/v4/letter/f/d6d6ee/32.png) [@Florian\_Stohr](https://techcommunity.softwareag.com/u/Florian_Stohr)\
**Post date:** [December 9, 2011, 8:56am UTC](https://techcommunity.softwareag.com/t/bnf-grammar-for-natural/99179/4 "2011-12-09T08:56:06Z")

</div>

Hi,

“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 ☹

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

---

<div class="post-metadata">

**Author:** ![Brian\_Johnson1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/brian_johnson1/32/163_2.png) [@Brian\_Johnson1](https://techcommunity.softwareag.com/u/Brian_Johnson1)\
**Post date:** [December 10, 2011, 5:25pm UTC](https://techcommunity.softwareag.com/t/bnf-grammar-for-natural/99179/5 "2011-12-10T17:25:24Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Florian\_Stohr](https://avatars.discourse-cdn.com/v4/letter/f/d6d6ee/32.png) [@Florian\_Stohr](https://techcommunity.softwareag.com/u/Florian_Stohr)\
**Post date:** [December 12, 2011, 11:57am UTC](https://techcommunity.softwareag.com/t/bnf-grammar-for-natural/99179/6 "2011-12-12T11:57:23Z")

</div>

Hi,

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 🙂

-Florian

---

<div class="post-metadata">

**Author:** ![mwessjoh](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@mwessjoh](https://techcommunity.softwareag.com/u/mwessjoh)\
**Post date:** [December 16, 2013, 8:50am UTC](https://techcommunity.softwareag.com/t/bnf-grammar-for-natural/99179/7 "2013-12-16T08:50:20Z")

</div>

> [@Florian Stöhr](#):
>
> Hi,
> 
> 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 🙂
> 
> -Florian

Hi,

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

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [December 16, 2013, 11:33am UTC](https://techcommunity.softwareag.com/t/bnf-grammar-for-natural/99179/8 "2013-12-16T11:33:39Z")

</div>

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?

Other?

steve

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:01pm UTC](https://techcommunity.softwareag.com/t/bnf-grammar-for-natural/99179/9 "2021-04-02T15:01:18Z")

</div>


