12

Say, for example, I wanted to pay somebody to create a programming language or scripting language for me. What type of document would they need, in order to fully understand what it is exactly that I want.

I mean, are there standard documents that describe the new programming/scripting language in question?

sepp2k
  • 4,329
J.T.S.
  • 299

5 Answers5

16

What you need to write is called a language specification.

It should contain a description of the language's grammar (preferably in Extended Backus-Naur-Form) and its semantics.

For the latter part you could either write a description in your own words (but take care to be precise) or a formal semantics.

sepp2k
  • 4,329
13

You will need the following:

  • A reason for creating a new language
  • A Philosophy
  • A Semantic Definition
  • A lexical description of your tokens
  • A Syntax Analysis definition

How will your language be different? What is its mission? Is it functional? Is it object orientated? Is it a meta-language? What are its unique features? What will it give the world that doesn't exist (or exists in an ugly way)? How do you want to change things? Is it compiled or interpreted? A DSL or general purpose language? This is your philosophy and dictates alot about your language's design.

Next, work on scratching out rough syntax and semantics on paper. This will be your semantic definition ... writing fake code is a great way to develop your thoughts. Read "The C Programming Language" for an excellent example of how this is done. Play with it.

You will then need to define your tokens and syntax in some way. Programs then process these into automata capable of reading in strings and processing the syntax. Yacc and Bison use Regular Expressions and a BNF style syntax for lexical and syntax analysis respectively. There are also Yacc and Bison like tools in for other languages.

You will also need a grounding in language theory/compilers to know what NOT to do. Examples include ambiguous grammars, AST generation and manipulation problems and generally how to make life simple for yourself. Knowing the theory is very important. I would consider getting the following to start off:

Compilers: Principles, Techniques and Tools (Dragon Book)
Modern Compiler Implementation in C or Modern Compiler Implementation in Java

8

99.9% of the time creating a new language is completely unnecessary. The return on investment would most likely be tiny, and you would have just wasted your time.

Most likely you can use Javascript as a susceptible scripting language, and there are parsers available for most languages already. You can also use other scripting languages you like if you can find a suitable parser for them. Implementing those into your program would require much less work and have a bigger return. People don't have to learn another language, they just have to learn your API. Its a much better solution.

Creating a new language is almost always bad.

Bryan Oakley
  • 25,479
TheLQ
  • 13,650
  • 7
  • 56
  • 88
3

You can describe your language's grammar in BNF.

For instance, this is Python's grammar.

grokus
  • 7,528
  • 4
  • 32
  • 46
0

if you're using .NET, here is something I stumbled across some time back. I only gave it a curious glance, but maybe it would be use to you: irony.

Irony is a development kit for implementing languages on .NET platform.

svick
  • 10,137
  • 1
  • 39
  • 53
DevSolo
  • 2,814