Closed ponyatov closed 4 years ago
Some disadvantage I found in flex/bison: using bison it is better to use C++ and use class tree based on basic virtual class AST and set of it's inheritor classes for every different type of token (number, string, symbol, operator,..) and AST node (list cons, plain vector, gui element,..), see here for example: https://github.com/ponyatov/sym/blob/master/hpp.hpp
Now I'm digging into buildyourownlisp making some adaptation for my dumbstyle C++ (I have no enough skillls in real C++, just some entry level class-wrapping). Is there any sense in further write addition on using flex/bison/C++ for this diylisp manual ?
No reason really. Nothing wrong with Flex/Bison.
It is nice to just drop in a single C file rather than try to teach the whole Flex/Bison tool chain though. Also I think including the grammar in the C file to be preprocessed might be a little confusing for people who are unfamiliar with C syntax.
But ultimately parser combinators and parser generators are not so different.
Playing with parsing I found that AST trees itself in very unversal data element, which can follow Lisp ideology "code = data". Can you recommend some publications, where I can find description of Lisp-like system based on Tree processling, not List (something like Trip language 8-).
This Trip approach consists of Object element looks like native for modern computer languages, and most data structures. Maybe is there some ready to use system exists which I can play or realize it using only description ?
In short I'm searching 1) ready to use homoiconic language based of tree processing 2) or some description of Lisp short model targets on it's homoiconity, to expand this model onto my DIY system design.
I'm surprized why you don't use flex/bison for input parsing ? It's basic tools included in all toolchains and widely used for text data parsing. What advantages does mpc have over bison-generated parser (except illustration of using an external library in C programming) ?