How to parse and call c++ constructors?
- From: "Groleo" <groleo@xxxxxxxxx>
- Date: 17 Sep 2005 13:54:50 -0400
Hi.
I have the following problem:
Given a file,:
A {
B {
text="cucu"
}
}
it;s parsed like:
text=cucu
B
A.
But to make this usefull, I wanted to fill up a datastructure:
struct B {
char* text;
};
struct A {
struct B _b;
};
So, to show the actions too:
A { <-- a =new A();
B { <-- a->_b =new B();
text="cucu" <-- a->_b->text = $2;
}
}
So again this is translated into:
a->_b->text = $2; //error: a was not allocated, b was not allocated
a->_b =new B(); //error: a was not allocated.
a =new A();// too late :)
How can this be done without errors?
.
- Follow-Ups:
- Re: How to parse and call c++ constructors?
- From: Hans-Peter Diettrich
- Re: How to parse and call c++ constructors?
- From: A Pietu Pohjalainen
- Re: How to parse and call c++ constructors?
- From: Detlef Meyer-Eltz
- Re: How to parse and call c++ constructors?
- Prev by Date: Re: Parsing Expression Grammar
- Next by Date: Interpreter Memory Models?
- Previous by thread: New Yacc/Bison like parser generator for C#
- Next by thread: Re: How to parse and call c++ constructors?
- Index(es):
Relevant Pages
|
Loading