Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 05-14-2005, 04:56 AM   #1
Solid State Member
 
mankxman's Avatar
 
Join Date: May 2005
Posts: 8
Question How 2 make a language?

Hey. i really wanna know how to make ur own programming langauge. and i would also like 2 know how to make ur own file types? any help would be much appreciated!
__________________

mankxman is offline   Reply With Quote
Old 05-16-2005, 12:44 PM   #2
Daemon Poster
 
Techy Geek's Avatar
 
Join Date: Feb 2005
Posts: 1,320
Send a message via MSN to Techy Geek
Default Re: How 2 make a language?

Im not sure but that is probably very very difficult, im sorry to say this and I will probably get a bad rep. point for it but...... google it.....I would but I'm at school and cant be bothered...soz
__________________

__________________
"If I seem to act unkind, its only me and not my mind" I Want To Tell You, The Beatles, Revolver
"When I am king, you will be first against the wall" Paranoid Android, Radiohead, OK Computer
There are two types of people, those who hate Microsoft, and those who work for it...
Possibly a Mac Convert
Techy Geek is offline   Reply With Quote
Old 05-17-2005, 04:46 AM   #3
Daemon Poster
 
george's Avatar
 
Join Date: Mar 2005
Posts: 553
Send a message via MSN to george Send a message via Yahoo to george
Default Re: How 2 make a language?

Well first you should learn an actual programming language so you know how they work and then ask around programming communities for some help it will probably be to difficult and if it's not serious I wouldn't bother wasting my time.
george is offline   Reply With Quote
Old 05-17-2005, 04:52 AM   #4
BSOD
 
Join Date: Apr 2005
Posts: 79
Default Re: How 2 make a language?

why dont you make your own os just need to know c++ and asm.
boz4life is offline   Reply With Quote
Old 05-17-2005, 09:11 AM   #5
Daemon Poster
 
Tulsileaf's Avatar
 
Join Date: Jul 2004
Posts: 1,249
Default Re: How 2 make a language?

easier to make a proghramming language

1) study other languages (to get an idea of what to make)
2) design the language
3) make interpretor or compiler
4) discover that existing languages are better than yours
5) get depressed
6) visit pub
7) get drunk
8) remove pants
9) ???
10) Profit!!
__________________
(|141 73g ()7 (|33|/| 11143s| |_| z1|-|7 (|43s| |/|4> |_| |-|0|1
Tulsileaf is offline   Reply With Quote
Old 05-17-2005, 10:05 AM   #6
Fully Optimized
 
UK31337's Avatar
 
Join Date: Feb 2005
Posts: 2,776
Default Re: How 2 make a language?

Quote:
Originally Posted by Tulsileaf
easier to make a proghramming language

1) study other languages (to get an idea of what to make)
2) design the language
3) make interpretor or compiler
4) discover that existing languages are better than yours
5) get depressed
6) visit pub
7) get drunk
8) remove pants
9) ???
10) Profit!!
Sadly, Tulsileaf probably isn't joking.

You need to be pretty hardcore to make your own language.
__________________
Master of common sense. If you don't like it, stop reading.
UK31337 is offline   Reply With Quote
Old 05-17-2005, 02:48 PM   #7
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 8,006
Default Re: How 2 make a language?

how do you mean you want to write a programming language? do you mean interperator
for languages like PHP or perl
or a compilable language like visual basic, or C...

the former is definitly easier.

In fact I'll have a go at making one (interperated/scripting language) to get you started...
root is offline   Reply With Quote
Old 05-17-2005, 03:31 PM   #8
Daemon Poster
 
Tulsileaf's Avatar
 
Join Date: Jul 2004
Posts: 1,249
Default Re: How 2 make a language?

