I have a file, which I have read, and need to print a parse tree for it. What I am doing is a syntax checker only for open and close parentheses (). If the item read is a open parentheses, I put it on a stack. If it is a close parentheses, I pop it off the stack. But, as I am reading and writing, I need to write the parse tree to the file. The input file looks like this:
OPAREN (
DEFUN Defun
Name Acount
OPAREN (
NAME L
CPAREN )
OPAREN (
COND cond
OPAREN (
...
etc.
The parse tree should look like this:
OPAREN (
DEFUN Defun
NAME Acount
OPAREN (
NAME L
CPAREN )
OPAREN (
COND cond
OPAREN (
... etc.
The problem I am having is printing the tabs when there is a new level. Does anyone know how I could print the tabs out at a new level. Thanks.