A pretty printer for C.
A note on operator precedence: This printer uses precedence
levels to control when to print parentheses around expressions.
The actual precedence values are the standard C precedence levels
multiplied by ten.
author: Robert Grimm version: $Revision: 1.74 $
Field Summary
final public static boolean
EXTRA_PARENTHESES The flag for printing additional parentheses to avoid gcc
warnings.
startExpression(int prec) Start printing an expression at the specified operator precedence
level.
See Also:CPrinter.endExpression(int) Parameters: prec - The expression's precedence level.
Create a new C printer.
Parameters: printer - The printer.
CPrinter
public CPrinter(Printer printer, boolean lineUp, boolean gnuify)(Code)
Create a new C printer.
Parameters: printer - The printer. Parameters: lineUp - The flag for whether to line up declaratons andstatements with their source locations. Parameters: gnuify - The flag for whether to use GNU code formattingconventions.
Determine whether the specified generic node contains a long type
definition. A long type definition requires multiple lines for
readability. Examples include enumeration, structure, and union
type definitions.
Parameters: specs - The generic node, representing a list of specifiers. true if the specifiers contain a longtype specifier.
Enter an expression context. The new context has the specified
precedence level.
See Also:CPrinter.exitContext(int) Parameters: prec - The precedence level for the expression context. The previous precedence level.
Enter an expression context. The new context is appropriate for
an operand opposite the associativity of the current operator.
For example, when printing an additive expression, this method
should be called before printing the second operand, as additive
operators associate left-to-right.
See Also:CPrinter.exitContext(int) The previous precedence level.
Print an expression as a truth value. This method prints the
specified node. If that node represents an assignment expression
and
CPrinter.EXTRA_PARENTHESES is true, this method
adds an extra set of parentheses around the expression to avoid
gcc warnings.
Parameters: n - The node to print.
Determine whether the specified declaration is long. A long
declaration requires multiple lines for readability. Examples
include declarations containing enumeration, structure, and union
type definitions.
Parameters: decl - The declaration. true if the specified declaration is long.
Start printing an expression at the specified operator precedence
level.
See Also:CPrinter.endExpression(int) Parameters: prec - The expression's precedence level. The previous precedence level.