I'm developing compiler(need help with parser).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <string>
using namespace std;

string input;
string output;
string type;

void Scan () {
     if (input == "Console") {output = "Console", type = "Ident";}
        else if (input == "[") output = "L_Farad";
     else if (input == "]") output = "R_Farad";
          else if (input == "(") output = "L_Cow";
     else if (input == ")") output = "R_Cow";
          else if (input == "*") output = "Star";
     else if (input == "Write") output = "Write";
          else if (input == "Wait") output = "Wait";
     else if (input == ";") output = "Colon";
          else if (input == "//") output = "Comment";
}

void Parse () { ?????? }

int main () {
    cin >> input;
    Scan();
    cout << output;
    
    cin.get (); cin.get ();
    return 0;
}


Here is the code of my compiler, what i have to write, to have a parser?
I need a little help what to do next?

1
2
3
4
5
6
//my comment

Console[
	Write(*Hello*);
	Wait();
]


Here is my own language code!
closed account (zb0S216C)
If you don't know how to parse, then you may as well stop. Compiler development is a challenging project, even for experienced programmers. I recommend learning about parsing before actually basing a project on it.

Here's some resources:

Wikipedia's Page:
http://en.wikipedia.org/wiki/Parse_tree

Parsing Techniques:
http://www2.andrews.edu/~bidwell/456/history.html

Parsing Theory:
http://www.csse.monash.edu.au/hons/projects/2000/Supun.Ruwanpura/parsing.htm

Wazzak
Topic archived. No new replies allowed.