www.digitalmars.com         C & C++   DMDScript  

D.gnu - lexer for flex

reply C.R.Chafer <blackmarlin nospam.asean-mail.com> writes:
I have written a flex lexer for d - source attached
please point out any bugs

(bison parser to follow when written)

C 2002/6/11
Jun 11 2002
parent reply "Martin M. Pedersen" <mmp www.moeller-pedersen.dk> writes:
"C.R.Chafer" <blackmarlin nospam.asean-mail.com> wrote in message
news:ae5bmk$2u97$1 digitaldaemon.com...
 Content-Transfer-Encoding: 8Bit

 I have written a flex lexer for d - source attached
 please point out any bugs

 (bison parser to follow when written)
It seems you have started what I did too :-) However, I ran into problems with the declaration grammar. The problem is that bison does not do N look-ahead that seems to be required by the D grammar - at least if "parse.c" is to be translated more or less directly. The problem is the Parse::is...() methods in "parse.c" that makes the grammar LALR(N). I have not figured out any way to solve this problem. Another problem is that you cannot easily destinguish type names from other names as in C. If you find your way around these problems, I would very much like to hear about it. I stopped for these reasons. I did the statements and expressions, though, and the grammar attached to this mail might help you or someone else getting started. I guess TOK_TYPENAME should not be defined as a token as i did, but I did not know better. After once having problems porting a flex generated lexer to an EBCDIC platform, I haven't used it since - so I don't have a .l file like you. But if you substitute the token names it should do. Regards, Martin M. Pedersen begin 666 grammar.y M+RHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ M*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ* T*#0H (" )$ED M.B!G<F%M;6%R+GDL=B Q+C0 ,C P,B\P-B\P,R R,#HT-3HT,"!M;7 17AP M("0-"B (" D4V]U<F-E.B O:&]M92]M;7 O87)C:&EV92]C=G-R;V]T+W!R M:B]D9G)O;G0O<W)C+V=R86UM87(N>2QV("0-" T**BHJ*BHJ*BHJ*BHJ*BHJ M*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ M*BHJ*BHJ*BHJ*BH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HE=&]K96X (%1/2U]&3$]!5%],251%4D%,#0HE=&]K96X (%1/ M2U])1$5.5$E&2452#0HE=&]K96X (%1/2U]465!%3D%-10T*#0HO*B!+97EW M;W)D<R!I;B!A;'!H86)E=&EC86P ;W)D97( *B\-"B5T;VME;B 5$]+7T%" M4U1204-4#0HE=&]K96X (%1/2U]!3$E!4PT*)71O:V5N("!43TM?04Q)1TX- M"B5T;VME;B 5$]+7T%330T*)71O:V5N("!43TM?05-315)4#0HE=&]K96X M(%1/2U]"250-"B5T;VME;B 5$]+7T)/1%D-"B5T;VME;B 5$]+7T)214%+ M#0HE=&]K96X (%1/2U]"651%#0HE=&]K96X (%1/2U]#05-%#0HE=&]K96X M(%1/2U]#05-4#0HE=&]K96X (%1/2U]#051#2 T*)71O:V5N("!43TM?0T5. M5 T*)71O:V5N("!43TM?0TA!4 T*)71O:V5N("!43TM?0TQ!4U,-"B5T;VME M;B 5$]+7T-/35!,15 -"B5T;VME;B 5$]+7T-/3E-4#0HE=&]K96X (%1/ M2U]#3TY424Y510T*)71O:V5N("!43TM?1$5"54<-"B5T;VME;B 5$]+7T1% M1D%53%0-"B5T;VME;B 5$]+7T1%3$5'051%#0HE=&]K96X (%1/2U]$14Q% M5$4-"B5T;VME;B 5$]+7T1%4%)%0T%4140-"B5T;VME;B 5$]+7T1/#0HE M=&]K96X (%1/2U]$3U5"3$4-"B5T;VME;B 5$]+7T5,4T4-"B5T;VME;B M5$]+7T5.54T-"B5T;VME;B 5$]+7T585$5.1$5$#0HE=&]K96X (%1/2U]% M6%1%4DX-"B5T;VME;B 5$]+7T9!3%-%#0HE=&]K96X (%1/2U]&24Y!3$Q9 M#0HE=&]K96X (%1/2U]&24Y!3 T*)71O:V5N("!43TM?1DQ/050-"B5T;VME M;B 5$]+7T9/4 T*)71O:V5N("!43TM?1T]43PT*)71O:V5N("!43TM?248- M"B5T;VME;B 5$]+7TE-04=)3D%260T*)71O:V5N("!43TM?24U03U)4#0HE M=&]K96X (%1/2U])3 T*)71O:V5N("!43TM?24Y/550-"B5T;VME;B 5$]+ M7TE.5 T*)71O:V5N("!43TM?24Y415)&04-%#0HE=&]K96X (%1/2U])3E9! M4DE!3E0-"B5T;VME;B 5$]+7TQ/3D<-"B5T;VME;B 5$]+7TY%5PT*)71O M:V5N("!43TM?3E5,3 T*)71O:V5N("!43TM?3U54#0HE=&]K96X (%1/2U]/ M5D524DE$10T*)71O:V5N("!43TM?4D5455).#0HE=&]K96X (%1/2U]32$]2 M5 T*)71O:V5N("!43TM?4U1!5$E##0HE=&]K96X (%1/2U]35%)50U0-"B5T M;VME;B 5$]+7U-54$52#0HE=&]K96X (%1/2U]35TE40T -"B5T;VME;B M5$]+7U-93D-(4D].25I%1 T*)71O:V5N("!43TM?5$A)4PT*)71O:V5N("!4 M3TM?5$A23U<-"B5T;VME;B 5$]+7U12544-"B5T;VME;B 5$]+7U1260T* M)71O:V5N("!43TM?5%E0141%1 T*)71O:V5N("!43TM?54)95$4-"B5T;VME M;B 5$]+7U5#14Y4#0HE=&]K96X (%1/2U]524Y4#0HE=&]K96X (%1/2U]5 M3$].1PT*)71O:V5N("!43TM?54Y)3TX-"B5T;VME;B 5$]+7U532$]25 T* M)71O:V5N("!43TM?5D524TE/3 T*)71O:V5N("!43TM?5D])1 T*)71O:V5N M("!43TM?5D],051)3$4-"B5T;VME;B 5$]+7U=#2$%2#0HE=&]K96X (%1/ M2U]72$E,10T*)71O:V5N("!43TM?5TE42 T*#0HO*B!0=6YC='5A=&EO;B J M+PT*)71O:V5N("!43TM?4TQ!4T (" (" (" (" (" O*B O(" ("HO M#0HE=&]K96X (%1/2U]33$%32%]%42 (" (" (" ("\J("\](" *B\- M"B5T;VME;B 5$]+7T1/5" (" (" (" (" (" +RH +B (" J+PT* M)71O:V5N("!43TM?1$]47T1/5" (" (" (" (" O*B N+B ("HO#0HE M=&]K96X (%1/2U]$3U1?1$]47T1/5" (" (" ("\J("XN+B *B\-"B5T M;VME;B 5$]+7T%.1" (" (" (" (" (" +RH )B (" J+PT*)71O M:V5N("!43TM?04Y$7T51(" (" (" (" (" O*B F/2 ("HO#0HE=&]K M96X (%1/2U]!3D1?04Y$(" (" (" (" ("\J("8F(" *B\-"B5T;VME M;B 5$]+7T]2(" (" (" (" (" (" +RH ?" (" J+PT*)71O:V5N M("!43TM?3U)?15$ (" (" (" (" (" O*B!\/2 ("HO#0HE=&]K96X M(%1/2U]/4E]/4B (" (" (" (" ("\J('Q\(" *B\-"B5T;VME;B M5$]+7TU)3E53(" (" (" (" (" +RH +2 (" J+PT*)71O:V5N("!4 M3TM?34E.55-?15$ (" (" (" (" O*B M/2 ("HO#0HE=&]K96X (%1/ M2U]-24Y54U]-24Y54R (" (" ("\J("TM(" *B\-"B5T;VME;B 5$]+ M7U!,55, (" (" (" (" (" +RH *R (" J+PT*)71O:V5N("!43TM? M4$Q54U]%42 (" (" (" (" O*B K/2 ("HO#0HE=&]K96X (%1/2U]0 M3%537U!,55, (" (" (" ("\J("LK(" *B\-"B5T;VME;B 5$]+7TQ4 M(" (" (" (" (" (" +RH /" (" J+PT*)71O:V5N("!43TM?3%1? M15$ (" (" (" (" (" O*B \/2 ("HO#0HE=&]K96X (%1/2U],5%], M5" (" (" (" (" ("\J(#P\(" *B\-"B5T;VME;B 5$]+7TQ47TQ4 M7T51(" (" (" (" +RH /#P](" J+PT*)71O:V5N("!43TM?3%1?1U0 M(" (" (" (" (" O*B \/B ("HO#0HE=&]K96X (%1/2U],5%]'5%]% M42 (" (" (" ("\J(#P^/2 *B\-"B5T;VME;B 5$]+7T=4(" (" M(" (" (" (" +RH /B (" J+PT*)71O:V5N("!43TM?1U1?15$ (" M(" (" (" (" O*B ^/2 ("HO#0HE=&]K96X (%1/2U]'5%]'5" (" M(" (" (" ("\J(#X^(" *B\-"B5T;VME;B 5$]+7T=47T=47T51(" M(" (" (" +RH /CX](" J+PT*)71O:V5N("!43TM?1U1?1U1?1U0 (" M(" (" (" O*B ^/CX ("HO#0HE=&]K96X (%1/2U]'5%]'5%]'5%]%42 M(" (" ("\J(#X^/CT *B\-"B5T;VME;B 5$]+7TY/5" (" (" (" M(" (" +RH (2 (" J+PT*)71O:V5N("!43TM?3D]47T51(" (" (" M(" (" O*B A/2 ("HO#0HE=&]K96X (%1/2U].3U1?15%?15$ (" (" M(" ("\J("$]/2 *B\-"B5T;VME;B 5$]+7TY/5%],5%]'5" (" (" M(" +RH (3P^(" J+PT*)71O:V5N("!43TM?3D]47TQ47T=47T51(" (" M(" O*B A/#X]("HO#0HE=&]K96X (%1/2U].3U1?3%0 (" (" (" (" M("\J("$\(" *B\-"B5T;VME;B 5$]+7TY/5%],5%]%42 (" (" (" M+RH (3P](" J+PT*)71O:V5N("!43TM?3D]47T=4(" (" (" (" (" O M*B A/B ("HO#0HE=&]K96X (%1/2U].3U1?1U1?15$ (" (" (" ("\J M("$^/2 *B\-"B5T;VME;B 5$]+7U!!4D%.7T]014X (" (" (" +RH M*" (" J+PT*)71O:V5N("!43TM?4$%204Y?0TQ/4T4 (" (" (" O*B I M(" ("HO#0HE=&]K96X (%1/2U]"4D%#2T547T]014X (" (" ("\J(%L M(" *B\-"B5T;VME;B 5$]+7T)204-+151?0TQ/4T4 (" (" +RH 72 M(" J+PT*)71O:V5N("!43TM?0U523%E?3U!%3B (" (" (" O*B![(" M("HO#0HE=&]K96X (%1/2U]#55),65]#3$]312 (" (" ("\J('T (" M*B\-"B5T;VME;B 5$]+7U%-05)+(" (" (" (" (" +RH /R (" J M+PT*)71O:V5N("!43TM?0T]-34$ (" (" (" (" (" O*B L(" ("HO M#0HE=&]K96X (%1/2U]314U)(" (" (" (" (" ("\J(#L (" *B\- M"B5T;VME;B 5$]+7T-/3$].(" (" (" (" (" +RH .B (" J+PT* M)71O:V5N("!43TM?1$],3$%2(" (" (" (" (" O*B D(" ("HO#0HE M=&]K96X (%1/2U]%42 (" (" (" (" (" ("\J(#T (" *B\-"B5T M;VME;B 5$]+7T517T51(" (" (" (" (" +RH /3T (" J+PT*)71O M:V5N("!43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1I9FEE<B!43TM?0T],3TX <W1A=&5M96YT#0H M(" .PT*#0IB;&]C:U]S=&%T96UE;G0-"B (" Z(%1/2U]#55),65]/4$5. M(&]P=%]S=&%T96UE;G1?;&ES="!43TM?0U523%E?0TQ/4T4-"B (" [#0H- M"F5X<')E<W-I;VY?<W1A=&5M96YT#0H (" .B!E>'!R97-S:6]N(%1/2U]3 M14U)( T*(" (#L-" T*9&5C;&%R871I;VY?<W1A=&5M96YT#0H (" .B!V M87)I86)L95]D96-L87)A=&EO;B!43TM?4T5-20T*(" (#L-" T*:69?<W1A M=&5M96YT#0H (" .B!43TM?248 5$]+7U!!4D%.7T]014X 97AP<F5S<VEO M;B!43TM?4$%204Y?0TQ/4T4 <W1A=&5M96YT(&]P=%]E;'-E#0H (" .PT* M#0IO<'1?96QS90T*(" (#H +RH 96UP='D *B\-"B ("!\(%1/2U]%3%-% M('-T871E;65N= T*(" (#L-" T*=VAI;&5?<W1A=&5M96YT#0H (" .B!4 M3TM?5TA)3$4 5$]+7U!!4D%.7T]014X 97AP<F5S<VEO;B!43TM?4$%204Y? M0TQ/4T4 <W1A=&5M96YT#0H (" .PT*#0ID;U]W:&EL95]S=&%T96UE;G0- M"B (" Z(%1/2U]$3R!S=&%T96UE;G0 5$]+7U=(24Q%(%1/2U]005)!3E]/ M4$5.(&5X<')E<W-I;VX 5$]+7U!!4D%.7T-,3U-%#0H (" .PT*#0IF;W)? M<W1A=&5M96YT#0H (" .B!43TM?1D]2(%1/2U]005)!3E]/4$5.(&9O<E]I M;FET(%1/2U]314U)(&]P=%]E>'!R97-S:6]N(%1/2U]314U)(&]P=%]E>'!R M97-S:6]N(%1/2U]005)!3E]#3$]312!S=&%T96UE;G0-"B (" [#0H-"F9O M<E]I;FET#0H (" .B O*B!E;7!T>2 J+PT*(" ('P 97AP<F5S<VEO; T* M(" ('P =F%R:6%B;&5?9&5C;&%R871I;VX-"B (" [#0H-"G-W:71C:%]S M=&%T96UE;G0-"B (" Z(%1/2U]35TE40T 5$]+7U!!4D%.7T]014X 97AP M<F5S<VEO;B!43TM?4$%204Y?0TQ/4T4 8FQO8VM?<W1A=&5M96YT#0H (" M.PT*#0IC87-E7W-T871E;65N= T*(" (#H 5$]+7T-!4T4 97AP<F5S<VEO M;B!43TM?0T],3TX <W1A=&5M96YT#0H (" .PT*#0ID969A=6QT7W-T871E M;65N= T*(" (#H 5$]+7T1%1D%53%0 5$]+7T-/3$].('-T871E;65N= T* M(" (#L-" T*8V]N=&EN=65?<W1A=&5M96YT#0H (" .B!43TM?0T].5$E. M544 ;W!T7VED96YT:69I97( 5$]+7U-%34D-"B (" [#0H-"F)R96%K7W-T M871E;65N= T*(" (#H 5$]+7T)214%+(&]P=%]I9&5N=&EF:65R(%1/2U]3 M14U)#0H (" .PT*#0IR971U<FY?<W1A=&5M96YT#0H (" .B!43TM?4D54 M55).(&]P=%]E>'!R97-S:6]N(%1/2U]314U)#0H (" .PT*#0IG;W1O7W-T M871E;65N= T*(" (#H 5$]+7T=/5$\ :61E;G1I9FEE<B!43TM?4T5-20T* M(" (#L-" T*=VET:%]S=&%T96UE;G0-"B (" Z(%1/2U]7251((%1/2U]0 M05)!3E]/4$5.(&5X<')E<W-I;VX 5$]+7U!!4D%.7T-,3U-%(&)L;V-K7W-T M871E;65N= T*(" (#L-" T*<WEN8VAR;VYI>F5D7W-T871E;65N= T*(" M(#H 5$]+7U-93D-(4D].25I%1"!S=&%T96UE;G0-"B ("!\(%1/2U]364Y# M2%)/3DE:140 5$]+7U!!4D%.7T]014X 97AP<F5S<VEO;B!43TM?4$%204Y? M0TQ/4T4-"B (" [#0H-"G1R>5]S=&%T96UE;G0-"B (" Z(%1/2U]44ED M8FQO8VM?<W1A=&5M96YT(&-A=&-H97, ;W!T7V9I;F%L;'D-"B (" [#0H- M"F-A=&-H97,-"B (" Z(&QA<W1C871C: T*(" ('P 8V%T8V -"B ("!\ M(&-A=&-H(&-A=&-H97,-"B (" [#0H-"F-A=&-H#0H (" .B!43TM?0T%4 M0T 5$]+7U!!4D%.7T]014X <&%R86UE=&5R(%1/2U]005)!3E]#3$]312!B M;&]C:U]S=&%T96UE;G0-"B (" [#0H-"G!A<F%M971E< T*(" (#H 5$]+ M7U194$5.04U%(&ED96YT:69I97( +RH 5$]$3SH 9FEX("HO#0H (" .PT* M#0IL87-T8V%T8V -"B (" Z(%1/2U]#051#2"!B;&]C:U]S=&%T96UE;G0- M"B (" [#0H-"G1H<F]W7W-T871E;65N= T*(" (#H 5$]+7U1(4D]7(&5X M<')E<W-I;VX 5$]+7U-%34D-"B (" [#0H-"F]P=%]F:6YA;&QY#0H (" M.B O*B!E;7!T>2 J+PT*(" ('P 5$]+7T9)3D%,3%D 8FQO8VM?<W1A=&5M M96YT#0H (" .PT*#0IA<VU?<W1A=&5M96YT#0H (" .B!43TM?05--(&%S M;5]O<&5N(&]P=%]A<VU?:6YS=')U8W1I;VY?;&ES="!A<VU?8VQO<V4-"B M(" [#0H-"F%S;5]O<&5N#0H (" .B!43TM?0U523%E?3U!%3 T*(" (" M("![#0H (" (" (" ("!I<V%S;2 ](#$[#0H (" (" ('T-"B (" [ M#0H-"F%S;5]C;&]S90T*(" (#H 5$]+7T-54DQ97T-,3U-%#0H (" (" M('L-"B (" (" (" (&ES87-M(#T ,#L-"B (" (" ?0T*(" (#L- M" T*;W!T7V%S;5]I;G-T<G5C=&EO;E]L:7-T#0H (" .B O*B!E;7!T>2 J M+PT*(" ('P 87-M7VEN<W1R=6-T:6]N7VQI<W0-"B (" [#0H-"F%S;5]I M;G-T<G5C=&EO;E]L:7-T#0H (" .B!A<VU?:6YS=')U8W1I;VX-"B ("!\ M(&%S;5]I;G-T<G5C=&EO;B!43TM?4T5-22!A<VU?:6YS=')U8W1I;VY?;&ES M= T*(" (#L-" T*87-M7VEN<W1R=6-T:6]N#0H (" .B!43TM?5TE42$E. M7T%330T*(" ('P 5$]+7U=)5$A)3E]!4TT 87-M7VEN<W1R=6-T:6]N#0H M(" .PT*#0HO*BHJ*BHJ*B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; T*(" M(#L-" T*97AP<F5S<VEO; T*(" (#H 87-S:6=N;65N=%]E>'!R97-S:6]N M#0H (" ?"!E>'!R97-S:6]N(%1/2U]#3TU-02!A<W-I9VYM96YT7V5X<')E M<W-I;VX-"B (" [#0H-"F%S<VEG;FUE;G1?97AP<F5S<VEO; T*(" (#H M8V]N9&ET:6]N86Q?97AP<F5S<VEO; T*(" ('P 87-S:6=N;65N=%]E>'!R M97-S:6]N(&%S<VEG;FUE;G1?;W!E<F%T;W( 8V]N9&ET:6]N86Q?97AP<F5S M<VEO; T*(" (#L-" T*87-S:6=N;65N=%]O<&5R871O< T*(" (#H 5$]+ M7T51#0H (" ?"!43TM?4$Q54U]%40T*(" ('P 5$]+7TU)3E537T51#0H M(" ?"!43TM?4U1!4E]%40T*(" ('P 5$]+7U-,05-(7T51#0H (" ?"!4 M3TM?4$520T5.5%]%40T*(" ('P 5$]+7T%.1%]%40T*(" ('P 5$]+7T]2 M7T51#0H (" ?"!43TM?6$]27T51#0H (" ?"!43TM?3D5'7T51#0H (" M?"!43TM?3%1?3%1?15$-"B ("!\(%1/2U]'5%]'5%]%40T*(" ('P 5$]+ M7T=47T=47T=47T51#0H (" .PT*#0IC;VYD:71I;VYA;%]E>'!R97-S:6]N M#0H (" .B!L;V=I8V%L7V]R7V5X<')E<W-I;VX-"B ("!\(&QO9VEC86Q? M;W)?97AP<F5S<VEO;B!43TM?44U!4DL 97AP<F5S<VEO;B!43TM?0T],3TX M8V]N9&ET:6]N86Q?97AP<F5S<VEO; T*(" (#L-" T*;&]G:6-A;%]O<E]E M>'!R97-S:6]N#0H (" .B!L;V=I8V%L7V%N9%]E>'!R97-S:6]N#0H (" M?"!L;V=I8V%L7V]R7V5X<')E<W-I;VX 5$]+7T]27T]2(&QO9VEC86Q?86YD M7V5X<')E<W-I;VX-"B (" [#0H-"FQO9VEC86Q?86YD7V5X<')E<W-I;VX- M"B (" Z(&]R7V5X<')E<W-I;VX-"B ("!\(&QO9VEC86Q?86YD7V5X<')E M<W-I;VX 5$]+7T%.1%]!3D0 ;W)?97AP<F5S<VEO; T*(" (#L-" T*;W)? M97AP<F5S<VEO; T*(" (#H >&]R7V5X<')E<W-I;VX-"B ("!\(&]R7V5X M<')E<W-I;VX 5$]+7T]2('AO<E]E>'!R97-S:6]N#0H (" .PT*#0IX;W)? M97AP<F5S<VEO; T*(" (#H 86YD7V5X<')E<W-I;VX-"B ("!\('AO<E]E M>'!R97-S:6]N(%1/2U]83U( 86YD7V5X<')E<W-I;VX-"B (" [#0H-"F%N M9%]E>'!R97-S:6]N#0H (" .B!E<75A;&ET>5]E>'!R97-S:6]N#0H (" M?"!A;F1?97AP<F5S<VEO;B!43TM?04Y$(&5Q=6%L:71Y7V5X<')E<W-I;VX- M"B (" [#0H-"F5Q=6%L:71Y7V5X<')E<W-I;VX-"B (" Z(')E;&%T:6]N M86Q?97AP<F5S<VEO; T*(" ('P 97%U86QI='E?97AP<F5S<VEO;B!E<75A M;&ET>5]O<&5R871O<B!R96QA=&EO;F%L7V5X<')E<W-I;VX-"B (" [#0H- M"F5Q=6%L:71Y7V]P97)A=&]R#0H (" .B!43TM?15%?15$-"B ("!\(%1/ M2U].3U1?15$-"B ("!\(%1/2U]%45]%45]%40T*(" ('P 5$]+7TY/5%]% M45]%40T*(" (#L-" T*<F5L871I;VYA;%]E>'!R97-S:6]N#0H (" .B!S M:&EF=%]E>'!R97-S:6]N#0H (" ?"!R96QA=&EO;F%L7V5X<')E<W-I;VX M<F5L871I;VYA;%]O<&5R871O<B!S:&EF=%]E>'!R97-S:6]N#0H (" .PT* M#0IR96QA=&EO;F%L7V]P97)A=&]R#0H (" .B!43TM?3%0-"B ("!\(%1/ M2U],5%]%40T*(" ('P 5$]+7T=4#0H (" ?"!43TM?1U1?15$-"B ("!\ M(%1/2U].3U1?3%1?1U1?15$-"B ("!\(%1/2U].3U1?3%1?1U0-"B ("!\ M(%1/2U],5%]'5 T*(" ('P 5$]+7TQ47T=47T51#0H (" ?"!43TM?3D]4 M7T=4#0H (" ?"!43TM?3D]47T=47T51#0H (" ?"!43TM?3D]47TQ4#0H M(" ?"!43TM?3D]47TQ47T51#0H (" ?"!43TM?24X-"B (" [#0H-"G-H M:69T7V5X<')E<W-I;VX-"B (" Z(&%D9&ET:79E7V5X<')E<W-I;VX-"B M("!\('-H:69T7V5X<')E<W-I;VX <VAI9G1?;W!E<F%T;W( 861D:71I=F5? M97AP<F5S<VEO; T*(" (#L-" T*<VAI9G1?;W!E<F%T;W(-"B (" Z(%1/ M2U],5%],5 T*(" ('P 5$]+7T=47T=4#0H (" ?"!43TM?1U1?1U1?1U0- M"B (" [#0H-"F%D9&ET:79E7V5X<')E<W-I;VX-"B (" Z(&UU;'1I<&QI M8V%T:79E7V5X<')E<W-I;VX-"B ("!\(&%D9&ET:79E7V5X<')E<W-I;VX M861D:71I=F5?;W!E<F%T;W( ;75L=&EP;&EC871I=F5?97AP<F5S<VEO; T* M(" (#L-" T*861D:71I=F5?;W!E<F%T;W(-"B (" Z(%1/2U]03%53#0H M(" ?"!43TM?34E.55,-"B ("!\(%1/2U].14<-"B (" [#0H-"FUU;'1I M<&QI8V%T:79E7V5X<')E<W-I;VX-"B (" Z('5N87)Y7V5X<')E<W-I;VX- M"B ("!\(&UU;'1I<&QI8V%T:79E7V5X<')E<W-I;VX ;75L=&EP;&EC871I M=F5?;W!E<F%T;W( =6YA<GE?97AP<F5S<VEO; T*(" (#L-" T*;75L=&EP M;&EC871I=F5?;W!E<F%T;W(-"B (" Z(%1/2U]35$%2#0H (" ?"!43TM? M4TQ!4T -"B ("!\(%1/2U]015)#14Y4#0H (" .PT*#0IU;F%R>5]E>'!R M97-S:6]N#0H (" .B!P;W-T9FEX7V5X<')E<W-I;VX-"B ("!\(%1/2U]! M3D0 =6YA<GE?97AP<F5S<VEO; T*(" ('P 5$]+7U!,55-?4$Q54R!U;F%R M>5]E>'!R97-S:6]N#0H (" ?"!43TM?34E.55-?34E.55, =6YA<GE?97AP M<F5S<VEO; T*(" ('P 5$]+7U-405( =6YA<GE?97AP<F5S<VEO; T*(" M('P 5$]+7TU)3E53('5N87)Y7V5X<')E<W-I;VX-"B ("!\(%1/2U]03%53 M('5N87)Y7V5X<')E<W-I;VX-"B ("!\(%1/2U].3U0 =6YA<GE?97AP<F5S M<VEO; T*(" ('P 5$]+7TY%1R!U;F%R>5]E>'!R97-S:6]N#0H (" ?"!4 M3TM?1$5,151%('5N87)Y7V5X<')E<W-I;VX-"B ("!\(%1/2U].15< ;F5W M7V5X<')E<W-I;VX-"B ("!\(%1/2U]005)!3E]/4$5.(%1/2U]465!%3D%- M12!43TM?4$%204Y?0TQ/4T4 =6YA<GE?97AP<F5S<VEO; T*(" ('P 5$]+ M7U!!4D%.7T]014X 5$]+7U194$5.04U%(%1/2U]005)!3E]#3$]312!43TM? M1$]4(&ED96YT:69I97(-"B (" [#0H-"G!O<W1F:7A?97AP<F5S<VEO; T* M(" (#H <')I;6%R>5]E>'!R97-S:6]N#0H (" ?"!P;W-T9FEX7V5X<')E M<W-I;VX 5$]+7T1/5"!I9&5N=&EF:65R#0H (" ?"!P;W-T9FEX7V5X<')E M<W-I;VX 5$]+7U!,55-?4$Q54PT*(" ('P <&]S=&9I>%]E>'!R97-S:6]N M(%1/2U]-24Y54U]-24Y54PT*(" ('P <&]S=&9I>%]E>'!R97-S:6]N(%1/ M2U]005)!3E]/4$5.(&]P=%]A<F=U;65N=%]L:7-T(%1/2U]005)!3E]#3$]3 M10T*(" ('P <&]S=&9I>%]E>'!R97-S:6]N(%1/2U]"4D%#2T547T]014X M97AP<F5S<VEO;B!43TM?0E)!0TM%5%]#3$]310T*(" (#L-" T*<')I;6%R M>5]E>'!R97-S:6]N#0H (" .B!43TM?241%3E1)1DE%4 T*(" ('P 5$]+ M7U1(25,-"B ("!\(%1/2U]355!%4 T*(" ('P ;G5L;%]L:71E<F%L#0H M(" ?"!B;V]L7VQI=&5R86P-"B ("!\(&YU;65R:6-?;&ET97)A; T*(" M('P <W1R:6YG7VQI=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" [#0H-"FYU;65R:6-?;&ET97)A; T*(" (#H M:6YT96=E<E]L:71E<F%L#0H (" ?"!F;&]A=%]L:71E<F%L#0H (" .PT* M#0II;G1E9V5R7VQI=&5R86P-"B (" Z(%1/2U])3E1%1T527TQ)5$5204P- M"B (" [#0H-"F9L;V%T7VQI=&5R86P-"B (" Z(%1/2U]&3$]!5%],251% M4D%,#0H (" .PT*#0IS=')I;F=?;&ET97)A; T*(" (#H 5$]+7U-44DE. M1U],251%4D%,#0H (" ?"!S=')I;F=?;&ET97)A;"!43TM?4U1224Y'7TQ) 45$5204P-"B (" [#0H-"B4E#0H` ` end
Jun 11 2002
next sibling parent reply "Walter" <walter digitalmars.com> writes:
Why not just use lexer.c and parse.c more or less directly?
Jun 11 2002
next sibling parent C.R.Chafer <blackmarlin nospam.asean-mail.com> writes:
Walter wrote:

 Why not just use lexer.c and parse.c more or less directly?
