[antlr-interest] Parse data structure as input

Yau Kwong K (Tony) yau at LGSInnovations.com
Wed Apr 9 08:57:36 PDT 2008


Ter,

 

I would need more information and pointer of how to accomplish this
(sample code if there is any).  I've read the book and the generated
codes on tree and tree adaptor (especially on the C target) and I still
don't have a clear picture on how to extend Antlr to fit our
application.  The following pseudo code is what I'm trying to do. 

 

typedef struct StructA_struct {

            int intA1;

            int intA2;

} StructA;

 

typedef struct StructB_struct {

            int intB1;

            myStructA *structA_p;

} StructB;

 

StructB *myStruct = (StructB *) &alreadyDefinedStruct;

 

if (myStruct -> intB1 == 100) 

            action100 ();      // take action100 if intB1 has the value
of 100

if (myStruct -> structA_p -> intA1 == 200)

            action200();       // take action200 if intA1 has the value
of 200

if (myStruct -> structA_p -> intA2 == 300)

            action300();       // take action300 if intA2 has the value
of 300

 

Would appreciate if anyone can share some thoughts on this.

 

Regards,

Tony

 

 

 

 

 

            

 

________________________________

From: Terence Parr [mailto:parrt at cs.usfca.edu] 
Sent: Tuesday, April 01, 2008 3:36 PM
To: Yau Kwong K (Tony)
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Parse data structure as input

 

Sure. a tree adaptor + tree grammar i what you want.

Ter

On Apr 1, 2008, at 11:03 AM, Yau Kwong K (Tony) wrote:





Hi all,

 

I'm new to antlr and I'm trying to find out if Antlr can parse C data
structure (instead of plain character stream) as input. My data
structures have struct containing

different data types and pointers to multiple different struct (like a
tree).  They are all in C target.

I would like to write a tree walker to walk the data structure and take
appropriate action when a particular value is set inside the input
structure.

 

Any suggestions would be appreciated.

 

Thanks,

Tony

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080409/40566216/attachment-0001.html 


More information about the antlr-interest mailing list