Quote:
Originally Posted by root
In fact I'll have a go at making one (interperated/scripting language) to get you started...
when you're done, post it here so we can see.
__________________
(|141 73g ()7 (|33|/| 11143s| |_| z1|-|7 (|43s| |/|4> |_| |-|0|1
Tulsileaf is offline   Reply With Quote
Old 05-17-2005, 04:43 PM   #9
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 8,006
Default Re: How 2 make a language?

ok...

heres a simple script interperator, (you'll have to use your imagination though!!)

the script is run from the command line, in the form script.exe [script file]

there are three code files (at the minute) because I've only coded two very smple function, "add" and "writeword", there is currently no other function and no support for variables...
(I'll add some more functions later).

everyone should feel free to add to this language, it's a first come first server affair,
so if someone wants to write a function with a stupid name, or indeed a stupid function. respect the fact that they did that, and don't go changng other peoples functions name or functions function...

It's currently written in C and is compilable on both windows Linux and Mac, (a truly portable scripting language?)...

feel free to write OS specific functions, but don't to also write the code to make it so that it'll still compile (albeit ignoring your functins) on another OS...


heres the code so far....



script.c
Code:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <string>
#include "functionslist.h"



int main(int argc, char *argv[])
{
	int x;
	
	float a,b,c; /*declare some random variables incase they are needed later*/
	char inpath[50], task[50], arg[100];
	FILE *input;
	for (x=0; x<argc; x++)
	{
		if (x>1)
		{
			printf("you can only run one script at a time");
			exit(1);
		}
	}
	if (x==1)
	{
		printf("Usage is scrip.exe [scriptname]");
		exit(1);
	}
	if (strlen(argv[1])>=50)
	{
		printf("script names are limited to 50 chars");
		exit(1);
	}
	input = fopen(argv[1],"r");
	if (input==NULL)
	{
		printf("Error 1 - could not find input file - %s\n\n\r",inpath);
		exit(1);
	}
	/*here we decide what functions we'll be allowing, and the permissible arguments for each function
	for this example the functions that I have decided to allow are

	add some numbers (because it's simple)

	*/
	while (x=fscanf(input,"%s",&task)!=EOF) /*scan for task*/
	{
		if(strcmp(task,addfunction)==NULL)
		{
			fscanf(input,"%f,%f",&a,&b);
			c = addfunc(a,b);
			printf("%f\r\n",c);
		}
		if(strcmp(task,printwordfunction)==NULL)
		{
			fscanf(input,"%s",&arg); /*not all scripting functions will need a seperate function, echo to the screen is a good example of this*/
			printf("%s\r\n",arg);
		}
	}
}
functionslist.h
[code]
/*list functions here*/
float addfunc(float, float);

/*declare functions that will be available
these are global variables, just because it
was easier and cleaner to do it like this*/

char *addfunction = "add";
char *printwordfunction = "writeword";
char *printstringfunction = "writestring"; //not included this but you get the picture right
[code]

and lastly the function specific file
addfunc.c
Code:
float addfunc(float a, float b)
{
	float result;
	result = a + b;
	return(result);
}
I've tried to structure the programming so tat new functions can be added without bloating the software.

For some users they may have to add lines to include the addfunc.c file at the start of the functionslist.h file... the IE I used was VS.NET and having these three files added to the solution meant that the addfunc.c file was added automatically...

so like I say, if anyone is intersted, please feel free to extend this language.


---edit--
just for completion... the script I used was called hello.txt and looked like this

add 1,20
writeword hello
root is offline   Reply With Quote
Old 05-18-2005, 07:24 AM   #10
Daemon Poster
 
george's Avatar
 
Join Date: Mar 2005
Posts: 553
Send a message via MSN to george Send a message via Yahoo to george
Default Re: How 2 make a language?

Quote:
Originally Posted by boz4life
why dont you make your own os just need to know c++ and asm.
OK lets think. For one person with no programming language experience that would take more than 15 years to make a os and I don't think he wants to do 15 years of learning the ins and outs of os and programming languages just for something to do.
__________________

george is offline   Reply With Quote
Reply

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
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 01:04 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0