The Tower Bridge in Sacramento, California Grammar Downloads
Examples and Full Programming Languages
Latest News
Getting Started
Screen Shots
About GOLD
How It Works
Why Use GOLD?
Revision History
Freeware License
More ...
What is a Parser?
Backus-Naur Form
DFA Lexer
LALR Parsing
More ...

This page contains a collection of different grammars written in the GOLD Meta-Language. GOLD grammars are based on Backus-Naur form and regular expressions. As a result, these grammars can also be converted to other parsing systems that are based on these notations.

Each of the zip files contains both the grammar files and the parsing tables that were constructed by the GOLD Parser Builder.

Example Grammars
Hex Literals This grammar shows how to define Hex Literals in your grammar.  The formats used for C++ and Visual Basic are included
Identifiers This is a very simple example which defines a common identifier.
Numbers Besides identifiers, programming languages often contain terminals for integer and floating point literals. This grammar defines both.
Simple This is a very "simple" grammar that was used in the Visual Basic Example project. The grammar contains a few basic statements as well as the rules for basic mathematical expressions.
Version: 2
Strings One of the most common declarations used in programming languages is the "string". In this example, a character set is defined and then used to declare a standard string terminal.
Strings (C style) The C programming language uses a backslash to define special characters normally not accessible via the keyboard. This grammar shows how to define a String terminal which will accept C style strings.
Operator Precedence This grammar contains the basic rules needed to define mathematical expressions. It includes the levels of operator precedence used in common arithmetic.
Phone Number This is a very simple example that parses U.S./Canada style phone numbers.
Programming Languages
ALGOL 60 ALGOL is, by far, the most influential programming language developed to date. Although is did not achieve mass use, a large number of syntactic and semantic principles and concepts were developed and incorporated into the language.

These include: block structure, free-form structure (elements are not required to be in a specific column), pass by name and the For-Loop. As a result, ALGOL is considered the main reference language in computer science.

BASIC 64 BASIC is one of the oldest programming language and one of the most popular.  It was developed in 1964 by John G. Kemeny and Thomas E. Kurtz to teach students the basics of programming concepts.
C (ANSI) C was designed for the creation and implementation of low-level systems such as operating systems, device drivers, firmware, etc... To realize   this goal, the language contains the ability to perform operations  directly on memory and has direct access to system pointers. While this gives an enormous amount of control and flexibility, it also makes C a  professional programming language - not to be used by an inexperienced programmer.
C# Updated! C# was primarily the work of computer scientist Anders Hejlsberg who has worked on a wide range of programming languages. These include, but are not limited to, Visual J++, Borland Delphi and Turbo Pascal. His previous works and influences from Java and C++ can be seen in C#.

The goal of C# was to counter the flaws and difficulties found in Java and C++. In addition, the language was designed to work well with the Common Language Runtime which runs the Microsoft .NET platform.

The grammar was designed, in part, using the official language specification that can be found on the Microsoft website. As a result, considerable time was required to write a LALR(1) compliant version.

COBOL 85 The COBOL programming language is one of the oldest still in use today. It  was originally designed by the United States Department of defense under the supervision of the Conference on Data Systems Languages (CODASYL) Committee. Most of the groundwork and design of COBOL was done by Admiral Grace Hopper of the United States Navy.

The COBOL 85 grammar is complex - containing, on average, over 350 reserved words, 950 rules which results in 1,681 LALR states. This is the full grammar.

This version of the BASIC Programming Language was implemented on the Commodore 64. I wrote this grammar to amuse myself and to remember the fun I had on that 8-bit wonder.

