WiParser is a modern parser combinator written from scratch in plain C++ 17. It is intended to provide a simple API that can be easily extended.
This repository was contributed by Valentin-Ioan Vintilă and it is provided under the MIT License. For more info about the author, check out his personal website or his other projects.
The repository contains an example Makefile that compiles the test.cpp file. You can thus extract the required (generic) compilation process.
Simply run make
and a new file, ./test
, should be created.
A few examples should be provided in the test.cpp file. These should give the programmer a good understanding of the basics, without reading any documentation.
The rich API provided by the current version of the project, 1.0.2b, will be explained in the following paragraphs
The parser_state_t
structure contains the information that will be passed from one (sub)parser to another. Think of it as a log of wood that will be processed into a dinner table by various machines (in our case, parsers) which work in an ordered manner.
The structure contains the following information:
target_string (std::string)
- The string that has to be parsed.result (std::any)
- In our analogy, the dinner table (or any product in between the log of wood and the dinner table). Currently, theresult
can only be astd::string
or astd::vector<std::any>
, but this will be addressed in the future so that more types will be included.index (std::size_t)
- The index of the character that will be processed next,target_string[index]
.error (std::optional<std::string>)
- This will hold no value if no error occured and it will hold a detailed string in case something went wrong.
There are setters and getters for each of the parameters explained above.
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO