Fedora Linux Support Community & Resources Center
  #1  
Old 6th April 2012, 07:26 PM
Mepoe Offline
Registered User
 
Join Date: Oct 2011
Posts: 110
linuxopera
How do you create your own programming language hmm?

It's remarkably annoying to find information on this subject. I found this ebook...

http://gilesbowkett.blogspot.co.uk/2...g-awesome.html

Anyone find anything else or have extra tips? (I can't purchase hard copies of books because quite frankly, I have nowhere to put them)


Disclaimer
This thread is to make it easier to find information on the net and perhaps get someone into learning the basics who wouldn't ordinarily know how to go about it. A sort of collection of resources that anyone could have access to. I'm not really after answers like, "Learn C++" or "Get a better understanding of programming languages"...that's the whole point after all.
Reply With Quote
  #2  
Old 6th April 2012, 08:29 PM
jpollard Online
Registered User
 
Join Date: Aug 2009
Location: Waldorf, Maryland
Posts: 6,860
linuxfirefox
Re: How do you create your own programming language hmm?

"Using C with Curses, Lex, and YACC".

A bit dated, and there are newer sources that include bison, but there are a ton of web sources available about using lex/flex and YACC/Bison. (I recommend flex/bison as they are more common, and have less restrictions on the grammar definition.)

The bigger problem has nothing to do with the tools, but with what you are trying to do...

Documenting that, and creating proposed language constructs for the problem domain are hard. Then there is the generalizing of the identified constructs into the problem domain use.

Small problem domain languages are simpler - usually used for configuration files, and do not need complex grammar.

It really depends on what you are trying to do. Complete general purpose languages are hard, and can take a year or more to get functional. A small language (a testbed for a library for instance) can be done in a week or so. Creating a compiler/translator or interpreter for an already defined language is now a semester project (3 to 4 people mind).
Reply With Quote
  #3  
Old 6th April 2012, 09:16 PM
Mepoe Offline
Registered User
 
Join Date: Oct 2011
Posts: 110
linuxopera
Re: How do you create your own programming language hmm?

Okay, I'm assuming that the 'new' language would be built off assembly (like I assume C is?). How about outputting the words 'Hello World' in your own language. =P

I think that's what most people who want to create their language want to do, they just want to do it in their own way. (or I could be wrong XD)
Reply With Quote
  #4  
Old 6th April 2012, 09:45 PM
jpollard Online
Registered User
 
Join Date: Aug 2009
Location: Waldorf, Maryland
Posts: 6,860
linuxfirefox
Re: How do you create your own programming language hmm?

gcc is a translator - it creates a linearized tree structure that is passed to a code generator (one way to think of the tree structure is a LISP s-expression that is equivalent to the semantics of the program, the s-expression is converted to assembly/object code by the code generator. Optimization can be (or is) done on the intermediate code, resulting in more intermediate code. The C translator does not use assembly directly. Now SOME compilers have, or could, go directly to assembly or object code. It is just more efficient to make different passes handle different things.

And again, a "hello World" program is a proposed language construct... How large a language you want depends on how general you need it to be.

btw, gcc is a member of a family of compilers, all using the same code generator. This makes it easier to add a new language (no need for another code generator, linker, librarian,... Just add a new translator. Or add an optimizer...

Completely general languages do exist... though the IBM Watson interpreter is rather expensive, and even after years of development, has more to go.
Reply With Quote
  #5  
Old 9th April 2012, 02:00 PM
Alberth5674764 Offline
Registered User
 
Join Date: Nov 2011
Posts: 35
linuxfirefox
Re: How do you create your own programming language hmm?

There are at least three levels of 'making a language'.

The highest is about the language itself. You start with a blank sheet of paper, and fill in what language constructs you have and what they mean.
For example what is the high level block structure, a function, a class, a process, a definition ?
Do you have variables?
Do you have an assignment statement? (yes, there is a class of languages that does not have an assignment statement). If you do, what does "y = x" mean, do you copy the content of x to y, copy a reference, replace all y in the program by x ?
What operators do you have, a '+' ? does it do add, merge, union, or something else?

In other words, you define what is in the language, and if you write something down, what it means.


At the intermediate level, you need a program that takes a file with a program in your language in it, and does something useful with it. Just like gcc takes a C file, and compiles it.
There is a lot of information here, look for stuff with keywords compilers, compiler construction, ast, code generator/generation.

At the lowest level, the above program is pretty big and complex, so there are parts of it which are covered by other software. Lex and Yacc are famous examples. Look for stuff labeled with parsers, scanners, parser construction, compiler toolkit
Reply With Quote
  #6  
Old 9th April 2012, 04:49 PM
AndrewSerk Offline
Registered User
 
Join Date: Oct 2010
Posts: 889
linuxredhatfirefox
Re: How do you create your own programming language hmm?

I just ran across a thread about a fine young student building a new programming language.

Quote:
The language from the funky title works off the notion of the Graph datastructure (google if you're not familiar), the idea is small amounts of code are put in the nodes and on the arcs are weights that are conditions, the last operation done in the node will be checked against these conditions and if anything meets it's condition it will follow the arc and run the code in that node. It's a funky idea and something different from our imperative, precedural, OOP, functional and declarative. I believe I am the first to do a language like this.

You can download the 0.0.3 version (current version) from my site
Crayon 0.0.3
The thread can be found at :http://scientificlinuxforum.org/inde...=0&#entry10570
Reply With Quote
  #7  
Old 10th April 2012, 06:28 PM
jpollard Online
Registered User
 
Join Date: Aug 2009
Location: Waldorf, Maryland
Posts: 6,860
linuxfirefox
Re: How do you create your own programming language hmm?

Yes, but it isn't a new idea.

Way back in the FORTRAN days I believe (well, read an old paper) on using a flowchart for the input to a translator.

The big problem at the time was what is called a GUI - the devices were horribly expensive.

Another view of the same problem is an ATM (meaning augmented transition matrix) and is used by nearly every video game, whether they call it that or not.
Reply With Quote
  #8  
Old 23rd April 2012, 12:16 AM
stevea Online
Registered User
 
Join Date: Apr 2006
Location: Ohio, USA
Posts: 8,874
linuxfirefox
Re: How do you create your own programming language hmm?

Quote:
Originally Posted by jpollard View Post
gcc is a translator - it creates a linearized tree structure that is passed to a code generator (one way to think of the tree structure is a LISP s-expression that is equivalent to the semantics of the program, the s-expression is converted to assembly/object code by the code generator. Optimization can be (or is) done on the intermediate code, resulting in more intermediate code. The C translator does not use assembly directly. Now SOME compilers have, or could, go directly to assembly or object code. It is just more efficient to make different passes handle different things.
"translator" is meaningless in this context; no one expects a compiler interprets the source language.
The "abstract syntax tree" generated for the languages of GCC (C, C++, objective-C, Ada, Fortran ...) is not linear, and not linearizable. The representation of the tree can be linear - but that's not important.
The allusion to s-expressions is not helpful to many readers - red herring, pompous flourish.
The resulting parse tree is not passed to the code generator. It's translated to GIMPLE a BNF variant with no more than 3 operators (still not linear) - .... to avoid belaboring the flaws - here is a diagram of the represenation states for any GCC compiler.
http://en.wikibooks.org/wiki/GNU_C_C...r_Architecture
Code gen occurs from the RTL reprentation - far away from the parse tree.

Quote:
And again, a "hello World" program is a proposed language construct... How large a language you want depends on how general you need it to be.
Generality is not a well-ordered quantity - nonsense claim, noise.


Quote:
btw, gcc is a member of a family of compilers, all using the same code generator. This makes it easier to add a new language (no need for another code generator, linker, librarian,... Just add a new translator. Or add an optimizer...
And also allows for replacement of the back-end - as in the case of LLVM.

Quote:
Completely general languages do exist... though the IBM Watson interpreter is rather expensive, and even after years of development, has more to go.
There is no concept as "completely general language". Any representation of input to a Turing machine is a sufficiently general language to map all software. So like it or not BASIC has completely equivalent representational capability as Haskell, Prolog, or JAVA. Obviously there are substantial difference in the expressiveness - but again 'expressiveness' is not well-ordered quantity.

There is no "Watson Interpreter" language, for IBM's Watson AI system - the SW was written in C++, Java, Prolog, Hadoop framework (which is a very interesting thing) ... IOW conventional languages. Maybe you mean "natural language interpreter" of Watson, but that's a different matter, unrelated to his thread.
__________________
None are more hopelessly enslaved than those who falsely believe they are free.
Johann Wolfgang von Goethe
Reply With Quote
Reply

Tags
create, hmm, language, programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming language. The Mishanator Programming & Packaging 13 12th November 2010 01:27 PM
D Programming Language sarahsman Programming & Packaging 2 25th December 2009 03:21 AM
ADA programming language? esnc Programming & Packaging 1 18th February 2009 04:22 AM
Favourite Programming Language? Lypin Programming & Packaging 124 17th June 2008 10:03 PM
Programming language deepfreeze Linux Chat 8 1st November 2005 08:20 PM


Current GMT-time: 14:28 (Thursday, 02-10-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat