Re: c preprocessors

Axel Kittenberger <axel@dtone.org>
16 Sep 2001 00:35:33 -0400

          From comp.compilers

Related articles
c preprocessors Waverly.Edwards@Genesys.com (2001-09-11)
Re: c preprocessors jStouten@Orenda-it.nl (Jacques Stouten) (2001-09-11)
Re: c preprocessors axel@dtone.org (Axel Kittenberger) (2001-09-16)
| List of all articles for this month |

From: Axel Kittenberger <axel@dtone.org>
Newsgroups: comp.compilers
Date: 16 Sep 2001 00:35:33 -0400
Organization: Kabelsignal AG Broadband Service
References: 01-09-030 01-09-041
Keywords: C
Posted-Date: 16 Sep 2001 00:35:33 EDT

Jacques Stouten wrote:


> take a look at lcc, A Retargetable Compiler for ANSI C
> at http://www.cs.princeton.edu/software/lcc/


http://www.cs.princeton.edu/software/lcc/pkg/CPYRIGHT


Looking at the license of 'lcc' I get the impression it's some parts
even more restrictive than the GPL:


* You may not sell lcc or any product derived from it in which it is a
significant part of the value of the product


Notice that the GPL with gcc has no selling limitations. (Don't
confuse it with the GPL part that you may not sell the -source- beyond
the media costs)


* lcc is available free for your personal research and instructional
use under the `fair use' provisions of the copyright law.


How about commercial use?


I'm no lawyer, thank god, looking at this license it confuses me, it
contra-indicates itself in some parts, I got the impression that in
one paragraph it explicitly forbids something which is explicitly
allowed again in the next one. However I'm of course a layman, but I
think I finally understood the GPL that comes in example with gcc.


BTW: There is a freaking good FAQ from the FSF:
http://www.gnu.org/licenses/gpl-faq.html


---


I once wrote a C preprocessor (in java), unfortunally commercialy so I
don't have even no longer access to it myself, or I would give it to you :(
But I can tell it's not too difficult. Best you work in streams, construct
the preprocessor in several layers each handling chars/tokens to the next
level.


Level 1: read characters from a file.
Level 2: replace trigraphs (If you want to support them at all)
Level 3: tokenize (filter comments)
Level 4: concat string constants and cut away \\n terminatations
Level 5: filter the # preprocessor commandos, and implement a action for
them. (If you encounter a #include in example, instance a new Level 1
reader )
Level 6: replace macro's


Than you've the tokenstream as you wanted it and can either push it into a
c compiler or write it back to a file if you want so.


Well yes it was some weeks work, but that's a price to pay for a
properitary license.


As John said truely, you can mix GPL with proprietary software at
process level. As long the project parts operate at arms distance you
can put them together. In example a proprietary process may execute a
GPL process, take its output or redirect it's stdout into a stream,
and work further with it generated output. Linking GPL and proprietary
software together is not allowed (static and dynamic)


- Axel


<D) http://www.dtone.org


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.