cparen - add parentheses to C expressions
Written for those of us who can never remember the precedence and
associativity of operators in C,
reads lines of C code from standard-in,
adds parentheses to indicate operator binding in expressions,
then writes the resultant code to standard-out.
The input code fragment need not contain complete statements.
For example, the following line is a valid input to
} else if (x->d_prep > 56 && x->d_assoc == LEFT)
considers identifiers in expressions to be variable names.
option allows you to specify a whitespace-separated list of types.
cparen -t 'amap anop'
Declares "amap" and "anop" as type names rather than variable names.
Exit status is 2 if
was invoked improperly,
1 if some other error occurred,
0 if all went well.
Brad Needham, Tektronix, Inc.
Copyright (c) 1984 by
Tektronix, Incorporated Beaverton, Oregon 97077
All rights reserved.
Permission is hereby granted for personal, non-commercial
reproduction and use of this program, provided that this
notice is included in any copy.
assumes that the input code fragment came from a syntactically correct
C program -- it does not attempt to give reasonable syntax-error messages.
focuses on C statments it does not recognize other constructs e.g.
variable or function declarations.
It cannot process a whole C program.
The input is not filtered through the C preprocessor.