You can check out the section 'Parsers' under http://build.nimrod-lang.org/docs/lib.html.
If you want to create a DSL, maybe it is an option for you to build it in nimrod with the help of the macro-/templatesystem?
Thanks for the response. Unfortunately, I didn't see anything in those libraries that could be helpful. I guess I'll just stick to C for this project :(
Out of curiosity though, how would one use the macro/template system to create a DSL?
Even though Nimrod lacks a parser generator, it does have the parsing modules, one of which contains an efficient string tokenizer.
If you wanted to use just macros and AST manipulation, you would probably create a macro which takes an existing AST construct (like, say, a series of procedure and variable definitions ) and uses the information in the AST to construct an expanded or optimized parser.
To borrow style from the excellent codetalker python parser generator:
var x = Parser()
parserRules:
parser = x # The parser to add the rules to
# A series of procedures and vars belonging to the parser
Identifier = oneOrMore(upperLetter | lowerLetter) & zeroOrMore(upper letter | lowerLetter | digit | underscore)
Number = oneOrMore(digit)
proc Indent(parser, env) =
if parser.peek() != Newline and parser.peek(1) != Tab:
return
var level = 1
while parser.peek(level + 1) == Tab:
level +=1
parser.capture(level)
env[indentationLevel] = level
Of course, the above could probably be done in some fashion without macros or templates, however macros could be used to transform the above into a more optimized piece of code.
I'm curious, why use C? I don't know of many parser generators for it (although that's not saying there aren't any), and it's not the kind of language I would try to write a plain parser in - I'd use Nimrod or Python for that sort of thing (For python, I'd use codetalker, which is optimized with cython)
I want to write a programming language, but I don't want to use C/C++. I also don't want to hand-write my lexer and parser.
It is a typical misconception that a compiler only consists of a parser. For the nimrod compiler only ~3% of the code base is the actual lexer and parser... Generating this code doesn't buy you much. That said, lexer and parser generators for nimrod would be sweet but I'm not aware of any.