digitalmars.D - [Discussion] Compiler-Compiler for D
- Sjoerd van Leent (84/84) Nov 10 2004 Hi all,
- Stewart Gordon (5/7) Nov 11 2004 This was discussed a while back:
- Sjoerd van Leent (5/17) Nov 11 2004 Got this noted. Since it was a while back, I didn't notice. But that
Hi all, Just out of curiousity, since I am developing DDoc (and just got the expressions going more or less) I did hit an interesting point. Right now I am using Yacc to extract all D grammar (since I need the comments as well). Then I'll pass it through to a D class tree. However, I feel more and more that something similar as Yacc should be available for D. Perhaps even using OOP. I was thinking of things like the following: ------------------------------------------------------------------------ Start: ProtectionAttribute Identifier ';' ProtectionAttribute: 'public' | 'private' | 'protected' | 'package' | 'extern' | 'extern' '(' Indentifier ')' Identifier: '[_[:ALPHA:]][_[:ALNUM:]]' ------------------------------------------------------------------------ It could very well be possible to both allow Interactive parsing as Non-interactive parsing, in which an object tree is made. In this case the following could be possible: ------------------------------------------------------------------------ class Start { ProtectionAttribute varProtectionAttribute1_1; Identifier varIdentifier1_2; int rule; bit isRule(int i) { return (rule == i); } ProtectionAttribute getProtectionAttribute1_1() { return varProtectionAttribute1_1; } Identifier getIdentifier1_2() { return varIdentifier1_2; } } class ProtectionAttribute { char[][] match1_1; // 'public' char[][] match2_1; // 'private' char[][] match3_1; // 'protected' char[][] match4_1; // 'package' char[][] match5_1; // 'extern' char[][] match6_1; // 'extern' char[][] match7_2; // '(' Identifier varIdentifier8_3; char[][] match9_4; // ')' int rule; bit isRule(int i) { return (rule == i); } char[][] getMatch1_1() { return match1_1; } // // *** Etc... *** // char[][] getMatch9_4() { return match9_4; } } class Identifier { char[][] match1_1; '[_[:ALPHA:]][_[:ALNUM:]]' int rule; bit isRule(int i) { return (rule == i); } char[][] getMatch1_1() { return match1_1; } } ------------------------------------------------------------------------ Regards, Sjoerd
Nov 10 2004
Sjoerd van Leent wrote: <snip>However, I feel more and more that something similar as Yacc should be available for D. Perhaps even using OOP.This was discussed a while back: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/4351 Stewart.
Nov 11 2004
Stewart Gordon wrote:Sjoerd van Leent wrote: <snip>Got this noted. Since it was a while back, I didn't notice. But that doesn't hold me from writing something like it :) Regards, SjoerdHowever, I feel more and more that something similar as Yacc should be available for D. Perhaps even using OOP.This was discussed a while back: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/4351 Stewart.
Nov 11 2004