<p>I am looking for a reference where I can learn a reasonably systematic approach to how to specify a formal grammar for a given syntax.</p>

<p>By a "formal grammar" I mean something like a BNF description.</p>

<p>(Implicit in this question is the assumption that one can draw a meaningful distinction between "a syntax" and "a grammar".  It is my understanding that this is the case, since many different (formal) grammars can represent the same syntax.  But please correct me if my understanding is wrong.)</p>

<p>The only model I can think of for the kind of reference I'm looking for is Friedl's <a href="http://books.google.com/books/about/Mastering_regular_expressions.html?id=NYEX-Q9evKoC" rel="nofollow">book</a> on regular expressions.  Its presentation is somewhat informal, but it devotes a fair bit of space to the problem of translating a verbal description of a pattern into a formal description in the form of a regular expression.  The key is that Friedl's book is focused on the practical problem of specifying regular expressions correctly.  I am interested in the practical problem of specifying a formal grammar correctly.</p>

<p>Thanks!</p>

CC BY-SA 3.0
2011-09-12T06:38:22.643Z
I sympathise with your cause, but if it is a practical problem, why come here? ;) Try the books of Terence Parr (via antlr.org), they helped me a lot.
Raphael
CC BY-SA 3.0
2011-09-12T11:02:15.050Z
I posted in TCS because when I posted the question in SO the response was one of utter incomprehension.  I spent hours responding to comments that claimed the question did not even make sense and that grammar and syntax were the same thing...  Thanks for the pointer.
kjo
CC BY-SA 3.0
2011-09-12T16:51:12.863Z
I see how that response on SO can be frustrating. Even though, most people will not consider this kind of problem TCS (imho) because it contains (implicitly) the request for design guidelines or engineering principles. Looking into compilers and/or compiler generators is definitely a good way to go. However, if you asked "How can I show that this grammar describes that language?" you had a question in TCS; formal languages is what you want then. There, you also learn the distinction between grammars and languages and how they relate. Your "implicit assumption" is very true indeed.
Raphael
<reference-request><grammars><parsing>
Ref request: grammar specification how-to
kjo
# Ref request: grammar specification how-to

(Asked by: username_0 on 2011-09-12)

I am looking for a reference where I can learn a reasonably systematic approach to how to specify a formal grammar for a given syntax.

By a "formal grammar" I mean something like a BNF description.

(Implicit in this question is the assumption that one can draw a meaningful distinction between "a syntax" and "a grammar". It is my understanding that this is the case, since many different (formal) grammars can represent the same syntax. But please correct me if my understanding is wrong.)

The only model I can think of for the kind of reference I'm looking for is Friedl's [book](http://books.google.com/books/about/Mastering_regular_expressions.html?id=NYEX-Q9evKoC) on regular expressions. Its presentation is somewhat informal, but it devotes a fair bit of space to the problem of translating a verbal description of a pattern into a formal description in the form of a regular expression. The key is that Friedl's book is focused on the practical problem of specifying regular expressions correctly. I am interested in the practical problem of specifying a formal grammar correctly.

Thanks!

**Tags:** reference-request, grammars, parsing

> **Comments:**
> **username_1**: I sympathise with your cause, but if it is a practical problem, why come here? ;) Try the books of Terence Parr (via antlr.org), they helped me a lot.  
> **username_0**: I posted in TCS because when I posted the question in SO the response was one of utter incomprehension.  I spent hours responding to comments that claimed the question did not even make sense and that grammar and syntax were the same thing...  Thanks for the pointer.  
> **username_1**: I see how that response on SO can be frustrating. Even though, most people will not consider this kind of problem TCS (imho) because it contains (implicitly) the request for design guidelines or engineering principles. Looking into compilers and/or compiler generators is definitely a good way to go. However, if you asked "How can I show that this grammar describes that language?" you had a question in TCS; formal languages is what you want then. There, you also learn the distinction between grammars and languages and how they relate. Your "implicit assumption" is very true indeed.  

---

## 0 answers

