Author Topic: A New Programming Language  (Read 10614 times)

0 Members and 1 Guest are viewing this topic.

Offline Ki1o

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 119
  • Rating: +5/-2
  • Doing my best...
    • View Profile
A New Programming Language
« on: February 24, 2012, 04:49:33 pm »
Many of you may not have noticed (or even cared for) my absence but I have been busy for the last couple of weeks.  I recently got accepted to a computer science research academy at my local college (I'm in high school) so thats what I have been doing.  I am creating an interpreted programming language in C++ using either BYACC, YACC or ANTLR for the parser and LEX or FLEX for the lexical analyzer.  If you have any ideas or suggestions or tips feel free to help out. Thanks.  :D

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: A New Programming Language
« Reply #1 on: February 24, 2012, 05:54:06 pm »
Can we have a Hello world in this fabulous new langage ;D ?

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: A New Programming Language
« Reply #2 on: February 24, 2012, 06:06:56 pm »
I'd like to see some basic syntax for this, and if I learn what/how to use the things you talked about I'd be glad to help. I'm kind of a noob in C++ so I might not be able to do much. I'm much better with python though I am learning C++
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: A New Programming Language
« Reply #3 on: February 24, 2012, 07:06:56 pm »
I'm with ruler in saying I'd like to see some syntax, but it sounds cool! I'm actually looking into compiler design myself, but not for direct machine code- I'm trying to use the .NET Framework as a base, but I'm going to create a parser, lexer, etc. all from scratch. I'm decent with C++, so if you need any help or anything feel free to ask.

Good luck!

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: A New Programming Language
« Reply #4 on: February 25, 2012, 05:24:42 am »
Wow, sounds very promising, creating a programming language with C++. I personally tried to learn C++, but didn't get much further than half the SAMS Teach Yourself C++, and also looked at C++ for Dummies. That's pretty much it for me. I mainly used Codeblocks when typing C++, a great GUI type program that can bundle in all the complier and code editing in a great looking program (you have to install the compiler separately, but some installers come bundled with mingw)

Good luck with your project!
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline Ki1o

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 119
  • Rating: +5/-2
  • Doing my best...
    • View Profile
Re: A New Programming Language
« Reply #5 on: February 25, 2012, 07:58:32 am »
Right now we are working on learning C++ a little more.  We are also working on learning BYACC, ANTLR, and LEX/FLEX.  Afterwards we can define the grammar and incorporate basic arithmetic as well as variables, loops, and control flow.
Right now we have named it M4Trix.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: A New Programming Language
« Reply #6 on: February 25, 2012, 09:41:18 am »
Seems interesting. Make sure, however, to start with the basics first, though, then work your way into the language depths, like with Axe Parser. This is to make sure you don't start too huge and won't get overwhelmed by the size and complexity of such project. An example of what I mean: Download Axe Parser v0.0.1 then a few other versions and see what was present in it at that time, then the author Quigibo added more and more.

It's also good to not make the syntax too complicated but still quite readable and short.
« Last Edit: February 25, 2012, 09:41:58 am by DJ_O »

Offline Ki1o

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 119
  • Rating: +5/-2
  • Doing my best...
    • View Profile
Re: A New Programming Language
« Reply #7 on: February 25, 2012, 11:23:53 am »
Yeah we have taken it in another direction trying to see if we can create a hand written parser.  We also have a basic syntax defined.
Example :
<<< is input
>>> is output
We have basic arithmetic tokens as well as comments.
Example program would be:

>>> "Hello World!"

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: A New Programming Language
« Reply #8 on: February 25, 2012, 11:36:23 am »
Do you compile to some byte-code then interpret that, or do you interpret the source directly?

...I am creating an interpreted programming language in C++...

Offline Ki1o

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 119
  • Rating: +5/-2
  • Doing my best...
    • View Profile
Re: A New Programming Language
« Reply #9 on: February 25, 2012, 11:49:01 am »
The source will be interpreted directly for difficulty purposes (Creating a virtual machine etc.). :P
EDIT: Meaning creating bytecode would be too hard.
« Last Edit: February 25, 2012, 11:49:55 am by Ki1o »

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: A New Programming Language
« Reply #10 on: February 25, 2012, 11:56:59 am »
I know what you meant :P lol. Do you store the information to some kind of buffer? I think that would be easier if you plan on doing loops, but then again I'm not the one taking the course lol.

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: A New Programming Language
« Reply #11 on: February 25, 2012, 12:18:57 pm »
The source will be interpreted directly for difficulty purposes (Creating a virtual machine etc.). :P
EDIT: Meaning creating bytecode would be too hard.

Creating bytecode is largely the same process as interpretation at the simplest level... If you want to apply optimizations to the bytecode, that's different and can be much more complicated, but just mapping language to bytecode should be relatively simple with a solid language/bytecode design. I've found it's a good sanity check for a language that it is easy to generate a bytecode based on code in that language. If it's not easy, then the language is too complex. Let's take a while loop as an example:

Code: [Select]
While(A>0){
B=B+1;
C=C+2;
};

Let's try parsing this to bytecode:

Code: [Select]
TEST_GREATER(A,0); // Tests if arg1 is greater than arg2 and returns 1 if it is, 0 otherwise.
IF_NOT_GOTO(ANS,+6); // If Not(ANS) is true, then GOTO the opcode 10 commands after this one (code after the while loop)
INC(B,1); // Increment B and store result in ANS
SETVAR(B,ANS); // Store the incremented value of B to the variable B, overwriting the old value
INC(C,2);
SETVAR(C,ANS);
GOTO(-6); // GOTO the opcode 6 opcodes before this one (The condition test)

As you can see, generating a bytecode is basically equivalent to making the interpreter understand the code at all. One reason why bytecodes are so often used is that it's a lot faster to parse the one or two bytes that make up a typical opcode than it is to parse a potentially multi-lined script over and over again, when the work really only needs to be done once.

If the above bytecode looks like Assembly, that's because that's exactly what you're generating! Assembly code for a virtual machine.
« Last Edit: February 25, 2012, 12:20:59 pm by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Ki1o

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 119
  • Rating: +5/-2
  • Doing my best...
    • View Profile
Re: A New Programming Language
« Reply #12 on: February 25, 2012, 12:53:56 pm »
Sorta off topic: would that be for a stack based VM or register based? I've seen tutrorials on generating bytecode for a VM but we have a limited amount of time in which to get this done which is why we favored just directly interpreting it.

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: A New Programming Language
« Reply #13 on: February 25, 2012, 01:02:31 pm »
That bytecode would be more suitable for a register based VM, which is what I highly recommend unless you have a specific reason for choosing stack based (like portability to very memory limited systems).
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Ki1o

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 119
  • Rating: +5/-2
  • Doing my best...
    • View Profile
Re: A New Programming Language
« Reply #14 on: March 06, 2012, 07:56:43 pm »
Ok so after some discussion we've decided chage some of the syntax.  Input and output will be marked with only one < and > respectively.  We've also decided to use Java for the lexical analyser and the parser which will interpret the source code into Java bytecode. The interpreter will be written in C++ fro speed purposes.  Essentially our language will be quite portable.
EDIT: Also we're thinking about changing the name. Any suggestions?
EDIT2: OK my bad.... the whole thing will be implemented in Java and will be compiled to Java bytecode  ;D
That's correct now
« Last Edit: March 06, 2012, 08:05:05 pm by Ki1o »