Hi I have to write a parser for a simple Syntax and I was wondering if there are already resources to help me do that.
Any hints are welcome.
key1 = value1
key2 = value2, value3
key3(args) = value5
key1(args)= table (
Why don’t you use an existing file format instead of rolling your own? TOML is built into Julia, but there are also other (JSON, YAML, etc). Otherwise those packages could be inspirations for you.
I want to use an external program which takes this kind of format as an input. The parser would help with reusing/modifying the already existing files, which are quite long.
I’ll take a look at the mentioned projects. Let’s see if I can find some common strategy, which I can reuse.
I haven’t used it, but I have high hopes for
This looks very interesting, although I can’t grab the full concept yet.
You may find Lerche useful. It reads an EBNF for your grammar to create a parser. Rules provided by you for traversing and transforming the resultant parse tree are then applied. Lerche is only version 0.1 but the API is designed to match the Lark API so it shouldn’t change.
I am successfully using it for a reasonably complicated grammar .
There are certainly opportunities for speed improvement in Lerche. As a workaround, you can see from the linked project that it is possible to simply serialise the generated parser.
I managed to write a small parser using CombinedParsers.
I have to say it works quite well.
Also I saw that there is an issue for adding a macro, which can import EBNF grammar.