Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repository of BNF Grammars?

Is there a place I can find Backus–Naur Form or BNF grammars for popular languages? Whenever I do a search I don't turn up much, but I figure they must be published somewhere. I'm most interested in seeing one for Objective-C and maybe MySQL.

like image 678
Greg Avatar asked Dec 02 '08 16:12

Greg


People also ask

What is BNF give an example?

BNF is an example of a context-free grammar that is used to describe a context-free language. Since all regular languages are context-free, you can convert every regular expression to a BNF production rule (or set of rules). However, the reverse is not true. Figure 1: Venn diagram: context-free and regular languages.

What is BNF parser?

The BNF parser generator takes a syntax not unlike BNF and generates a "C" parser for it, a parser that can parse either strings or files. This is a flexible tool, ment for smaller parsing tasks where bison+flex are just to big to use. grammar: BNF input grammar.

How is BNF related to context free grammar?

As for a context free grammar, a BNF grammar has a finite set of terminal symbols, a finite set of nonterminal symbols, a start symbol (one of the nonterminal symbols), and a finite set of rules.

Is BNF a CFG?

BNF stands for Backus Naur Form notation. It is a formal method for describing the syntax of programming language which is understood as Backus Naur Formas introduced by John Bakus and Peter Naur in 1960. BNF and CFG (Context Free Grammar) were nearly identical.

What is a BNF grammar and why is it useful?

It’s useful to be able to read BNF grammars because they’re very common in computer science and programming. Many specification documents use BNF to define languages, including programming languages, configuration files, and even network packet formats. Any context-free language can be described using a BNF grammar.

What is the BNF grammar for SH61?

The input language for sh61 command lines is described in terms of a BNF grammar, where BNF stands for Backus–Naur Form, or Backus Normal Form. BNF is a declarative notation for describing a language, meaning simply a set of strings. BNF notation is built from: Terminals, such as "x", which must exactly match characters in the input.

What is the BNF representation of lists?

The BNF representation of lists is right-recursive, following the list conctructor in Haskell and most other languages. Right-recursive lists, however, are an inefficient way of parsing lists in an LALR parser, because they can blow up the stack size.

What is the BNF converter?

This document defines the grammar formalism Labelled BNF (LBNF), which is used in the compiler construction tool BNF Converter. Given a grammar written in LBNF, the BNF Converter produces a complete compiler front end (up to, but excluding, type checking), i.e. a lexer, a parser, and an abstract syntax definition.


2 Answers

you have to search on tools used to create grammars: "lex/yacc grammar", "antlr grammar" "railroad diagram"

http://www.antlr3.org/grammar/list.html

Here's some grammar files

objective-c

  • http://www.omnigroup.com/mailman/archive/macosx-dev/2001-March/022979.html

  • http://www.cilinder.be/docs/next/NeXTStep/3.3/nd/Concepts/ObjectiveC/B_Grammar/Grammar.htmld/index.html

  • https://github.com/pornel/objc2grammar

python

  • http://www.python.org/dev/summary/2006-04-16_2006-04-30/#the-grammar-file-and-syntaxerrors

javascript

  • http://tomcopeland.blogs.com/EcmaScript.html

  • http://www.ccs.neu.edu/home/dherman/javascript/

ruby

  • http://www.ruby-doc.org/docs/ruby-doc-bundle/Manual/man-1.4/yacc.html
like image 151
Gene T Avatar answered Sep 18 '22 15:09

Gene T


FWIW, the MySQL grammar file (mysql-server/sql/sql_yacc.y) is open source and browseable at launchpad.net (though it's a bit slow and I got an error when I tried to pull up the specific file).

Also, a snapshot of the whole MySQL Server source is downloadable from dev.mysql.com.

like image 42
Bill Karwin Avatar answered Sep 21 '22 15:09

Bill Karwin