Hello,
I have a text processing, matching, parsing, toolkit based on PEG (see below short description). It should be close to usable, and has some documentation already. I would be pleased to publish it as a library for others to use eventually (with a free licence). In the meantime, any kind of review, trial use, argumented critics, would be very useful to help & improve it, esp. to make it good D code -- because I'm very new to the language. Module and doc available at: http://spir.wikidot.com/deematch. Some characteristics: * Hopefully, as a tool, it is clear & friendly. * Grammars/parsers are written in plain D, using a set of typical pattern types. * Produces a tree of rather simple nodes. * A handful of helper pattern types allow producing an AST directly. * Custom match actions performed on nodes ("bottom-up processing"). * Testing tools (match trials, specific assertions, test suites). * Readable feedback (patterns, nodes, tests, errors). auto digit = klass("0-9"); auto natural = charString(digit); auto SPACE = drop(optionString(character(' '))); auto PLUS = Composition(SPACE, literal("+"), SPACE); auto addition = list(natural, PLUS, 2); addition.trial("98 + 765 + 4"); // common testing method ==> ------------------------------------------------------------------ pattern : List([0-9]+, Composition(Drop(' '*) "+" Drop(' '*)), 2) text : "98 + 765 + 4" outcome : ["98" "765" "4"] ------------------------------------------------------------------ auto nodes = natural.findAll("~~1-23__456==="); writeln(nodes); ==> ["1", "23", "456"] auto node = addition.match("98 + foo"); ==> ****************************************************************** Match Failure: cannot match expected pattern. pattern : List([0-9]+,Extract(Drop(' '*) "+" Drop(' '*)),2) index : 5 found : "foo" Cannot find at least 2 elements for List pattern [...] ****************************************************************** Denis -- -- -- -- -- -- -- vit esse estrany ☣ spir.wikidot.com
