[antlr-interest] Re: antlr-interest Digest, Vol 11, Issue 43

Desai Nishitkumar Ashokkumar nadesai at cse.iitb.ac.in
Mon Oct 24 06:04:30 PDT 2005


On Sun, 23 Oct 2005 antlr-interest-request at antlr.org wrote:

> Send antlr-interest mailing list submissions to
> 	antlr-interest at antlr.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://www.antlr.org/mailman/listinfo/antlr-interest
> or, via email, send a message with subject or body 'help' to
> 	antlr-interest-request at antlr.org
>
> You can reach the person managing the list at
> 	antlr-interest-owner at antlr.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of antlr-interest digest..."
>
>
> Today's Topics:
>
>   1. Re: query (Sohail Somani)
>   2. Re: thank you sir (Terence Parr)
>   3. Re: ANTLR modification (Suman Karumuri)
>   4. Re: Re: thank you sir (Terence Parr)
>   5. Re: Re: antlr-interest Digest, Vol 11, Issue 41 (Martin Probst)
>   6. Problem with carriage returns in c#	stringtemplate (Tech)
>   7. Re: ANTLRWorks 1.0ea4 available! (Jean Bovet)
>   8. Re: ANTLRWorks 1.0ea4 available! (Jean Bovet)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 23 Oct 2005 12:08:00 -0700
> From: Sohail Somani <sohail at taggedtype.net>
> Subject: Re: [antlr-interest] query
> To: Desai Nishitkumar Ashokkumar <nadesai at cse.iitb.ac.in>
> Cc: antlr-interest at antlr.org
> Message-ID: <1130094480.8124.1.camel at localhost.localdomain>
> Content-Type: text/plain
>
> On Sun, 2005-23-10 at 19:02 +0530, Desai Nishitkumar Ashokkumar wrote:
>> Hello sir,
>>  		I m doing M.Tech at IIT bombay, India. My project is on
>> re-engineering from procedural to object oriented program. And I am trying
>> to apply that on linux kernel. Currently I am trying to make any c code
>> compilable by c++ code. I am using GNU C grammar given in ANTLR grammars.
>> My doubt is is Preprocessing done by ANTLR or is there any option to do
>> that. and can I apply tool (translation tool) to entire project directory
>> such that tool itself take care of #include and #define statement ??
>
> FYI: Structs + Functions != procedural, Classes != object-oriented.
>
> Speaking from personal experience, it is entirely possible to write an
> object oriented kernel in C. I'd imagine the linux kernel is no
> different.
>
> Sohail
>
>
>
> ------------------------------
>
> Message: 2
> Date: Sun, 23 Oct 2005 13:05:29 -0700
> From: Terence Parr <parrt at cs.usfca.edu>
> Subject: [antlr-interest] Re: thank you sir
> To: ANTLR Interest <antlr-interest at antlr.org>
> Message-ID: <873B2D00-FC78-49EB-9820-CA28EA4BCF9F at cs.usfca.edu>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
>
> On Oct 23, 2005, at 10:31 AM, Desai Nishitkumar Ashokkumar wrote:
>
>> Hello sir,
>>            After running preprocessor manually, preprocessod code
>> is different (not in semantic but syntatic) from original code. And
>> if I convert this preprocessod code to c++ code (without classes,
>> only compatible to g++) such that it is compile by g++ compiler
>> then this translated code is also without any macros (preprocessor
>> statement) but that I dont want. I only want to do is making C code
>> compile by g++ compiler. And this I want to do automatically and
>> dont want to change unnecessary codes.
>
> Hi.  This is a standard problem.  Preprocessors can render the output
> messy, but w/o using preproc, the input is often not valid C code.
>
>> If I manually first do preprocessing then I think it ll not
>> fulfilled my goal.
>> Actually I want to make linux kernel compilable by g++. If I
>> manually apply preprocessor on that and then translate it to c++
>> then translated code ll be very big. bcz kernel has lots of macros
>> used.
>
> C++ is C so I'm not sure you have a problem with anything except the
> io libraries and such; still the Clib should still work with C++ right?
>
> Ter
>
>
> ------------------------------
>
> Message: 3
> Date: Mon, 24 Oct 2005 01:36:56 +0530
> From: Suman Karumuri <mansuk at gmail.com>
> Subject: Re: [antlr-interest] ANTLR modification
> To: antlr-interest at antlr.org
> Message-ID:
> 	<c26541e00510231306m6cb74795w2f6a0e320b4e1397 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On 10/23/05, Jim Crafton <jim.crafton at gmail.com> wrote:
>> Not with anything I tried. You're right it is pretty basic to do (not
>> more than 10-15 LOC if that). If it doesn't go in then I may have
>> issues when I upgrade to the next version. I guess it's not that big
>> of a deal, just something to watch out for.
>>
>> If it's appropriate, I'd be more than happy to just post my snippets
>> on the list so that other's can more easily find it.
>>
> Please do post them here.
> They would prove useful for people.Better post as much as you can(incl
> examples) so that it will stay in the archives for future reference.
>
> -Suman
>
>
> ------------------------------
>
> Message: 4
> Date: Sun, 23 Oct 2005 13:10:22 -0700
> From: Terence Parr <parrt at cs.usfca.edu>
> Subject: Re: [antlr-interest] Re: thank you sir
> To: ANTLR Interest <antlr-interest at antlr.org>
> Message-ID: <FABAD9E0-A17D-4AB0-A604-6A4605C56605 at cs.usfca.edu>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
>
>
> On Oct 23, 2005, at 1:05 PM, Terence Parr wrote:
>> C++ is C so ...
>
> ooops...make that "C is C++..." or "C++ is C with additions..."
>
Hi   Sir,
 	There are lots of program which can be compiled by gcc but not 
