As I read, Nim has seamless with any C libraries and code, so for the lexer,
you can use Ragel, it produces readable and compact code with -G2 option (I use
it on low-end microcontrollers for command parsing).
The more interesting question is Nim able to do backtracking to implement DCG
Hi @spip,
Sorry, only noticed your post just now - for future communication feel free to
post into the NPeg issues at github so I get properly notified.
> It has its own grammar syntax for rules that does not follow (E)BNF like
> Nim's pegs
This is a design choice: having a grammar parseable
npeg has very nice features:
* A complete documentation with clear code.
* Peg generation at compile time.
* AST captures to build an Abstract Syntax Tree while matching the grammar.
* Nim code embedding in the rules.
* Debugging and tracing functions, with the nice grammar tree view.
Add option and repeat in
[https://github.com/loloiccl/nimly/pull/22](https://github.com/loloiccl/nimly/pull/22)
Ah please support "0 or more", it sucks to write simple loops as recursion.
nimly support only BNF now. For example, these are missing now.
* option ([else] in) : IF cond THEN exp [else]
* 0 or more ({param} in): PROC NAME RPAR {param} LPAR
But you can write BNF which equal to these.
I will support EBNF later
I'm taking the liberty to shamelessly mention my recent project here, as this
seems the appropriate thread to do so: NPeg is a PEG-style parser generator
which allows free mixing of grammar and Nim code, which should be suitable for
the task of lexing and parsing.
It can collect simple string
Wow, nimly looks nice. Don't have the time to try it. When you say "EBNF not
supported" what exactly is missing?
I made a BNF lexer/parser generator library
([https://github.com/loloiccl/nimly)](https://github.com/loloiccl/nimly\)).
(unfortunately, EBNF is not supported now)