Related articles |
---|
Parsing questions e8rasmus@etek.chalmers.se (Rasmus Anthin) (2000-01-06) |
Parsing Questions sewing@uvic.ca (Stefan Ewing) (2002-06-13) |
Re: Parsing Questions sting@linguist.dartmouth.edu (Michael J. Fromberger) (2002-06-14) |
Re: Parsing Questions ian@cfmu.eurocontrol.be (Ian Wild) (2002-06-14) |
Re: Parsing Questions joachim_d@gmx.de (Joachim Durchholz) (2002-06-14) |
Re: Parsing Questions rcbilson@plg2.math.uwaterloo.ca (Richard C Bilson) (2002-06-14) |
Re: Parsing Questions vbdis@aol.com (VBDis) (2002-06-14) |
[2 later articles] |
From: | Rasmus Anthin <e8rasmus@etek.chalmers.se> |
Newsgroups: | comp.compilers |
Followup-To: | poster |
Date: | 6 Jan 2000 16:46:24 -0500 |
Organization: | Chalmers University of Technology |
Keywords: | parse, question |
My token list and node-class looks like this:
--------------------------------------------
typedef char *chr; //"Unlimited" strings
typedef struct{
char token[toklen]; //toklen=30 or something. Ugly isn't it?
int row;
}toktype;
toktyp t[1000]; //This is very ugly I know.
class Node{
chr data;
int code;
Node *left,*right;
Node(Node *l=0, Node *r=0, chr d=0, int cd=0) :
left(l), right(r), data(d), code(cd) {}
};
----------------------------------------------------------
I have begun writing the parser as something like this:
----------------------------------------------------------
Node *parse(Node *root,int nr){
switch(t[nr].token[0]){
case '+' :
root->data="PLUS"
root->right=new Node(root->right,nr+2) // is this right??
....
....and so forth...
-------------
I don't know if I have got this right. However i would like some further
help on how to implement the parser for the binary tree-class???
Or should I use Recursive Descent or LALR or LL0 or LL1 or LR0 or LR1 ????
If so, how do I implement these????
Please help me!!!
Sincerely:
B. Rasmus Anthin
e8rasmus@etek.chalmers.se
www.etek.chalmers.se/~e8rasmus
57360731
Return to the
comp.compilers page.
Search the
comp.compilers archives again.