No offence, but they are written in C++, which will not interface to BTL and would probably be a pain to interface to GCC. And anyway the best way to understand a language fully is to write a compiler for it. PS: Thanks to MMP for the parser yacc source, my version mainly consists of rebuilding a grammar I wrote some time ago to parse oomic - just got some shift/reduce conflicts to resolve. C 2002/6/12
Jun 12 2002
prev sibling parent "Martin M. Pedersen" <mmp www.moeller-pedersen.dk> writes:
"Walter" <walter digitalmars.com> wrote in message
news:ae60k2$iq5$1 digitaldaemon.com...
 Why not just use lexer.c and parse.c more or less directly?
My reasons are the same as described by C.R.Chafer, portability and understanding. Also, using a tool like bison documents the grammar, makes it easier to maintain and experiment with, and it pinpoints ambiguties in the grammar. Regards, Martin M. Pedersen
Jun 12 2002
prev sibling parent reply Erik de Castro Lopo <nospam mega-nerd.com> writes:
"Martin M. Pedersen" wrote:
 
 It seems you have started what I did too :-) However, I ran into problems
 with the declaration grammar. The problem is that bison does not do N
 look-ahead that seems to be required by the D grammar - at least if
 "parse.c" is to be translated more or less directly. The problem is the
 Parse::is...() methods in "parse.c" that makes the grammar LALR(N). I have
 not figured out any way to solve this problem. Another problem is that you
 cannot easily destinguish type names from other names as in C. If you find
 your way around these problems, I would very much like to hear about it. I
 stopped for these reasons.
