Quick Overview
Algodal™ Parser Generator Tool is a tool for generating UTF-8 or binary parsers in C11 code using the Algodal™ Parser Language. Generated parsers can be compiled with various C and C++ compilers for use in your projects, which include gcc, clang, gcc++ and clang++. If you are making a non-C and non-C++ project, then you can write bindings in other languages for the well defined API of the generated parsers. The parser generator language can be used to design complete parsers for any languages faster than it is to use other parser generators or write the parsers by hand.
A complete parser is a fully compliant parser for a specific well defined language that publicly provides a complete official language specification.
Algodal™ Parser Language can be used to easily write parsers for languages with C-like grammars, such as, C, C++, Java, JavaScript and JSON. Also can be used any other languages such as Python, XML and INI. It even supports parsing binary languages like WAVE and BMP.
Algodal™ Parser Generator Language (also called parser language or source) is the language in which the parsers are written. It uses commands, prefaced with the @ symbol to give instructions to the generator. The smallest building block of a witten parser is called an action (@action). An action is what the parser does. Actions can be treated as functions or subroutines. Some actions can be given special roles such as tokenizers and entry points. The names of actions are important as they are used for labelling purposes. An action can be defined in either the tokenphase (@token) or the syntaxphase (@syntax). The tokenphase is where tokenization occurs. Tokenization is grouping individual characters from the parsed text into tokens. The syntaxphase is where analyzation occurs. Analyzation is the grouping of individual tokens from the tokenization into nodes. These nodes are combined together create the abstract syntax tree a.k.a (AST). Unlike other parser generators, Algodal™ Parser Generator generates the AST for you. You can control what node gets generated in the AST using objectpoint (@objectpoint) and scope (<>). You can generate a parser that either generates an AST with only tokens or both tokens and nodes or does not generate any AST (only parses the text for compliance to specification). You will learn more details about these in later chapters.
Algodal™ Parser Generator Tool has a different interpretation, from other parser generators, of what a parser is. Algodal™ Parser Generator Tool considers a parser to be a virtual machine. Therefore, it divides a parser into 2 parts: the program with the actual code of the parser and the machine which the runs the program. The machine is reusable code. Therefore, once you generate the machine code, you don’t need to regenerate it again unless you have updated to a newer Algodal™ Parser Generator Tool version. The program is specific code. It is specific to the parser source you wrote in the Algodal™ Parser Language. Each parser you write will generate a different program code, as well as, if you update your parser source, the generated program code will also change. You can generate many parsers, therefore, have many programs running on a single machine. That is, multiple parsers in a single program is supported out of the box, unlike most other parser generators. Also, instead of generating the program as C code, you can generate it as JSON data. Algodal™ Parser Generator Tool allows you to include code in your machine that will convert the JSON to program code. This feature is useful for writing parsers for text editors via a pluggable method.
The generated parser code will be much smaller compared to other parser generators and, especially, parsers written by hand.
- Parsers generated with with Algodal™ Parser Language includes the following features:
Recursions (it’s the user’s responsibility to write the parser well to avoid infinite loop). There is no recursion limit. The parsers can recurse as many times as memory allows.
Loops
Look aheads
Logic, variables and stack support
Read UTF-8 text without any issues (unlike most other parser generators)
Read binary
Parses quickly and accurately.
Cross-compile on multiple platforms (practically any platform that C can be compiled for). Windows, Linux and Android are officially supported.
Simple and well-document APIs for integration in project.
Bindings (user provided) to cross over into other programming languages.
Abstract syntax tree is generated for you - you don’t have to write logic for this
and much more
Friendly license:
The parser source (.parser or .algodal-parser file) you write is yours.
You can freely add the generated parsers code in your project (public, private, commercial).