-
Notifications
You must be signed in to change notification settings - Fork 0
Introduction
The Gold Parser, or Gold Parser System, as the author calls it, is a parser generator and a parser engine for DotNet that is free and open source. It can be utilised to parse various programming languages' source codes, or as the author describes it:
GOLD is a free parsing system that you can use to develop your own programming languages, scripting languages and interpreters. It strives to be a development tool that can be used with numerous programming languages and on multiple platforms.
The website of this project - https://github.com/viktorchernev/GoldParserEngine
This project license - https://github.com/viktorchernev/GoldParserEngine/blob/master/LICENSE
The website of the original project - http://www.goldparser.org/index.htm
The original project license - http://www.goldparser.org/about/license.htm
The Gold Parser is licensed under its own license agreement, which consists of just few sentences and is derived from the zlib/libpng Open Source License Agreement.
In few words, you can do anything with the software, as long as you license it under the same agreement, and as long as you don't lie about who wrote it or what it does.
The Gold Parser has been receiving updates until September 17, 2012, when the last version - version 5.2 has been released.
The Gold Parser is a parser generator (also known as compiler-compiler), much like many other lexer and parser generators - you provide it with a written grammar and it creates your parser for you.
The Gold parser has it's own unique features that it might or might not share with other similar software. For example, the lexer is inbuilt within the parser, so you provide the lexer rules within the parser grammar file. Also, you don't get a parser source code, but instead you get grammar tables file (.egt), while the actual parser is on a .net dll that you reference in your project - the grammar tables are all the logic the parser is going to follow in order to parse a piece of source code (like a source file) and spit out a structure known as a parse tree.
The Gold parser consists of two pieces of software - the builder and the engine. The engine is made of few classes in a .dll that you can reference in your DotNet projects, while the builder is a (rather poorly cooded) IDE. Here is a quick idea of how this works:
a) download and install the builder
b) write your language grammar
c) (optionally) save your grammar (to .grm file)
d) try to compile your grammar
e) (optionally) fork on fixing conflicts in your grammar
f) compile your grammar (to .egt file)
g) (optionally) test your compiled grammar in the IDE
h) add a reference to the GoldParserEngine.dll
i) in code - create an instance of the GoldParser
j) in code - load the compiled .egt file in the parser (I load it from an embedded resource)
k) in code - call the Parse() method multiple times until the file is parsed
I wanted to understand how the engine works in detail and have a working source code of the latest version in C#, and since I was not able to find neither the source code for the last version in C#, nor great documentation, I set up to rewrite the code from disassembly (using ILSpy) and write the documentation my self. Quite late in the process, I found what appears to be said source in a github repo - https://github.com/meziantou/GoldParser-Engine/ and some documentation on the EGT file format, and used @meziantou's repo to verify my code and gain further insight from his comments.
I have done this with the intention to use the engine in my project, and have done some minor changes. For one, I have created an EGT reader class, that is able to translate EGT files (raw uninteligeable bytes) to readable JSON. I have also changed the reference/instance based grammar table structures inside EGT to index based ones. I have also done some refactoring at few places, where code was substandart.
However, my version of the engine is 100% interoperable with the original version 5.2 and compatible with the Gold Parser Builder.