Bison is also able to generate GLR parsers (since 1.50) via the "%glr-parser" option. Have you looked that using this? Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ Fundamentalist : Someone who is colour blind and yet wants everyone else to see the world with the same lack of colour.
Jul 09 2004
parent reply "Nicolas Lehuen" <nicolas.lehuen thecrmcompany.com> writes:
I'm not expert in the parsing department, but I used ANTLR =
(http://www.antlr.org/) which is a LL(k) parser generator, outputing =
Java, C# or C++. Maybe they could be nudged into generating D code as =
well ?

Regards,
Nicolas Lehuen

"Erik de Castro Lopo" <nospam mega-nerd.com> a =E9crit dans le message =
de news:40EF24E3.B5BE2EB5 mega-nerd.com...
 "Martin M. Pedersen" wrote:
=20
 It seems you have started what I did too :-) However, I ran into =
problems
 with the declaration grammar. The problem is that bison does not do =
N
 look-ahead that seems to be required by the D grammar - at least if
 "parse.c" is to be translated more or less directly. The problem is =
the
 Parse::is...() methods in "parse.c" that makes the grammar LALR(N). =
I have
 not figured out any way to solve this problem. Another problem is =
that you
 cannot easily destinguish type names from other names as in C. If =
you find
 your way around these problems, I would very much like to hear about =
