How to write a programming language

insaned@mail.bg (insaned)
14 Mar 2003 11:18:17 -0500

          From comp.compilers

Related articles
How to write a programming language insaned@mail.bg (2003-03-14)
Re: How to write a programming language newsfeed2@boog.co.uk (Peter Cooper) (2003-03-17)
| List of all articles for this month |
From: insaned@mail.bg (insaned)
Newsgroups: comp.compilers
Date: 14 Mar 2003 11:18:17 -0500
Organization: http://groups.google.com/
Keywords: question
Posted-Date: 14 Mar 2003 11:18:17 EST

Hello people.I would like to make my own programming language.It
should look like this:


$a = 1;
$b = 2;
$c = $a + $b;
$d = 1+(2*(3+1*2))+1;


function loop()
{
      echo("Loop");
      return 1;
}


I have a basic ideas how should i do it, but i would like some help
about variables.Where to store them, how to use them, etc.Also about
the function...how to store them, where, how to call them.
My programming language is going to be like PHP, vars will be
dynamicly created and should be any type...int, string, object...


I splitt the code as follows:
$a
=
1
;
$b
=
2;
.
.
.
.
.


i can't figure where to store variables and their names, in arrays
but...how?
first thing to do is this!and i can't!


I am using Visual C++ and my idea is:


class Variable {
private:
      bool is_string;
      bool is_integer;
      bool is_char;
      .
      .
      .


      Variable *next_var;


public:
      int get_int();
      char* get_string();
      char get_char();


      bool set_type(int);
      bool copy(void*);
}




Variable* vars;


when i create a variable:
vars = new Variable();


and later:
vars->next_var->next_var->set_type(INTEGER);




and so on...I don't know if this code is going to work, bacause i
didn't test it!But i thing it should!


So if anyone have any ideas, comments, or links in the web is welcome.
Thanks!


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.