www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Flex file for the D programming language

reply "Casper Ellingsen" <no reply.com> writes:
I need a flex file for the D programming language. So, I was just  
wondering of anyone of you guys know where I can find an already existing  
one? Or do I have to make one from scratch?

Casper
-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Dec 30 2005
next sibling parent J C Calvarese <technocrat7 gmail.com> writes:
In article <op.s2lmqbuge7y2tg casper.c-map.no>, Casper Ellingsen says...
I need a flex file for the D programming language. So, I was just  
wondering of anyone of you guys know where I can find an already existing  
one? Or do I have to make one from scratch?

Casper

(I assume you mean this flex: http://www.gnu.org/software/flex/) I don't think I've heard of anyone creating a flex file for D because I think if I had heard of such an effort I would've added a mention to this wiki page: http://www.prowiki.org/wiki4d/wiki.cgi?GrammarParsers jcc7
Dec 30 2005
prev sibling next sibling parent reply Manfred Nowak <svv1999 hotmail.com> writes:
Casper Ellingsen wrote:

 I need a flex file for the D programming language.

Never heard that flex does support unicode. If flex does not support unicode then only a subset of D can be read. -manfred
Dec 30 2005
parent reply "Casper Ellingsen" <no reply.com> writes:
On Fri, 30 Dec 2005 21:03:20 +0100, Manfred Nowak <svv1999 hotmail.com>  
wrote:

 Casper Ellingsen wrote:

 I need a flex file for the D programming language.

Never heard that flex does support unicode. If flex does not support unicode then only a subset of D can be read. -manfred

I'm pretty sure flex supports unicode. Correct me if I'm wrong though. -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Dec 30 2005
parent Manfred Nowak <svv1999 hotmail.com> writes:
Casper Ellingsen wrote:

[...]
 I'm pretty sure flex supports unicode. Correct me if I'm wrong
 though. 

That reads as if you are not willing to do any tests yourself prior to acquiring help from the community. The flex of my cygwin installaton, which is up to date, creates lexers, that read into an `extern char* yytext;'. Maybe we have different definitions for "support". -manfred
Dec 30 2005
prev sibling next sibling parent reply Chris Lajoie <ctlajoie___remove___this___ ___gmail.com> writes:
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Casper Ellingsen wrote:
 I need a flex file for the D programming language. So, I was just 
 wondering of anyone of you guys know where I can find an already 
 existing one? Or do I have to make one from scratch?

I have a mostly complete lexer written for ANTLR. It shouldn't be too hard to convert to flex, but I recommend you rewrite each rule individually to make sure I didn't screw up ;) (let me know if I did and it's not noted in the comments). Anything that is not handled correctly by my ANTLR lexer (that I am aware of) is noted in a comment prefixed with TODO: or BUG:. I have tried it on several of the largest files in phobos and it scanned each of them correctly, so it is complete enough for most D files. I understand there was another project doing this noted in the wiki, but it has been a dead link for some time now. Chris
Dec 30 2005
parent "Casper Ellingsen" <no reply.com> writes:
On Sat, 31 Dec 2005 00:01:12 +0100, Chris Lajoie  
<ctlajoie___remove___this___ ___gmail.com> wrote:

 Casper Ellingsen wrote:
 I need a flex file for the D programming language. So, I was just
 wondering of anyone of you guys know where I can find an already
 existing one? Or do I have to make one from scratch?

I have a mostly complete lexer written for ANTLR. It shouldn't be too hard to convert to flex, but I recommend you rewrite each rule individually to make sure I didn't screw up ;) (let me know if I did and it's not noted in the comments). Anything that is not handled correctly by my ANTLR lexer (that I am aware of) is noted in a comment prefixed with TODO: or BUG:. I have tried it on several of the largest files in phobos and it scanned each of them correctly, so it is complete enough for most D files. I understand there was another project doing this noted in the wiki, but it has been a dead link for some time now. Chris

Thanks! I'll wait and see what Carlos finds first, and then possible use yours as a base for my flex grammar file. Either way, I'll post my file once it's done for others to use. -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Dec 30 2005
prev sibling next sibling parent reply "Carlos Smith" <carlos.smith sympatico.ca> writes:
 I need a flex file for the D programming language. So, I was just
 wondering of anyone of you guys know where I can find an already existing
 one? Or do I have to make one from scratch?

I wrote one some months ago. Was quite complete at the time, but needs some work to make it up to date. Must search it, when found will post it here, tonight ( now it is 18h40 in Quebec City ). Carlos
Dec 30 2005
parent "Casper Ellingsen" <no reply.com> writes:
On Sat, 31 Dec 2005 00:38:13 +0100, Carlos Smith  
<carlos.smith sympatico.ca> wrote:

 I need a flex file for the D programming language. So, I was just
 wondering of anyone of you guys know where I can find an already  
 existing
 one? Or do I have to make one from scratch?

I wrote one some months ago. Was quite complete at the time, but needs some work to make it up to date. Must search it, when found will post it here, tonight ( now it is 18h40 in Quebec City ). Carlos

Sounds good. Let me know if you find it. -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Dec 30 2005
prev sibling parent "Carlos Smith" <carlos.smith sympatico.ca> writes:
"Casper Ellingsen" <no reply.com> wrote in message
news:op.s2lmqbuge7y2tg casper.c-map.no...
 I need a flex file for the D programming language. So, I was just

I found the files. (dated March 2005) Using flex 2.5.4 and bison 2.1 from the MingW32 distribution. D.y is an almost empty grammar for D. Just enough to allow bison to produce a header for the tokens. # bison -d -odtab.c d.y will produce dtab.h # flex -Cem -Bs8 -odlex.c d.l will produce dlex.c # gcc -O2 -DYYMAIN -odlex.exe -s gives a program to test. # dlex < somefile.d produce a list of tokens on stdout. Carlos
Dec 30 2005