[antlr-interest] C++ Target First cut

Gokulakannan Somasundaram gokul007 at gmail.com
Sun Feb 12 17:37:34 PST 2012


Made some more improvements, especially with respect to the CommonToken
storage. Also changed the way how namespace is mentioned to the code
generator. Removed the #define and introduced a scope called @namespace.

Did some quick benchmarks on the dynamic_scope example of C Target. I
removed the print statements, so that the parsing alone is benchmarked.
Found around 20% runtime improvement with the C++ Target. :). This is with
the defaults of C++ Target like std::string, std::vector etc. Request
someone to verify the same. The code is attached here by, but i have used
boost timestamp functions.

Planning to do some more testing.

Gokul.

On Sun, Feb 12, 2012 at 7:03 PM, Gokulakannan Somasundaram <
gokul007 at gmail.com> wrote:

> Fixed a memory leekage. Even if there are any more memory leekages, if the
> user uses a memory pool for all the allocation needs of the Parser and
> finally drops the memory pool at the end of parsing, the leekages can be
> totally avoided.
>
> Thanks,
> Gokul.
>
>
> On Sun, Feb 12, 2012 at 2:31 PM, Gokulakannan Somasundaram <
> gokul007 at gmail.com> wrote:
>
>> Hi,
>>    I have made the C++ Target working for a small example. Now i need the
>> help of everyone who needs a C++ Parser to test it and report me with the
>> bugs. This would help us to complete the C++ Target. I have made it working
>> with the dynamic scopes example, which is also present in the attachment.
>> I will also test with other examples.
>>   I would also welcome any suggestions that might make the usage more
>> intuitive. Currently, just to work with the defaults, we need to write a
>> header file like this and include it like this
>>
>> @lexer::includes
>> {
>>    #include "UserTraits.hpp"
>>    #define USER_NAMESPACE User
>> }
>>
>> @parser::includes
>> {
>>    #include "UserTraits.hpp"
>>    #define USER_NAMESPACE User
>> }
>>
>> Of course the namespace #define is optional. But the UserTraits is
>> necessary and it looks like this for the generated lexer and parser TLexer
>> and TParser.
>>
>>
>> namespace User {
>>
>> //If you need to override, copy the traits here and override the
>> necessary traits
>> #include <antlr3traits.hpp>
>>
>> class TLexer;
>> class TParser;
>>
>> typedef StreamTraits<TLexer, TParser> TTraits;
>> typedef TTraits TLexerTraits;
>> typedef TTraits TParserTraits;
>>
>>
>> }
>>
>>
>> Please let me know, if you need any clarifications. I have also fixed the
>> bugs testing it with g++.
>>
>> Thanks,
>> Gokul.
>>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Cpp.7z
Type: application/octet-stream
Size: 111285 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20120213/1c749cc7/attachment.obj 


More information about the antlr-interest mailing list