home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!fuug!demos!kiae!glas!demos!druid.uucp!darcy
- From: darcy@druid.uucp
- Newsgroups: comp.lang.c
- Date: 18 Jul 92 03:26 MDT
- Subject: Simple preprocessor
- Sender: Notesfile to Usenet Gateway <notes@glas.apc.org>
- Message-ID: <1992Jul17.232621.20226@druid.uuc>
- Nf-ID: #N:1992Jul17.232621.20226@druid.uuc:-1295377463:001:2384
- Nf-From: druid.uucp!darcy Jul 18 03:26:00 1992
- Lines: 63
-
-
- scs@adam.mit.edu (Steve Summit) writes:
- >Once of these days, someone should write a good, simple
- >preprocessor, perhaps simply a stripped-down cpp, that handled
- >#include, #ifdef, and simple #define (and *maybe* macros with
- >arguments), which *would* be appropriate for general-purpose,
- >non-C preprocessing tasks such as Makefiles, calendar files,
- >crontab files, etc. (Hmm; gotta write myself another note.)
-
- TA DA!!!
-
- Introducing mkfiles(3) (Actually that's too much like a BSD utility I
- believe but that's the name I started with. I'll probably change it.)
-
- It's not quite ready for distribution yet but here is a glimpse.
-
- First of all the '#' is a comment character like just about every
- Unix utility except cc. Blank lines are ignored. There are hooks
- if you need '#' or blank lines in the output.
-
- Preprocessor directives start with '@'. These include;
-
- @DEFINE Define a macro
- @DEFAULT Like @DEFINE but only if not already defined
- @UNDEFINE Undef same
- @INCLUDE Include a file
- @PACKAGE Include a file from a predefined directory
- @FILE Redirect output to a new file
- @PRINT Print to standard output regardless of current output
- @SHOW Show defined macros (for debugging)
- @CLEAR Clear all macros to a specific point
- @IFDEF Conditional
- @IFNDEF "
- @ELIFDEF "
- @ELIFNDEF "
- @ELSE "
- @ENDIF End conditional
- @QUOTE Quote all lines (a specialty thing I needed)
- @FOR For loop construct
- @END End for loop
- @ERROR Print message and exit
-
- Macros can take arguments and defaults can be specified for the arguments.
- Here is a sample macro:
- @DEFINE foo bar $(1:zap)
- And it's expansion:
- $(foo:goo) ==> bar goo
- $(foo) ==> bar zap
-
- The sample script creates a skeleton SVR4 device driver including the
- system files, Makefile, Bare C file, etc.
-
- The distribution includes my getarg(3) and getline(3), valuable utilities
- in their own right if I say so myself.
-
- I have a little more testing to do on it and then I will probably post it.
-
- --
- D'Arcy J.M. Cain (darcy@druid) |
- D'Arcy Cain Consulting | There's no government
- Toronto, Ontario, Canada | like no government!
- +1 416 424 2871 DoD#0082 |
-
-