g++. like in gcc no need to do explicit type casting wheres in g++ it is 
needed.

  So, program in which typecasting is not done explicitly is compiled by 
gcc but by g++. I want to make changes in c code such that it is also 
compiled by g++. And then I can convert any module to object oriented and 
test the entire project by g++.

If I ll not convert entire project to g++ compatible then after making one 
module object oriented how can i test that project is still working or 
not??

thanks

-Nishit

  > Ter
>
>
> ------------------------------
>
> Message: 5
> Date: Sun, 23 Oct 2005 22:25:31 +0200
> From: Martin Probst <mail at martin-probst.com>
> Subject: Re: [antlr-interest] Re: antlr-interest Digest, Vol 11, Issue
> 	41
> To: Desai Nishitkumar Ashokkumar <nadesai at cse.iitb.ac.in>
> Cc: ANTLR Interest <antlr-interest at antlr.org>
> Message-ID: <1130099131.10755.7.camel at localhost.localdomain>
> Content-Type: text/plain
>
> Hi,
>
>>             After running preprocessor manually, preprocessod code is
>> different (not in semantic but syntatic) from original code. And if I
>> convert this preprocessod code to c++ code (without classes, only
>> compatible to g++) such that it is compile by g++ compiler
>
> you do realise that C is a proper subset of C++, e.g. that any valid C
> program is also a valid C++ program? If you just replace all occurrences
> of "gcc" in the Makefiles of the Linux kernel with "g++" you will be
> able to compile the kernel just as before.
>
>>  then this
>> translated code is also without any macros (preprocessor statement) but
>> that I dont want.
>
> C++ includes pre-processor macros as a language feature, albeit they are
> usually not used to the degree they are in C. Pre-processed C++ files
> will contain the defines of all header files they include in their body,
> which will render the classes completely unusable.
>
>> I only want to do is making C code compile by g++
>> compiler. And this I want to do automatically and dont want to change
>> unnecessary codes.
>
> Any code compilable by gcc is compilable by g++.
>
>> If I manually first do preprocessing then I think it ll not fulfilled my
>> goal.
>
> You mean by manually calling "/lib/cpp" or by replacing all the macros?
> The first is not really manual, the later is probably close to
> impossible in a project as big as the Linux kernel. Especially as you'd
> have to come up with a equally powerful C++ programming technique as a
> replacement for each.
>
> I don't really see the point in what you're trying to do.
>
> Martin
>
>
>
> ------------------------------
>
> Message: 6
> Date: Sun, 23 Oct 2005 22:31:31 +0100
> From: Tech <tech at swingkid.fsnet.co.uk>
> Subject: [antlr-interest] Problem with carriage returns in c#
> 	stringtemplate
> To: antlr-interest at antlr.org
> Message-ID: <435C0133.7060902 at swingkid.fsnet.co.uk>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Thanks for your reply Luis.
>
> No, this is not my whole template group, but I was trying to reduce the
> problem. I agree with you that your code works. However, if you copy the
> string into a text file (removing the escape characters from the
> quotation marks) and include it as an embedded resource, it doesn't work!
>
>     //StringReader sr = new StringReader("group TestOutput;
>    program(statements)::= << class Wrapper { <statements;
>    separator=\"\r\n\"> } >>");
>     Stream s =
>    typeof(Class1).Assembly.GetManifestResourceStream("Project1.Test.stg");
>    StreamReader sr = new StreamReader(s);
>    StringTemplateGroup stg = new StringTemplateGroup(sr,
>    typeof(antlr.stringtemplate.language.AngleBracketTemplateLexer));
>
> where Test.stg contains
>
>    group TestOutput; program(statements)::= << class Wrapper {
>    <statements; separator="\r\n"> } >>
>
> I have tried copying the StreamReader contents into a string before
> constructing the StringTemplateGroup, but that doesn't help. It seems
> more like a .Net issue than a StringTemplate issue, but I can't figure
> it out. I wonder if it is an encoding thing?
>
> Always curious,
>
> Mark
>
>
>
>

-- 
Nishit Desai
M.Tech II year 
Computer Science & Engg.
IIT Bombay


More information about the antlr-interest mailing list