how can i make my own programming language...
i want to make my own for one of my projects can anybody give me a hand
29 Replies - 24178 Views - Last Post: 12 August 2010 - 11:03 AM
Replies To: How to make your own Programming language ?
#2
Re: How to make your own Programming language ?
Posted 12 November 2008 - 09:47 AM
Given your current level of understanding of programming, OOP concepts and such (not trying to be rude or anything I swear, I just making this observation from your questions in the VB.NET forum) I would say taking on a project like this is well above your head. Creating a language is no simple task, it takes a team years to develop and debug a language
#3
Re: How to make your own Programming language ?
Posted 12 November 2008 - 09:53 AM
oh ok...also no offense is taken since i know im not great at proggramming so no worries.. and ok.. i just wanted to know how to do it thats all..
#4
Re: How to make your own Programming language ?
Posted 12 November 2008 - 10:53 AM
Start off with some reading: Programming Language Processors in Java - Compilers and Interpreters (Watt & Brown)
But, be aware! Building a complete langue is hard and there are university courses about them, still not covering all aspects.
But, be aware! Building a complete langue is hard and there are university courses about them, still not covering all aspects.
#5
Re: How to make your own Programming language ?
Posted 12 November 2008 - 01:48 PM
As Psycho said, no offense, but it's really above you. HOWEVER. [read on]
You could make your own interpreted language. That's not difficult. It's basically just reading in a file, and either:
1) Outputting the "translated" code to a language which you DO know
2) Running it directly through your interpreter. No secondary code.
Here's an example~ I wrote my own Brainfuck interpreter the other day.
[click for blog entry]
Note, this is a really simple interpreter. Brainfuck only has 8 commands.
Other than that, I'd say avoid trying to make your own compiled language. I'm getting books on it soon, I'll most likely be blogging about it. Keep an eye out, I try to write stuff in layman's terms.
You could make your own interpreted language. That's not difficult. It's basically just reading in a file, and either:
1) Outputting the "translated" code to a language which you DO know
2) Running it directly through your interpreter. No secondary code.
Here's an example~ I wrote my own Brainfuck interpreter the other day.
[click for blog entry]
Note, this is a really simple interpreter. Brainfuck only has 8 commands.
/*
* A brainfuck interpreter
* Author: Danny Battison
* Contact: gabehabe@gmail.com
*/
#include <iostream>
#include <fstream>
using namespace std;
void DisplayHelp();
int main(int argc, char *argv[]) {
if (argc < 2 || argc > 3) {
DisplayHelp();
return EXIT_FAILURE;
}
if (!strcmp(argv[1], "-?")) {
cout << "BRAINFUCK INTERPRETER: WRITTEN BY DANNY BATTISON" << endl
<< "This program is designed to interpret a brainfuck application." << endl
<< "Written in C++" << endl
<< "Contact the author: gabehabe (at) gmail (dot) com";
}
else if (!strcmp(argv[1],"-i")) {
if (argc < 2 || argc > 3) {
DisplayHelp();
return EXIT_FAILURE;
} else {
ifstream file;
file.open(argv[2]);
if (!file.is_open()) {
cout << "ERROR: File could not be found.";
return EXIT_FAILURE;
}
string bf = "";
char buffer;
file.get(buffer);
bf += buffer;
while (!file.eof()) {file.get(buffer); bf += buffer;}
file.close();
char* ptr = new char[5000];
int sub;
for (sub = 0; sub < 5000; sub++) ptr[sub] = 0;
sub = 0;
unsigned int i;
int loopPosition = -1;
for (i = 0; i < bf.length(); i++) {
switch (bf[i]) {
case '+': ptr[sub]++; break;
case '-': ptr[sub]--; break;
case '>': sub++; break;
case '<': sub--; break;
case '.': cout << ptr[sub]; break;
case ',': ptr[sub] = getchar(); if (ptr[sub] == 13) {ptr[sub] = '\0'; loopPosition = -1;} break;
case '[': loopPosition = i; break;
case ']': if (loopPosition != -1) {if (ptr[sub] != '\0') i = loopPosition-1; else loopPosition = -1;} break;
}
}
}
return EXIT_SUCCESS;
}
}
void DisplayHelp() {
cout << "Invalid arguments. Example Usages:" << endl
<< "\tInterpret:\tbf.exe -i C:\\file.bf" << endl
<< "\tabout:\t\tbf.exe -?";
}
Other than that, I'd say avoid trying to make your own compiled language. I'm getting books on it soon, I'll most likely be blogging about it. Keep an eye out, I try to write stuff in layman's terms.
#6
Re: How to make your own Programming language ?
Posted 13 November 2008 - 12:53 AM
and how is what you wrote helping him? *confused*
#7
Re: How to make your own Programming language ?
Posted 13 November 2008 - 12:55 AM
HAHAHAHA, in your face Gabe!
Hey, does anyone else smell toast?
Hey, does anyone else smell toast?
#8
Re: How to make your own Programming language ?
Posted 13 November 2008 - 06:30 AM
Because it's an example to show him how an interpreter works.
And I don't smell toast. Though I could earlier. Around the same time that you posted that.
And I don't smell toast. Though I could earlier. Around the same time that you posted that.
#10
Re: How to make your own Programming language ?
Posted 13 November 2008 - 07:35 AM
hahahahaahahahahaha
#11
Re: How to make your own Programming language ?
Posted 13 November 2008 - 08:21 AM
No2 you have made my day.
Burnt toast gabe!
#12
Re: How to make your own Programming language ?
Posted 13 November 2008 - 02:07 PM
It's funnier because you can still see where you didn't crop the corners properly. 
Future reference: gabehabe~ All lower case. See, this is why I don't call any more.
EDIT: also looks like someone went a little crazy with the clone tool in PS. no2, did you do that, or was it that shoddy when you found it?
Future reference: gabehabe~ All lower case. See, this is why I don't call any more.
EDIT: also looks like someone went a little crazy with the clone tool in PS. no2, did you do that, or was it that shoddy when you found it?
#13
Re: How to make your own Programming language ?
Posted 13 November 2008 - 02:16 PM
Very useful topic about compilers here!
#14
Re: How to make your own Programming language ?
Posted 13 November 2008 - 02:19 PM
gabehabe, on 13 Nov, 2008 - 03:07 PM, said:
It's funnier because you can still see where you didn't crop the corners properly
EDIT: also looks like someone went a little crazy with the clone tool in PS. no2, did you do that, or was it that shoddy when you found it?
EDIT: also looks like someone went a little crazy with the clone tool in PS. no2, did you do that, or was it that shoddy when you found it?
M$Paint ftw. I just did a Google Images search.
#15
Re: How to make your own Programming language ?
Posted 14 November 2008 - 05:57 AM
|
|

New Topic/Question
Reply



MultiQuote









|