Download the Commodore 64 Font!You can also download a True Type Font I created that mimics the character set of the Commodore 64. This is a new version of the font that will work for both PC and Macintosh (the old version didn't work that well).

Delphi 7 Rob van den Brink, who authored the Object Pascal Engine, created the grammar for the Delphi 7 Programming Language. Delphi was developed from the concepts and syntax of Pascal and, its successor, Object Pascal.
Author: Rob van den Brink
Version: 1.1
Date: August 2006
Java Dmitry Gazko has submitted a grammar for the Java Programming Language This grammar is based on a partial conversion of Sun Java 1.0-2.0 specification.
Author: Dmitry Gazko
JavaScript Meinhard Schnoor-Matriciani submitted this grammar for the JavaScript Programming Language. The grammar has a few shift-reduce warnings - mainly due to the classic hanging else.
Author: Meinhard Schnoor-Matriciani
LISP LISP is one of the oldest programming language in use today; second only to FORTRAN. It was invented by mathematician John McCarthy and organizes data into abstract "lists"; which are delimited by parenthesis. This metaphor is used for both data and functions and yields a degree of orthogonality not seen in most languages.
Pascal Alexander Grau submitted the grammar for the Pascal Programming Language. Pascal was developed by Niklaus Wirth of the ETH Technical Institute of Zuerich in 1970-1971.
Author: Alexander Grau
Version: 1973
Smalltalk IV The Smalltalk programming language was developed at the Xerox labs at Palo Alto in the mid 1970s. The language was built upon the object-oriented model of Simula and designed to work directly with the newly developed concept of the graphic user interface (GUI), To this day, Smalltalk is considered one of the "purest" object-oriented programming languages.
SQL 89 (ANSI) The SQL programming language was developed as a uniform means of modifying and querying relational databases. By using a single abstract language to interact with the database, programs can be written that are independent of the vender and format of the database itself.
VB Script Updated! Vladimir Morozov submitted a grammer for the Visual Basic Scripting Language - VB Script. This is a version of Microsoft Visual Basic that can be used in webpages or for scripting tasks in Windows.

Vladimir Morozov worked with Nathan Baulch on a number of updates which take into account some real-world scenaros. These include the use keywords as identifiers, the use dot in front of identifiers in WITH statements (grammar allows to use them anywhere), missed statements, parameteres for calling SUB, and much more.

Author: Vladimir Morozov
Visual Basic .NET Visual Basic .NET is the latest version in the long evoluation of the BASIC programming language. The Visual Basic .NET programming language  is far more "clean" and orthagonal than its predecessors. Although some of the old constructs exist, the language is far easier to read and write.

Only use GOLD Parser Builder version 2.1 and later to compile this grammar. Earlier versions cannot handle the complexity.

Academic Languages
Brainf#ck As legend states, the Brainf#ck Programming Language (also called BF by those not wanting to curse) was created by Urban Mller in 1993.   The language was designed, in part, so Mller could create the smallest compiler ever. The first BF compiler was written for the Commodore Amiga OS 2.0 and was only 240 bytes in size. The BF Programming Language only consists of 8 different instructions, an array and a pointer.

Note: This grammar was written as an example. For such a simple syntax, it is far easier to manually write a specialized parser.

PL/0 PL/0 is a simple programming language created by Niklaus Wirth in his 1976 book Algorithms + Data Structures = Programs. Essentially, the grammar is a subset of Pascal and Modula-2 (both which Niklaus Wirth created). Most programming language features such as functions, parameters, looping statements, etc.. were removed.
Author: Eike Anderson
Oberon-00 "Oberon-00 is a simple programming language proposed in [Wirth98]  as a simple example of a common language that can be used for hardware and software compilation. Such language could be used for research purposes in the field of high-level synthesis (HLS) and as a testbed for hardware-software codesign. Oberon-00 is derived as a hardware-friendly subset of Oberon.

This package contains both a regular BNF grammar derived from the Oberon-00 EBNF, which can be used within the GOLD environment and the original EBNF."

Author: Nikolaos Kavvadias
File Formats
Cascading Style Sheets Cascading Style Sheets was originally proposed in 1994 by Hakon Wium Lie during "Mosaic and the Web" conference in Chicago.

Shortly afterwards, Hakon Wium Lie teamed up with Bert Bos who was developing a web browser called "Argo". Together the format of the first Cascading Style Sheets was developed and, with Thomas Reardon of Microsoft, was submitted to the W3C Committee in late 1996.

Graphviz (aka Dot) This grammar, submitted by Richard Scheider, is for a graph language from AT&T known by the names Graphviz and Dot.
Author: Richard Schneider
Date: February 4, 2002
HTML This grammar requires little explanation - being the dominant format used  for websites. Like XML, HTML is a descendant of SGML (Standardized General Markup Language). This grammar was mainly written as an example. Those parsing HTML documents should incorporate a simple stack rather than using a parsing system.
JSON JavaScript Object Notation (JSON) is a text file format that was created for data-interchange between different programming languages. The conventions of the format is based on the C programming language and, as a result, should be familiar to programmers of C++, Java, and C#.
Author: Arsne von Wyss
Version: 1.0
Date: August 14, 2010
XML XML, like the commonly used HTML format, is a descendant of SGML (Standardized General Markup Language). However, XML is not a descendant of HTML and structural differences exist between the two formats. XML has been adopted by leading software companies including Sun Microsystems and Microsoft for their SOAP framework.
Miscellaneous Grammars
Commandline Argument This is a grammar submitted by Alex K. Angelopoulos that is designed to be similar to the parsing performed by WScript.
Author: Alex K. Angelopoulos
Version: 0.1
Date: 09-28-2003
GOLD Grammar
This is the official grammar that is used internally by versions 2.6 and later of the GOLD Parser Builder.
Version: 2.6
GOLD Grammar
(Matt Hounsell)
Mathew Hounsell submitted a grammar that parses the Grammar Outline used by the Builder. This is a very clean design.
Author: Mat Hounsell
Version: 2003 - 02
Pokchi/J Christian Beaumont submitted a grammar he wrote called "Pokchi/J". This grammar defines a JavaScript like language with some C# like extensions.
Author: Christian Beaumont
Regular Expressions This very simple grammar will parse regular expressions. Unlike the grammar used for the GOLD Builder scanner, this grammar treats each character as a different token.
YACC One of the oldest and most respected parsing engine generators available to developers is YACC. Like "vi" "grep" and "awk", this software is considered  the de facto standard in the UNIX world. YACC, which is an acronym for Yet Another Compiler-Compiler, was developed by Stephen C. Johnson at AT&T. YACC can be used to create parsers using the C and C++   programming languages.
Grammars from Compiler Books
Compiler Construction:
Principles and Practice
The file contains the 'Tiny' grammar from Kenneth C. Louden's Compiler Construction: Principles and Practice book (ISBN 0-534-93972-4).
Modern Compiler Implementation This is a selection of grammars from Andrew W. Appel's Modern Compiler Implementation book series. Versions of this book were created from C, Java and ML.
Crafting a Compiler This file contains two of the grammars from the Crafting a Compiler by Charles N. Fischer & Richard J. LeBlanc, Jr. Currently, there is a new version in production. The grammars will be updated if they are changed in the new version.