[PLUG-Devel] Profiling a new programming language

Darrin Chandler dwchandler at stilyagin.com
Thu Nov 13 07:33:33 MST 2008


> To stave off my boredom I've decided to take up creating a programming
> language specifically for creating long repetitive text documents
> (like repetitive resource definitions) where simple ctrl-c ctrl-v
> won't work, like incrementing ID's, filenames within definitions, etc.
> 
> Basically, I have created, what I believe will be the sample script
> input file (which I have attached, along with the target generated
> file) so that I have a goal to aim for.
> 
> What would be the best way to start by developing this tool? I have
> never done any programming real down to the core like this, nothing
> with a lot of text parsing before... How would I best attack creating
> an interpreter?  I plan on making it in C so that it is fairly
> portable sourcewise, unless I am presented a better option of course
> :)

The "best" way to start is to sketch out some of the most common usage
cases and come up with a grammar that lets you express the solution in a
concise way. It sounds like you've already started. Good! Do some more,
and try to think of "edge" cases.

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!

Beware of cobbling together a language by hacking it together. MS did
this with their "shell" and for decades it has suffered from bugs and
inconsistent behavior. If you start with a spec in BNF then you can
change or extend your BNF and regenerate correct parsing code. Or if
you're using Perl/Python/Ruby/Awk rather than C you still have the BNF
to serve as a design.

One further bit of advice: consider writing this as a unix-style
"filter" program rather than an interpreter. Or at least make your
interpreter capable of running as a filter. The problem as you've stated
it screams filter.

-- 
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/20081113/b7895597/attachment.pgp 


More information about the PLUG-devel mailing list