Parser v 8.9
The Parser is designed to make reading from a file as easy as possible, while being extremely flexible. In order to do this, the Parsers is built at runtime. This flexibility means the Parser will take some additional cycles to set up; however, I believe this is well worth the cost.
Features:
- Built in smart File I/O
-
Instead of requiring you to manually load a file into memory for the Parser to process, the Parser does this for you automatically. On top of this, the Parser will only buffer a specified number of bytes from the file at any given time. In other words, the Parser can have a very small memory footprint.
-
Built in lexical analyzer:
-
The Parsers lexical analyzer provides several different methods to scan a file.
-
Globbing Search:
-
Globbing is a basic pattern matching algorithm. Globbing is very common in file systems. For example, "*.exe" will look for any executable. The same concept can be used with the Parser.
-
Regular Expression (RegEx) Search:
-
This is essentially a much more advanced version of globbing. Please check out this Wikipedia page for a much more detailed explanation.
-
Multiple Parser States:
-
Multiple different Parser states can exists at the same time. In other words, you can be processing a file in one part of your program, and then start processing another. In other words, you do not have to process files in a linear fashion. Instead, you can process them on demand.
-
Strict ANSI C (C89) with a C++ wrapper
-
Only strict ANSI C is used. In other words, if your compiler supports C89, then you can probably compile the library without any warnings. A C++ wrapper is provided as well.
-
Lost of documentation:
-
Binary Support:
-
While the Parser is mainly designed for text processing, it can also handle binary data. This includes things such as reading binary integers, binary floats, or just reading in a specified number of bytes.
-
Callbacks:
-
Callbacks can be defined to be called when ever a specific token is found.
-
Case Insensitivity:
-
All parsing can be set to be case insensitive.
So, why not use a traditional parser?
-
Traditional parsers tend to be static, rather then dynamic. Generally, once it's build, you can't change it. Plus, several steps are usually required to build a parser, which makes the overall process fairly non trivial.
Take the parser generators, bison and yacc, and the lexical analyzers, lex and flex. To build a parser, you need to roughly perform the following steps:
- Write lexer script file
- Generate lexer source file
- Write parser script file
- Generate parser source file
- Integrate parser into your project
So, you are dealing with at least 2 script files with specialized syntax and you may have to modify the final output to integrate the parser into your project. This makes quick iteration of a language very difficult.
So, in summary,
- Must know two specialized scripting languages
- Additional changes to the generate source may be required
- Small syntax changes typically requires a complete rebuild
- Maintenance is not very viable, since regeneration of source code will remove all internal modifications