A bunch of cunts, mostly in the Australian sense. Except that one guy.

does anyone know of a program that makes creating a new language

...easy?

...http://www.1729.com/blog/MetaprogrammingFiveKindsOfSourceCode.html


looks interesting.  I would like to try creating a domain specific language.


where should I start?
Permalink worldsSmallestViolin 
September 26th, 2006 12:16am
If syntax is not a problem the XML works fine.
If so some of the model driven programming tools might be useful. And there bison/lex/yacc of course. Ruby allows eash embedding of DSLs.
Permalink son of parnas 
September 26th, 2006 12:19am
You might start by thinking of a domain.
Permalink cpm 
September 26th, 2006 12:40am
LISP Macros?


hahahahahahahahahaha!
Permalink Send private email a2800276 
September 26th, 2006 5:43am
Lex/Yacc -- also 'Bison'.
Permalink SaveTheHubble 
September 26th, 2006 9:19am
That link is very clever.  I like his dividing the artifacts into 5 parts.  Calling them all 'source' seems excessive, but what the hey.

The problem with the "Simple way of creating a new language" is that the infrastructure for even a "simple" language tends to be large.

1.  You need to define the Grammar, including Syntax and Language Tokens (keywords). 

2.  You need to remove ambiguities, or provide unambiguous ways to resolve them.

3.  Then you need Tokenizing of the language Tokens. 

4.  Then you need Syntax analysis of the Tokens, that they match the Grammar. 

5.  Then you need Semantic Action insertion into the Grammar, so that when 'Syntax' pieces are 'recognized' by the 'Parser', the appropriate output code generation occurs.

6.  Then you need some vanilla 'Engine' which can be customized so that it "turns the crank" on all of this.

7.  Then you probably need a 'library' of 'primitive calls' that the compiler knows about, in order to do 'common' things efficiently.

Any useful "compiler" for any computer language requires the above 6 pieces.  Lex will give you #3 above, Yacc provides a framework for doing 4, 5, and 6.

Sadly, that's the current "state of the art" for producing new languages, no matter how trivial.
Permalink SaveTheHubble 
September 26th, 2006 9:31am
As the article says, use ANTLR not flex/bison.
Permalink Send private email Wayne (AHA) 
September 26th, 2006 12:28pm
Thanks for the link.  There are very few books on creating a new language, and none I have ever found that make it easy.
Permalink Send private email Aaron F Stanton 
September 26th, 2006 12:48pm
http://www.apress.com/book/bookDisplay.html?bID=213

Very helpful for me.  Easiest book on the subject, EVAR.
Permalink Send private email sharkfish 
September 26th, 2006 1:35pm
Sweet... thanks sharkfish, I might have to look into that sometime in the next 5 years or so when I have the time.  ;(
Permalink Send private email Wayne (AHA) 
September 26th, 2006 1:42pm
It is a sweet little number.  You might want to _make_ time for that baby.

I can speak reasonably intelligently about Backus-Naur, and in my head, I'm always thinking about ways to apply the new knowledge.  He steps through writing a "DSL" for a calculator, then works all the way up through an actual language (a VB variant, blech).  I used it and I wrote a _very rudimentary_ language for creating web pages/HTML.  I know, stupid, but well, whatever.

The parsing and scanning techniques are very useful as well.

The problem with the book is that he doesn't really create a compiler that compiles to MSIL.  That is very disappointing.  However, after you read this book, as a novice, you'll be much closer to the goal of doing so and you can then read some of those academic books on compilers and know what they are talking about.

Interesting links:
http://msdn.microsoft.com/vstudio/dsltools/
http://weblog.jamisbuck.org/2006/4/20/writing-domain-specific-languages

(I love the PB&J example)
Permalink Send private email sharkfish 
September 26th, 2006 2:03pm
"It is a sweet little number.  You might want to _make_ time for that baby."

Maybe.  I took language design in University and created a little programming language and virtual machine.  I've always wanted to do it more seriously.

"The problem with the book is that he doesn't really create a compiler that compiles to MSIL."

That's rather disappointing..  you'd think that would be the point!
Permalink Send private email Wayne (AHA) 
September 26th, 2006 2:06pm
I dunno then.  The book may be beneath your level.

I"m in love with the idea of DSLs.  Once I figured out they would help me do this:

Make Me HTML 
  title="yet another stupid html page"
  head
  body
  footer="footer.html"
End


I was sold.  Of course, that is the most obvious example.  Something less obvious would be a whole language that takes a base accounting system and lets you build modules with a few lines of code.

Sure, you could just roll your own Java API. 

Martin Fowler on DSL vs. API
http://www.martinfowler.com/bliki/DslBoundary.html
Permalink Send private email sharkfish 
September 26th, 2006 2:36pm

This topic is archived. No further replies will be accepted.

Other topics: September, 2006 Other topics: September, 2006 Recent topics Recent topics