[PLUG-Devel] Profiling a new programming language

Darrin Chandler dwchandler at stilyagin.com
Sat Nov 15 07:28:59 MST 2008


On Sat, Nov 15, 2008 at 12:31:23AM -0700, Ryan Rix wrote:
> On Thu November 13 2008 07:33:33 am Darrin Chandler wrote:
> > Once you've done that, you might want to put what you've got into a
> > formal notation such as BNF. If you can define it well enough then you
> > can turn to tools such as lex/flex & yacc/bison, which have been
> > designed to generate parsing code from specs. If you can't define your
> > language that well then you need to get to that point! Even if you end
> > up not using C/lex/yacc!
> >
> 
> So, I have a BNF, completely finished IMO (attached as well) but I'm not 
> entirely sure what to do with it... I ran it through this haskellmabob, but 
> it doesn't really 'do' anything (the source was empty as far as I could tell) 
> but... :)
> 
> /me is lost

Have a look here:
http://ds9a.nl/lex-yacc/cvs/lex-yacc-howto.html

No generator will magically make a complete compiler from BNF, since BNF
only describes the grammar. Lex/yacc will generate code to parse an
input program, but you must supply the actions of what happens.

Follow the above tutorial (it's pretty gentle) and you'll see that yacc
takes a notation quite like BNF, and you'll also see how you can specify
actions for a given input statement.

Note that writing a compiler or interpreter is not a trivial task. For
what you want, I think you can do it. But expect to do some head
scratching, reading, backtracking from wrong approaches, etc.

Keep us informed. I suspect I'm not the only person interested in
compilers/interpreters on this list!

> 
> # these are just useful
> crlf		::= %x0a; #really just an LF but who's counting?
> blank		::= [{' '|'\t'|'\n'|'\r'}];
> digit 		::= %x30-39;
> number		::= {digit};
> letter		::= %d65-90 | %d97-102 | %d46;
> symbol		::=  %x21-2f | %x3a-3f | %x5b-60 | %x7b-7e;
> string		::= {letter};
> string_sp	::= {letter | blank | expandme };
> string_regex	::= {letter | blank | symbol | expandme};
> 
> comment	::= %x23 string_regex crlf; # all text after a # and before a crlf
> expandme	::= "${" defid [{"," option}] "}"; #  this says "hey expand me, dude!" to a definition!
> 
> #these are main section identifiers
> begindefine	::= "$define$";
> enddefine	::= "$enifed$";
> begintext	::= "$text$";
> endtex		::= "$txet$";
> 
> # Definitions
> definition	::= defid ":" deftype [{crlf defargs}] crlf [{arguments}];
> defid		::= digit;
> deftype		::= string;
> 
> # Arguments
> arguments	::= ">" argument crlf;
> argument	::= options | pattern | text | initval | computation;
> options		::= "opts:" option [{","option}];
> pattern		::= "pattern:" string_regex;
> text		::= "text:" string_regex;
> initval		::= "initval:" number;
> computation	::= string_regex;
> 
> option		::= string



> _______________________________________________
> PLUG-devel mailing list  -  PLUG-devel at lists.PLUG.phoenix.az.us
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-devel


-- 
Darrin Chandler            |  Phoenix BSD User Group  |  MetaBUG
dwchandler at stilyagin.com   |  http://phxbug.org/      |  http://metabug.org/
http://www.stilyagin.com/  |  Daemons in the Desert   |  Global BUG Federation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.PLUG.phoenix.az.us/pipermail/plug-devel/attachments/20081115/c33921de/attachment.pgp 


More information about the PLUG-devel mailing list