User loginNavigation 
C++ LL(1) Parser Combinator LibraryI have put a C++ LL(1) parser combinator library on GitHub https://github.com/keean/ParserCombinators. There is an example to show how it is used, and there is a simple recursive decent parser for comparison. The parsercombinators benchmark 20% faster than the simple parser. I would appreciate comments on the code, the choice of combinators (I want to keep the number to a minimum without compromising usefulness), and the comparative readability of code using the combinators vs the simple parser, or any other thoughts. There are two basic string recognisers ('accept', 'expect'), two nullary parsers ('succ', 'fail'), and two parserconstructors ('all', 'any') that take a user supplied functor and a variadic argument list of parsers or recognisers. The functor for the parser constructors is variadic, so it is passed one result argument for each parser, 'all' only calls the functor if all the parsers succeed and provides all arguments, 'any' calls the functor as soon as the first parser from the left succeeds with an index number indicating which argument has the valid result (the remaining arguments are initialised with the default constructor). Finally there are four combinators that can be used on both recognisers and parsers '&&', '' which behave as they do in boolean logic (with shortcircuit evaluation), 'many' and 'discard'. Edit: The latest version of this library supports full backtracking parser combinators, and is different from other C++ parser combinator libraries because it separates static and dynamic polymorphism. By limiting dynamic polymorphism to only where actually needed, the compiler can inline the combinators (which are functionobjects) resulting in performance better than the noncombinator handwritten recursive descent parsers. By Keean Schupke at 20140502 15:10  LtU Forum  previous forum topic  next forum topic  other blogs  4450 reads

Browse archivesActive forum topics 
Recent comments
1 hour 35 min ago
2 hours 6 min ago
2 hours 33 min ago
2 hours 44 min ago
4 hours 19 min ago
5 hours 53 min ago
6 hours 35 min ago
9 hours 48 min ago
10 hours 15 min ago
11 hours 1 min ago