it. I
 stopped for these reasons.
=20 Bison is also able to generate GLR parsers (since 1.50) via the=20 "%glr-parser" option. Have you looked that using this? =20 Erik --=20 +-----------------------------------------------------------+ Erik de Castro Lopo nospam mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ Fundamentalist : Someone who is colour blind and yet wants everyone else to see the world with the same lack of colour.
Oct 01 2004
parent Deja Augustine <deja scratch-ware.net> writes:
Nicolas Lehuen wrote:
 I'm not expert in the parsing department, but I used ANTLR
(http://www.antlr.org/) which is a LL(k) parser generator, outputing Java, C#
or C++. Maybe they could be nudged into generating D code as well ?
 
 Regards,
 Nicolas Lehuen
 
 "Erik de Castro Lopo" <nospam mega-nerd.com> a écrit dans le message de
news:40EF24E3.B5BE2EB5 mega-nerd.com...
 
"Martin M. Pedersen" wrote:

It seems you have started what I did too :-) However, I ran into problems
with the declaration grammar. The problem is that bison does not do N
look-ahead that seems to be required by the D grammar - at least if
"parse.c" is to be translated more or less directly. The problem is the
Parse::is...() methods in "parse.c" that makes the grammar LALR(N). I have
not figured out any way to solve this problem. Another problem is that you
cannot easily destinguish type names from other names as in C. If you find
your way around these problems, I would very much like to hear about it. I
stopped for these reasons.
Bison is also able to generate GLR parsers (since 1.50) via the "%glr-parser" option. Have you looked that using this? Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ Fundamentalist : Someone who is colour blind and yet wants everyone else to see the world with the same lack of colour.
To the best of my knowledge, Andy Friesen on the d.D newsgroup posted his D ANTLR grammar. Might be able to save yourself some work. -Deja
Oct 02 2004