Richard Lewis wrote:

Hi, I just started the process of determining how to convert my JAVA runtime based grammar into the C runtime. Will I run into memory allocation issues if I embed STL? For example, in my current grammar I use:

 

scope RScope {

                String name;

                HashMap<String,Enum> symbols;

}

 

If I translate this to:

 

scope RScope {

                std::string name;

                std::map<std::string, int> symbols;

}

Basically, so long as it gets by the ANTLR parser, then it will pretty much be spit out as seen. However, you need to copy the code in the C parser example to initialize anything in the scope that isn't automatic, and also to register a freeScope() function that knows how to free anything in the scope that isn't automatic. So you r symbol map probably wants to be a pointer, which you create with new and delete it when the scope is freed (it will call you back to tell you).

I will be updating the examples for 3.1.2 shortly, and this will show you how to handle such things much more efficiently than the current examples (which was really meant as a scope example rather than an efficiency example.

 

Is this even going to compile? And if it does, will it blow up or leak memory?


You might find that you have to typedef it to fool ANTLR in some cases, but generally it will be OK. The output file will be a C file, but if you compile it is as C++ then it should be fine. There are a couple of bugs with rewrites and casts that are on my list to fix very soon, ready for 3.1.2.

 

The second part of my question is: Will there be a C++ runtime available in the near future?

Don't know how near because I keep getting pulled off into other things, but I have been working on it. You should be fine with the C runtime but please read through all the examples and the docs before going to far ;-)

Jim

 


List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---



List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to