I am trying to create a simple compiler for a formatting language using Flex and Bison. The page setup information is specified as follows in the input file:
\pagesetup{2,80}
The first integer is irrelevant to my question. The second (80) is the line width. In the output file,
- I want a new line to be inserted when (with this example) 80 characters have been printed on a line (counting spaces) and printing to continue on the next line.
- I want to be able to center-align certain lines (e.g., a title) in the output file.
In my .y
file, I have this:
pageSetupProperty: BSLASH PAGESETUP LBRACE INTEGER COMMA INTEGER RBRACE;
The second integer is the one I need to use and I have set its yylval
to correspond correctly to its integer value.
However, I am stuck at this point. I have searched the Bison documentation as well as SO for a line width feature but I cannot find a way to do it.
And:
Full credit goes to Brian Tompsett and EJP for providing the full answer in comments.
Answer derived from their comments based on SE policy here.