digitalmars.D - scanner and parser generator for D
- Marc (13/13) Jun 22 2004 Hi people,
-
Stewart Gordon
(20/26)
Jun 22 2004
- Marc (6/12) Jun 22 2004 what i mean is flex/bison generated code relies on static global variabl...
- Andy Friesen (9/10) Jun 22 2004 Spirit relies very heavily on deducing template arguments on overloaded
- Marc (4/11) Jun 22 2004 indeed ! so i wonder how D would handle such stuff... i think it's a gre...
Hi people, I'm wondering if someone hasn't thought of developing an equivalent of Flex and Bison generating D code, possibly reentrant (one of the major flex/bison flaws being bad support for C++ code) As a possibly more interesting alternative, I also had a look at the Spirit library ( http://spirit.sourceforge.net/ ) and I think adapting its concepts to D would be a really valuable addition to the D standard library (and would represent a real stress test for the D overloadiing and templating models). For people who are too lazy to click, Spirit is a pure C++ header-based library that implements EBNF grammars using C++ objects and operators, and also include scanning facilities. regards, Marc
Jun 22 2004
Marc wrote:Hi people, I'm wondering if someone hasn't thought of developing an equivalent of Flex and Bison generating D code,<snip> I started developing something called SPE (Stewart's Parsing Engine). The idea is that tokenising and parsing work similarly and are covered in a single input file, and the generated program generates a parse tree that a compiler/interpreter can then interpret. I got as far as writing a parser for part of SPE itself, as a hand-coding of what SPE would generate, but not actually doing anything with it. It's in Java at the mo. But I've thought about switching the project over to D.possibly reentrantNot sure what you mean by this....(one of the major flex/bison flaws being bad support for C++ code)I think that's a flaw of C++ actually. The design of SPE relies on context-free grammar - whether that'll change depends on finding a way of implementing it.... Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.
Jun 22 2004
i mean that the generated code would be elligible for multithreaded apps, ie. all state informations should be stored in a D class or structure.possibly reentrantNot sure what you mean by this....what i mean is flex/bison generated code relies on static global variables that make it impossible to be used for a reentrant parser. There is a C++ mode for flex, but it uses deprecated C++ stream coding style. Have you taken a look at Spirit ? Its concepts are extremely interesting imho.(one of the major flex/bison flaws being bad support for C++ code)I think that's a flaw of C++ actually. The design of SPE relies on context-free grammar - whether that'll change depends on finding a way of implementing it....
Jun 22 2004
Marc wrote:Have you taken a look at Spirit ? Its concepts are extremely interesting imho.Spirit relies very heavily on deducing template arguments on overloaded operators, so if you're suggesting implementing Spirit in D, you've got your work cut out for you. :) The existing Spirit library is, as you say, interesting, but somewhat brittle. When it does work, (on GCC and MSVC 7.1) it can take a long, long time to compile. When it doesn't, the error messages are long enough to make me nostalgic for STL errors. :) -- andy
Jun 22 2004
Spirit relies very heavily on deducing template arguments on overloaded operators, so if you're suggesting implementing Spirit in D, you've got your work cut out for you. :) The existing Spirit library is, as you say, interesting, but somewhat brittle. When it does work, (on GCC and MSVC 7.1) it can take a long, long time to compile. When it doesn't, the error messages are long enough to make me nostalgic for STL errors. :)indeed ! so i wonder how D would handle such stuff... i think it's a great playground for 'extreme' use of templates, overloading.. etc the brittleness of Spirit is an evidence of the difficulty to implement a C++ compiler, and so comes D...
Jun 22 2004