Difference between revisions of "Make your own compiler, interpreter, parser, or expression analyzer"

From Free Pascal wiki
Jump to navigationJump to search
m (added categories)
m (formatting)
Line 1: Line 1:
== Lex and Yacc ==
+
= Lex and Yacc =
 
Two of the oldest unix tools. [https://en.wikipedia.org/wiki/Lex_(software) Lex] is a lexical analyser (token parser), and [https://en.wikipedia.org/wiki/Yacc Yacc] is a [https://en.wikipedia.org/wiki/LALR_parser LALR] parser generator. [https://en.wikipedia.org/wiki/Backus–Naur_form BNF] notation is used as a formal way to express context free grammars. Code and grammar are mixed, so grammar is tied to implementation language.
 
Two of the oldest unix tools. [https://en.wikipedia.org/wiki/Lex_(software) Lex] is a lexical analyser (token parser), and [https://en.wikipedia.org/wiki/Yacc Yacc] is a [https://en.wikipedia.org/wiki/LALR_parser LALR] parser generator. [https://en.wikipedia.org/wiki/Backus–Naur_form BNF] notation is used as a formal way to express context free grammars. Code and grammar are mixed, so grammar is tied to implementation language.
  
=== Plex and Pyacc ===
+
== Plex and Pyacc ==
 
[[Plex and Pyacc]] are pascal implementations of Lex and Yacc and they are part of your FreePascal distribution.
 
[[Plex and Pyacc]] are pascal implementations of Lex and Yacc and they are part of your FreePascal distribution.
  
=== Lazarus Lex and Yacc ===
+
== Lazarus Lex and Yacc ==
 
You can find unfortunately abandoned Lazarus Lex and Yacc [https://bitbucket.org/avra/lazlexyacc/src/master/ here].
 
You can find unfortunately abandoned Lazarus Lex and Yacc [https://bitbucket.org/avra/lazlexyacc/src/master/ here].
  
== Gold ==
+
= Gold =
 
[[Gold]] is a free parsing system that you can use to develop your own programming languages, scripting languages and interpreters. It uses [https://en.wikipedia.org/wiki/LALR_parser LALR] parsing, and a mix of [https://en.wikipedia.org/wiki/Backus–Naur_form BNF] notation, character sets and regular expressions for terminals to define language grammars. Code and grammar are separated, so grammar is not tied to implementation language. This means that the same grammar can be loaded into engines made in different programming languages.
 
[[Gold]] is a free parsing system that you can use to develop your own programming languages, scripting languages and interpreters. It uses [https://en.wikipedia.org/wiki/LALR_parser LALR] parsing, and a mix of [https://en.wikipedia.org/wiki/Backus–Naur_form BNF] notation, character sets and regular expressions for terminals to define language grammars. Code and grammar are separated, so grammar is not tied to implementation language. This means that the same grammar can be loaded into engines made in different programming languages.
  
Line 17: Line 17:
 
There is a subjective [http://goldparser.org/about/comparison-parsers.htm feature comparison table] of several parsers on Gold site, with special attention to [http://goldparser.org/about/comparison-yacc.htm Gold vs Yacc] comparison.
 
There is a subjective [http://goldparser.org/about/comparison-parsers.htm feature comparison table] of several parsers on Gold site, with special attention to [http://goldparser.org/about/comparison-yacc.htm Gold vs Yacc] comparison.
  
== AntLR ==
+
= AntLR =
 
TBD
 
TBD
  
== Coco-R ==
+
= Coco-R =
 
TBD
 
TBD
  
== Useful BNF and EBNF tools ==
+
= Useful BNF and EBNF tools =
 
* [http://www.garshol.priv.no/download/text/bnf.html BNF and EBNF metasyntax formal notations for writing grammars]
 
* [http://www.garshol.priv.no/download/text/bnf.html BNF and EBNF metasyntax formal notations for writing grammars]
 
* [http://bottlecaps.de/rr/ui EBNF to Syntax Diagram online convertor]
 
* [http://bottlecaps.de/rr/ui EBNF to Syntax Diagram online convertor]
Line 29: Line 29:
 
* [https://www.ctan.org/tex-archive/support/syngen Syngen - tool for generating syntax diagrams from BNF in LaTeX format]
 
* [https://www.ctan.org/tex-archive/support/syngen Syngen - tool for generating syntax diagrams from BNF in LaTeX format]
  
== See also ==
+
= See also =
 
* [https://www.inf.ethz.ch/personal/wirth/CompilerConstruction/CompilerConstruction1.pdf Niklaus Wirth - Compiler construction]
 
* [https://www.inf.ethz.ch/personal/wirth/CompilerConstruction/CompilerConstruction1.pdf Niklaus Wirth - Compiler construction]
 
* [https://compilers.iecc.com/crenshaw/ Let's build a compiler]
 
* [https://compilers.iecc.com/crenshaw/ Let's build a compiler]

Revision as of 20:57, 12 September 2018

Lex and Yacc

Two of the oldest unix tools. Lex is a lexical analyser (token parser), and Yacc is a LALR parser generator. BNF notation is used as a formal way to express context free grammars. Code and grammar are mixed, so grammar is tied to implementation language.

Plex and Pyacc

Plex and Pyacc are pascal implementations of Lex and Yacc and they are part of your FreePascal distribution.

Lazarus Lex and Yacc

You can find unfortunately abandoned Lazarus Lex and Yacc here.

Gold

Gold is a free parsing system that you can use to develop your own programming languages, scripting languages and interpreters. It uses LALR parsing, and a mix of BNF notation, character sets and regular expressions for terminals to define language grammars. Code and grammar are separated, so grammar is not tied to implementation language. This means that the same grammar can be loaded into engines made in different programming languages.

GOLD Parser Builder can be used to create, modify and test languages in Windows IDE which can also run on Wine. Command line tools are also available.

Gold Parser Builder has grammar editor with syntax highlighting, grammar generating wizard, test window to step through parsing of a sample source, templating system that can generate lexers/parsers or skeleton programs for various languages (including Delphi and FreePascal), import/export YACC/Bison, XML and HTML export, and interactive inspection of the compiled DFA and LALR tables.

There is a subjective feature comparison table of several parsers on Gold site, with special attention to Gold vs Yacc comparison.

AntLR

TBD

Coco-R

TBD

Useful BNF and EBNF tools

See also