World Library  
Flag as Inappropriate
Email this Article

GOLD (parser)

Article Id: WHEBN0008544400
Reproduction Date:

Title: GOLD (parser)  
Author: World Heritage Encyclopedia
Language: English
Subject: GOLD, Programming language implementation, Backus–Naur Form, Compiler construction
Collection: Parser Generators, Programming Language Implementation
Publisher: World Heritage Encyclopedia
Publication
Date:
 

GOLD (parser)

GOLD Parsing System
GOLD Logo
Builder Application
Developer(s) Devin Cook &
Multiple Contributors
Stable release 5.2.0 / 08-18-2012
Operating system Windows
Type Parsers - LALR
License zlib License (free software)
Website goldparser.org

GOLD is a free parsing system that is designed to support multiple programming languages.

Contents

  • Design 1
    • Builder 1.1
    • Compiled Grammar Table file 1.2
    • Engines 1.3
  • Grammars 2
  • Development overview 3
    • Design the grammar 3.1
    • Construct the tables 3.2
    • Select a parsing Engine 3.3
  • External links 4

Design

The system uses a DFA for lexical analysis and the LALR algorithm for parsing. Both of these algorithms are state machines that use tables to determine actions. GOLD is designed around the principle of logically separating the process of generating the LALR and DFA parse tables from the actual implementation of the parsing algorithms themselves. This allows parsers to be implemented in different programming languages while maintaining the same grammars and development process.

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

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 LALR and DFA tables. During this process, any ambiguities in the grammar will be reported. This is essentially the same task that is performed by compiler-compilers such as YACC and ANTLR.

Once the LALR and DFA parse tables are successfully constructed, the Builder can save this data into a Compiled Grammar Table file. This allows the information to be reopened later by the Builder or used in one of the Engines. Currently, the Builder component is only available for Windows 32-bit operating systems.

Some of the features of the Builder are as follows:

  • 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 LALR and DFA algorithms. Since different programming languages use different approaches to designing programs, each implementation of the Engine will vary. As a result, an implementation of the Engine written for Visual Basic 6 will differ greatly from one written for ANSI C.

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.

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"   = 

{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  = '//' 

  ::=  
               |  

   ::= display 
               |  display  read ID
               |  assign ID '=' 
               |  while  do  end
               |  if  then  end
               |  if  then  else  end
               
  ::=  '>'  
               |   '<'  
               |   '<=' 
               |   '>=' 
               |   '==' 
               |   '<>' 
               |  

     ::=  '+' 
               |   '-' 
               |   '&' 
               |  

    ::=  '*' 
               |   '/' 
               |  

  ::= '-' 
               |  

       ::= Identifier
               |  StringLiteral
               |  NumberLiteral
               |  '('  ')'

Development overview

Design the grammar

GOLD Builder Application
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.

Construct the tables

Once the grammar is complete, it is analyzed by the Builder, the LALR and DFA parse tables are constructed, and any ambiguities or problems with the grammar are reported. Afterwards, the tables are saved to a Compiled Grammar Table file to be used later by a parsing engine. At this point, the GOLD Parser Builder is no longer needed.

Select a parsing Engine

In the final stage, the tables are read by an Engine. At this point, the development process is dependent on the selected implementation language.

External links

  • GOLD Parsing System Homepage
    • List of Contributors
  • GOLD Yahoo Group
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
 
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
 
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.
 


Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.