HOME

TheInfoList



OR:

GOLD is a free
parsing Parsing, syntax analysis, or syntactic analysis is a process of analyzing a String (computer science), string of Symbol (formal), symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal gramm ...
system that is designed to support multiple programming languages.


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

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 Yacc (Yet Another Compiler-Compiler) is a computer program for the Unix operating system developed by Stephen C. Johnson. It is a lookahead left-to-right rightmost derivation (LALR) parser generator, generating a LALR parser (the part of a co ...
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 Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
32-bit operating systems. 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 Yacc (Yet Another Compiler-Compiler) is a computer program for the Unix operating system developed by Stephen C. Johnson. It is a lookahead left-to-right rightmost derivation (LALR) parser generator, generating a LALR parser (the part of a co ...
* 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 Visual Basic is a name for a family of programming languages from Microsoft. It may refer to: * Visual Basic (.NET), the current version of Visual Basic launched in 2002 which runs on .NET * Visual Basic (classic), the original Visual Basic suppo ...
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. * Assembly - Intel x86 * ANSI C * C# * D *
Delphi Delphi (; ), in legend previously called Pytho (Πυθώ), was an ancient sacred precinct and the seat of Pythia, the major oracle who was consulted about important decisions throughout the ancient Classical antiquity, classical world. The A ...
*
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
* Pascal * Python *
Visual Basic Visual Basic is a name for a family of programming languages from Microsoft. It may refer to: * Visual Basic (.NET), the current version of Visual Basic launched in 2002 which runs on .NET * Visual Basic (classic), the original Visual Basic suppo ...
* Visual Basic .NET * Visual C++


Grammars

GOLD grammars are based directly on
Backus–Naur form In computer science, Backus–Naur form (BNF, pronounced ), also known as Backus normal form, is a notation system for defining the Syntax (programming languages), syntax of Programming language, programming languages and other Formal language, for ...
, 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"   = 

 =  -  ' =  -  
Identifier    = *    

! String allows either single or double quotes

StringLiteral = ''  * ''
              ,  '"' * '"'

NumberLiteral = +('.'+)?

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

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 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. 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


External links

* * {{Web archive, title=GOLD Yahoo Group , url=https://web.archive.org/web/20201214134247/https://groups.yahoo.com/neo/groups/GOLDParser/info, date=December 14,2020 Parser generators Programming language implementation