COBOL Grammar creation

Hi All,

I’am new to Antlr and exploring and in recent few weeks got a good understanding on how to use it.

I’m trying to build grammar for COBOL programs, does anyone have ready to use COBOL grammar apart from what is available on GITHUB. On GITHUB COBOL 85 is available.

Any help is greatly appreciated.

Thyagaraju K


If you search with google / duckduckgo using
cobol ebnf
then you can find interesting resources:

VS COBOL II grammar Version 1.0.4

(I moved this to the parsing category)

Well we created and sell a commercial COBOL parser. There are open source grammars of various level of completeness / clarity / correctness

Hi Federico,

For now I need just COBOL grammar, is it possible to share it?


Thyagaraju K

Hi, well no, I am sorry, but while we have several open-source projects that particular one is a commercial project

Hi Federico,

Why, you mean you sell the COBOL parser? Then which language parser is built in?


Thyagaraju K

By built in I’m guessing you mean this one

The header shows an MIT license.

The free / open source grammars you find will probably be a good place to start – it may work fine for you. If those turn out to be insufficient and you don’t want to invest the time in making them complete enough for your project, sounds like you have a commercial option.


1 Like

Here is a COBOL 85 grammar that I created in 1995 for a contract job:

This is an LR type of grammar as opposed to an LL type grammar and should work
find with the LRSTAR parser generator

The COBOL 85 language is LR(2) if you ignore the tokens: IS and ARE. Otherwise
the language is LR(3). LRSTAR should be able to handle LR(3) but I have not tested
this grammar, yet, to see if it successfully reads using the LR(3) option.

I did test it in 1995 with an LALR(1) parser generator and it was working fine, except
for the READ statement which is LALR(2).

ANTLR may have trouble with this grammar because it is an LR style grammar (with
left recursion).

Let me know if you have any questions.

Koopa (COBOL) Parser Generator -