[antlr-interest] Re: Haven't seen this one.

Mehdi Taouti mehdi_cit at yahoo.com
Thu Dec 25 14:16:16 PST 2003


Hi Terence,
 
Haven't seen this part: :):
 
Well, if you can specify the exact augmentations you have to generate, 
we should be able to help you out ;)
 
Here it goes... I think it's extreemely interesting and it opens up many oportunities:
 
The point is being able to write any C++ constructs to some XML form. 
We can go further and talk about XML Reflection.
 
classA{
 int i;
 int j;
}

classA objectA(3,4);
 
objectA.toXML() => something like:
 
<classA>
<objectA>  
<i><int>3</int></i>  
<j><int>4</int></j>
</classA>
</objectA>
 
Cheers!

 

 
Mehdi Taouti <mehdi_cit at yahoo.com> wrote:
Thanks Terence,
 
Is there any examples of such a 'C++ subset' parser?
 
Cheers -:).

Terence Parr <parrt at cs.usfca.edu> wrote:

On Thursday, December 25, 2003, at 02:52 PM, mehdi_cit wrote:

> Hi Ter,
>
> Believe me I did a search and read tons of posts. I understood that
> parsing C++ was difficult (I had a look at the grammar, furtively
> though). But I would think that parsing the C++ code just to add
> some "easy funtions" like adding a toString(); function to all
> classes wouldn't be that hard.

Well, rewriting the token stream is now pretty easy; see my latest 
article:

http://www.antlr.org/article/rewrite.engine/index.tml

On the other hand, parsing to figure out when to do the rewriting is 
pretty hard. Fortunately, it sounds like you have an easier problem 
than parsing the whole language. Just adding some toString methods and 
so on should be pretty easy.

I remember parsing stuff outside of method bodies as much easier than 
parsing stuff inside (at least 10 years ago). So, you might get away 
with a C++ subset parser. :)

Ter

>
> For instance a class
>
> classA{
> int i;
> int j;
> ...
> }
>
> Parsing the code would generate
>
> classA::toString(){
> cout << "i: " << i << ", " << "j: " << j << endl;
> ....
> }
>
>
> Is that possible with ANTLR?
>
> I read once about some product that parses C++ and offers a Script
> like language (interface) to walk the tree and generate C++ code or
> whatever. But I cannot find it anymore...
>
> Anyways... I'm really in an extreemly bad mood :(. I accepted some
> project and I'm stuck now... I have been told that there exists some
> C++ grammar and that could be easily done with ANTL.

Well, if you can specify the exact augmentations you have to generate, 
we should be able to help you out ;)

Ter

>
> Apparently I should have investigated the matter further!
>
> Thank you in any case :)
>
> --- In antlr-interest at yahoogroups.com, Terence Parr 

> wrote:
>>
>> On Thursday, December 25, 2003, at 02:15 PM, mehdi_cit wrote:
>>
>>> Please someone answer, it wouldn't take you more than 5 minutes!
>>
>> I believe you'll see a response to this from a few times in the
> past
>> using a search. The answer is C++ is really hard to parse...most
>> people parse it in stages, which ANTLR certainly is capable of
> doing.
>> Have you seen the existing C++ grammar on the website?
>>
>> Ter
>>
>>>
>>> I'm investigating ANTLR. I need to know whether there is a viable
>>> C++ grammer as I want to be able to parse my C++ code and (let's
>>> say) generate some functions for every class (e.g.
> classA.toString
>>> (), classA.toSQL()). Is that possible with ANTLR, if yes how do
> we
>>> go about it? Please anyone help.... I really need it.
>>>
>>> I don't need to make some new compiler/language etc. I just need
> to
>>> automate some of the coding. Just as I said I need to have some
>>> parser that parses my C++ code, checks my classes and auto-
> generate
>>> some 'straightforward' functions.
>>>
>>> Please help me!
>>>
>>>
>>>
>>>
>>>
>>> Yahoo! Groups Links
>>>
>>> To visit your group on the web, go to:
>>> http://groups.yahoo.com/group/antlr-interest/
>>>
>>> To unsubscribe from this group, send an email to:
>>> antlr-interest-unsubscribe at yahoogroups.com
>>>
>>> Your use of Yahoo! Groups is subject to:
>>> http://docs.yahoo.com/info/terms/
>>>
>>>
>>>
>> --
>> Professor Comp. Sci., University of San Francisco
>> Creator, ANTLR Parser Generator, http://www.antlr.org
>> Co-founder, http://www.jguru.com
>> Co-founder, http://www.knowspam.net enjoy email again!
>> Co-founder, http://www.peerscope.com pure link sharing
>
>
>
>
> Yahoo! Groups Links
>
> To visit your group on the web, go to:
> http://groups.yahoo.com/group/antlr-interest/
>
> To unsubscribe from this group, send an email to:
> antlr-interest-unsubscribe at yahoogroups.com
>
> Your use of Yahoo! Groups is subject to:
> http://docs.yahoo.com/info/terms/
>
>
>
--
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Co-founder, http://www.jguru.com
Co-founder, http://www.knowspam.net enjoy email again!
Co-founder, http://www.peerscope.com pure link sharing






Yahoo! Groups Links

To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/

To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com

Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/ 



---------------------------------
Do you Yahoo!?
Yahoo! Photos - Get your photo on the big screen in Times Square 

---------------------------------
Yahoo! Groups Links

   To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
  
   To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
  
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 



---------------------------------
Do you Yahoo!?
Yahoo! Photos - Get your photo on the big screen in Times Square
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20031225/a1c4f421/attachment.html


More information about the antlr-interest mailing list