Separate parser crate #11
Replies: 6 comments 10 replies
-
Let me expand on this since I suggested it on the Reddit thread. It plays into #2 that you posted. I'm a big proponent of the UNIX model. Separate utilities / interfaces so that others can glue them together in new and interesting ways. By creating clean separations, you'll be able to develop quicker and bring in new contributors more easily. People will be interested in different aspects and will want to scratch their itch. If they have to build a large project or attempt to digest a large code base it will be a barrier to bringing new contributors into the project. Lastly you'll be able to utilize the beancount ledger file test suite to ensure correctness of the parsing crate. At the end of the day, you'll need to be able to parse the data files before you can do any other CLI operations. |
Beta Was this translation helpful? Give feedback.
-
While I'm not terribly interested in a Rust re-write of ledger, I am very interested in a standalone parser for ledger written in Rust. I briefly looked around and found nom which looks very interesting. I am not a good programmer and I don't know Rust, but I'd be happy to test such a parser. FWIW, I believe ledger2beancount has the most comprehensive test suite for ledger syntax and I'd be happy to contribute this test suite to a Rust parsing library. There should be a separate parser for hledger because the syntax is slightly incompatible with ledger. |
Beta Was this translation helpful? Give feedback.
-
I wrote ledger-dialect (not compatible) parser with |
Beta Was this translation helpful? Give feedback.
-
Should an existing Ledger parser be extracted first or should a new one be written using an existing parser crate/library (like nom or chumsky)? |
Beta Was this translation helpful? Give feedback.
-
Before anyone gets too down and dirty or in the weeds with a low level parser like nom, what about using serde and writing a deserializer? The framework and method is well established and the pattern is pretty standard in the community |
Beta Was this translation helpful? Give feedback.
-
Hello, FYI, Tackler has ANTRL4 based parser for simplified Ledger syntax . The parser definition is located here.
This is for java/scala, but it should be possible to generate parser definition for Rust target also. There is an experimental Rust target for ANTRL4 here: https://github.com/rrevenantt/antlr4rust I have been very happy working with ANTRL4 and the produced parser is fast: https://tackler.e257.fi/docs/performance/ |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The idea here is to create crates for parser implementation(s). These would be used by the main application but could also be used by external projects.
Having parsers in separate crates, with all the dependencies, would make swapping different parser implementations much easier. This would be really helpful until the application is stabilized. Also, should other parsers appear (like Antlr officially supporting Rust), it would enable switching implementations.
It would be useful to compile parser(s) to WASM and use in JavaScript code.
Questions to explore:
what is the exact expected output of the parser?AST, domain modelResources:
Beta Was this translation helpful? Give feedback.
All reactions