GOLD (parser)
![]() | The topic of this article may not meet Wikipedia's notability guidelines for products and services. (August 2017) |
This article needs additional citations for verification. (August 2017) |
![]() | |
![]() | |
Developer(s) | Devin Cook and 54 other contributors[1] |
---|---|
Final release | 5.2.0
/ August 18, 2012 |
Windows | |
Type | LALR parser |
License | zlib License (free software) |
Website | goldparser![]() |
GOLD is a free parsing system that is designed to support multiple programming languages.
Design
The system uses a
The GOLD system consists of three logical components, the "Builder", the "Engine", and a "Compiled Grammar Table" file definition which functions as an intermediary between the Builder and the Engine.
Builder
![GOLD Components](http://upload.wikimedia.org/wikipedia/commons/3/3f/GOLD_flow.png)
The Builder is the primary component and main application of the system. The Builder is used to analyze the syntax of a language (specified as a grammar) and construct
Once the
Some of the features of the Builder are:
- Freeware license
- State browsing
- Integrated testing
- Test multiple files wizard
- Generate webpages (including hyperlinked syntax charts)
- Generate skeleton programs using templates
- Export grammars to YACC
- Export tables to XML or formatted text
Compiled Grammar Table file
The Compiled Grammar Table file is used to store table information generated by the Builder.
Engines
Unlike the Builder, which only runs on a single platform, the Engine component is written for a specific programming language and/or development platform. The Engine implements the
Currently, Engines for GOLD have been implemented for the following programming languages / platforms. New Engines can be implemented using the source code for the existing Engines as the starting point.
- Assembly - Intel x86
- ANSI C
- C#
- D
- Delphi
- Java
- Pascal
- Python
- Visual Basic
- Visual Basic .NET
- Visual C++
Grammars
GOLD grammars are based directly on Backus–Naur form, regular expressions, and set notation.
The following grammar defines the syntax for a minimal general-purpose programming language called "Simple".
"Name" = 'Simple' "Author" = 'Devin Cook' "Version" = '2.1' "About" = 'This is a very simple grammar designed for use in examples' "Case Sensitive" = False "Start Symbol" = <Statements> {String Ch 1} = {Printable} - [''] {String Ch 2} = {Printable} - ["] Identifier = {Letter}{AlphaNumeric}* ! String allows either single or double quotes StringLiteral = '' {String Ch 1}* '' | '"' {String Ch 2}* '"' NumberLiteral = {Number}+('.'{Number}+)? Comment Start = '/*' Comment End = '*/' Comment Line = '//'
<Statements> ::= <Statements> <Statement>
| <Statement>
<Statement> ::= display <Expression>
| display <Expression> read ID
| assign ID '=' <Expression>
| while <Expression> do <Statements> end
| if <Expression> then <Statements> end
| if <Expression> then <Statements> else <Statements> end
<Expression> ::= <Expression> '>' <Add Exp>
| <Expression> '<' <Add Exp>
| <Expression> '<=' <Add Exp>
| <Expression> '>=' <Add Exp>
| <Expression> '==' <Add Exp>
| <Expression> '<>' <Add Exp>
| <Add Exp>
<Add Exp> ::= <Add Exp> '+' <Mult Exp>
| <Add Exp> '-' <Mult Exp>
| <Add Exp> '&' <Mult Exp>
| <Mult Exp>
<Mult Exp> ::= <Mult Exp> '*' <Negate Exp>
| <Mult Exp> '/' <Negate Exp>
| <Negate Exp>
<Negate Exp> ::= '-' <Value>
| <Value>
<Value> ::= Identifier
| StringLiteral
| NumberLiteral
| '(' <Expression> ')'
Development overview
![](http://upload.wikimedia.org/wikipedia/commons/thumb/a/ad/GOLD_screenshot.gif/220px-GOLD_screenshot.gif)
The first step consists of writing and testing a grammar for the language being parsed. The grammar can be written using any text editor - such as Notepad or the editor that is built into the Builder. At this stage, no coding is required.
Once the grammar is complete, it is analyzed by the Builder, the
In the final stage, the tables are read by an Engine. At this point, the development process is dependent on the selected implementation language.
References
- ^ "Contributors". goldparser.org. Retrieved 28 August 2017.
External links
![](http://upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/30px-Commons-logo.svg.png)
- Official website
- GOLD Yahoo Group at the Wayback Machine (archived 2020-12-14)