home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / B-C / C++Source Code Fmtr Folder / Src / Formatting.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-27  |  17.5 KB  |  813 lines  |  [TEXT/MPS ]

  1. #ifndef __FORMATTING__
  2. #define __FORMATTING__    1
  3.  
  4. #ifndef __CSCANNER__
  5. #include "CScanner.h"
  6. #endif
  7.  
  8. #ifndef __DATAAREA__
  9. #include "DataArea.h"
  10. #endif
  11.  
  12. #ifndef __FORMATSTRINGS__
  13. #include "FormatStrings.h"
  14. #endif
  15.  
  16. #ifndef __DFILE__
  17. #include "DFile.h"
  18. #endif
  19.  
  20. #ifndef __NEW__
  21. #include <new.h>
  22. #endif
  23.  
  24. #ifndef __STRING__
  25. #include <string.h>
  26. #endif
  27.  
  28.  
  29. /*
  30. ** Formatting:
  31. **    Controls the formatting and output of a text item
  32. */
  33.  
  34.  
  35. #pragma segment Formatting
  36.  
  37.  
  38. /*
  39. ** Enum defining various formatting registers
  40. */
  41. enum {
  42.     kRegIndentDelta = 0,                        //
  43.     kRegWidth,                                    //
  44.     kRegIndent,                                    //
  45.     kRegCurrentColumn,                            //
  46.     kRegTempIndent,                                //
  47.     kNRegisters = 10
  48. };
  49.  
  50.  
  51. /*µ struct FContext
  52. ** Define the structure of a context
  53. */
  54. struct FContext {
  55.     short fReg[kNRegisters];                    // Registers used during formatting
  56.     short fDeclWidth;                            // Minimum width of a declaration
  57.     short fWhatToSqueeze;                        // What squeezing is being done
  58.     Boolean fDeclLeft;                            // True if "*" and "&" associate left
  59.     Boolean fIsGroup;                            // True if this context begins a group
  60.     FormatString fComma;
  61.     FormatString fSemi;
  62.     FormatString fLCurly;
  63.     FormatString fRCurly;
  64.     FormatString fLParen;
  65.     FormatString fRParen;
  66.     FormatString fName;
  67.     FormatString fOperator;
  68.     FormatString fAssign;
  69. };
  70.  
  71.  
  72. /*
  73. ** Pointers to classes
  74. */
  75. class Syntactic;
  76. class FormatLog;
  77.  
  78.  
  79. //µ class Formatting
  80. class Formatting : public SingleObject {
  81. public:
  82.     short IFormatting();
  83.     short IFormatting(const Formatting *aFormat);
  84.  
  85.     static void SetOutput(DFile *anOutput);
  86.     // Set the output file to write to.  Shared by all instances
  87.  
  88.     void SetFormatLog(FormatLog *aFormatLog);
  89.     // Set the FormatLog that records all commands.  Shared by all instances
  90.  
  91.  
  92.     static void DebugFormatting(Boolean aFlag);
  93.  
  94.     short &CurrentColumn();
  95.  
  96.     short GetIndent() const;
  97.     void SetIndent(short anIndent);
  98.     void AddIndent(short aDelta);
  99.     void IncrIndent();
  100.  
  101.     static void CommentColumn(short aColumn);
  102.     static short CommentColumn();
  103.  
  104.     static void TabSize(short n);
  105.     static short TabSize();
  106.  
  107.     static void LineLength(short aColumn);
  108.     static short LineLength();
  109.  
  110.     static void ReformatComments(Boolean aFlag);
  111.     static Boolean ReformatComments();
  112.  
  113.     static void PassSourceNewLines(Boolean aFlag);
  114.     static Boolean PassSourceNewLines();
  115.  
  116.     static void PassConsecutiveNewLines(Boolean aFlag);
  117.     static Boolean PassConsecutiveNewLines();
  118.  
  119.  
  120.     /*
  121.     ** High level output operations.  The parser calls these routines to
  122.     ** set desired behavior or to inquire about what should be done with
  123.     ** a particular character.
  124.     */
  125.     void SetGlue(FormatString aGlue);
  126.     void ExecuteGlue(FormatString aGlue);
  127.     void Display(Syntactic *aToken);
  128.  
  129.     Boolean DeclLeft() const;
  130.  
  131.     void DeclPadStart(int nOperators);
  132.     void DeclPadEnd();
  133.     /*
  134.     ** These two methods are called around the "*" in an "int *foo"
  135.     ** declaration.  nOperators is the number of "*"/"&" operators
  136.     ** in the declaration.  DeclPadStart is called prior to Display()ing
  137.     ** each operator, DeclPadEnd is called afterwards.  The function
  138.     ** is to associate the operators with either the type or object,
  139.     ** as defined by fContext.fDeclLeft, and to pad the declaration to
  140.     ** the proper length, as defined by fContext.fDeclWidth
  141.     */
  142.  
  143.     void DeclWidth(Boolean goLeft, int aWidth);
  144.     /*
  145.     ** Set the width of the type part of a declaration.  goLeft is
  146.     ** true if "*" and "&" associate with the type, false if they
  147.     ** associate with the object being declared.  aWidth is the
  148.     ** width of the declaration.  If 0, then the width is accumulated
  149.     ** across declarations
  150.     */
  151.  
  152.  
  153.     /*
  154.     ** Language specific formatting routines.  These routines are invoked
  155.     ** by the parser.  Specify the glue to use when Display() is called.
  156.     */
  157.     void Comma();
  158.     void Semi();
  159.     void LCurly();
  160.     void RCurly();
  161.     void LParen();
  162.     void RParen();
  163.     void Name();
  164.     void Operator();
  165.     void Assign();
  166.  
  167.  
  168.     /*
  169.     ** Low level output operations.  Strings and characters which are output
  170.     ** should not contain tabs unless SetCurrentColumn is called afterwards
  171.     ** to fix up the column position.  Furthermore, these operations should
  172.     ** not be called except by token display routines as their actions are
  173.     ** not recorded for playback when line lengths overflow.
  174.     */
  175.     void Print(const char *aString);
  176.     void Puts(const char *aString);
  177.     void Putc(int aChar);
  178.     void NewLine();
  179.     void Write(const void *aString, size_t n);
  180.     void Flush();
  181.  
  182.     void Comment(const char *start, const char *end);
  183.     /*
  184.     ** Output the comment in the proper format
  185.     */
  186.  
  187.  
  188.     void OpenContext(Boolean isGroup = false);
  189.     void CloseContext();
  190.     void RestoreIndent();
  191.     /*
  192.     ** Create and restore contexts, areas where particular formats are
  193.     ** in effect along with different settings for the permanent and
  194.     ** temporary indents.  RestoreIndent restores the settings for the
  195.     ** permanent and temporary indents.  For now, do nothing
  196.     */
  197.  
  198.     void SetRegister(int aRegister, const unsigned char *&aFormat);
  199.     void SetRegister(int dstReg, int aValue);
  200.     int GetRegister(int srcReg) const;
  201.     // Set and fetch context registers.  The first form of SetRegister
  202.     // evaluates the formatting string to yield the expression.
  203.  
  204.  
  205.     void SetComma(FormatString aString);
  206.     void SetSemi(FormatString aString);
  207.     void SetLCurly(FormatString aString);
  208.     void SetRCurly(FormatString aString);
  209.     void SetLParen(FormatString aString);
  210.     void SetRParen(FormatString aString);
  211.     void SetName(FormatString aString);
  212.     void SetOperator(FormatString aString);
  213.     void SetAssign(FormatString aString);
  214.     // Set the format strings for the current context
  215.  
  216. private:
  217.     static Boolean NewLineWanted();
  218.     static Boolean SpaceWanted();
  219.     static Boolean NewLineNeeded();
  220.     static Boolean SpaceNeeded();
  221.     static void WantNewLine(short n = 1);
  222.     static void WantSpace(short n = 1);
  223.     static void NeedNewLine(short n = 1);
  224.     static void NeedSpace(short n = 1);
  225.     // Sometimes the parser needs newlines and whitespace to appear before
  226.     // or after tokens are displayed.  These methods control the desire.
  227.     // These methods are called prior to any new displays.  The distinction
  228.     // between 'want' and 'need' is that 'want'ed items are optional; they
  229.     // can be removed to squeeze more items on the line.  'Need'ed items
  230.     // are never removed.
  231.  
  232.     void FreshLine();
  233.     /*
  234.     ** Make sure the cursor is at the beginning of a line, emit a newline
  235.     ** if not so.
  236.     */
  237.  
  238.     void IndentTo(short aColumn);
  239.     void IndentTo();
  240.  
  241.     void IndentLine(short aColumn);
  242.     void IndentLine();
  243.     /*
  244.     ** IndentTo postcondition is CurrentColumn() >= aColumn.
  245.     ** IndentLine does a FreshLine()/IndentTo(aColumn)
  246.     */
  247.  
  248.  
  249.     static Boolean IsBOL();
  250.     static void AtBOL();
  251.     // Indicate that if a new line is required, it can be put here.
  252.     // Return true if we are the beginning of the line.
  253.     // Set the beginning of line state, require beginning of line
  254.     // Assure that we are at the beginning of the line, IsBOL() will
  255.     // return true after RequireBOL() is called.
  256.  
  257.  
  258.     void CheckWanted();
  259.     /*
  260.     ** Called by internal routines to check that whitespace will be
  261.     ** emitted prior to emitting other data
  262.     */
  263.  
  264.     void SetSqueeze(short whatToSqueeze);
  265.     /*
  266.     ** Set the squeeze option.  When re-doing formats, the squeeze option
  267.     ** is copied to all saved items on the stack.
  268.     */
  269.  
  270.     short WhatToSqueeze() const;
  271.     void SetWhatToSqueeze(short what);
  272.     // Return what is currently being squeezed.
  273.  
  274.     void UseSourceNewLine();
  275.     /*
  276.     ** This method is called when the output line would be too long.  It
  277.     ** is inserted into gFormatLog when an unused source newline is
  278.     ** encountered.  During gFormatLog->Redo(), if WhatToSqueeze says
  279.     ** to use source new lines, the newline will be emitted into the
  280.     ** output.
  281.     */
  282.  
  283.     void LogicalSpace();
  284.     void LogicalNewLine();
  285.     // These methods maintain desires by updating them from reality.  When
  286.     // a space (or equivalent) has been emitted, we no longer want a space
  287.     // and the last character emitted was a space.  When a newline is
  288.     // emitted, we no longer desire one.  Also, we indicate that a space
  289.     // has also been emitted.
  290.  
  291.     void _Putc(int aChar);
  292.     void _Write(const void *aString, size_t n);
  293.  
  294.     FormatString Interpret(FormatString aFormat);
  295.     int GetExpr(FormatString &aFormat, int defaultValue = 1);
  296.     /*
  297.     ** Special interpreter of format strings
  298.     */
  299.  
  300.     static Boolean IsIdentifierType(short aType);
  301.     static Boolean IsOperatorType(short aType);
  302.     /*
  303.     ** Methods returning true if the types should be treated as ids or ops
  304.     ** for the purposes of formatting
  305.     */
  306.  
  307. private:
  308.     // Variables common to all instances of Formatting
  309.     static DFile *gOutput;                        // The output stream
  310.     static FormatLog *gFormatLog;                // Where we remember our commands
  311.  
  312.  
  313. private:
  314.     // Formatting parameters set by command line
  315.     static short gTabSize;                        // The tab sizes to apply
  316.     static short gCommentColumn;                // The end-of-line comment level
  317.     static short gLineLength;                    // The length of an output line
  318.     static Boolean gDebug;                        // Flag to control debug displays
  319.  
  320.     static Boolean gReformatComments;            // True if comments can be word wrapped
  321.     static Boolean gPassSourceNewLines;            // True if source newlines are emitted
  322.     static Boolean gPassConsecutiveNewLines;    // True if two or more newlines get through
  323.  
  324.  
  325. private:
  326.     // Values for Checkpoint() and Rollback() to worry about.  These values
  327.     // are copied to local 
  328.     struct RollbackVars {
  329.         short fLastTokenType;                    // Type of last displayed token
  330.  
  331.         short fIndent;                            // The indent for the next line
  332.         short fCurDeclStart;                    // Start column of the current declaration
  333.  
  334.         short fWantNewLine;                        // # of new lines wanted
  335.         short fWantSpace;                        // # of spaces wanted
  336.         short fNeedNewLine;                        // # of new lines needed
  337.         short fNeedSpace;                        // # of spaces needed
  338.  
  339.         FormatString fFormatString;                // String currently being interpreted.
  340.         FormatString fGlueString;                // The current glue
  341.     };
  342.  
  343.  
  344.     static struct RollbackVars gV;                // The Values used by Formatting
  345.     static struct RollbackVars gC;                // The Checkpointed values
  346.  
  347.     static Boolean gFromSource;                    // True if data coming from source
  348.     static size_t gOutputOffset;                // Offset of line start in gOutput
  349.  
  350.     static short gSourceNewLines;                // # of source newlines not yet emitted
  351.     static Boolean gLastNewLineFromSource;        // True if the last new line was from the source
  352.  
  353.  
  354. private:
  355.     FContext fContext;                            // The current context
  356.     DataArea fSavedContexts;                    // Saved context items
  357. };
  358.  
  359.  
  360. //µ   Formatting::SetOutput
  361. #pragma segment Formatting
  362. inline void Formatting::SetOutput(DFile *anOutput)
  363. {
  364.     gOutput = anOutput;
  365. }
  366.  
  367.  
  368. //µ   Formatting::DebugFormatting
  369. #pragma segment Formatting
  370. inline void Formatting::DebugFormatting(Boolean aFlag)
  371. {
  372.     gDebug = aFlag;
  373. }
  374.  
  375.  
  376. //µ   Formatting::SetRegister
  377. #pragma segment Formatting
  378. inline void Formatting::SetRegister(int dstReg, int aValue)
  379. {
  380.     fContext.fReg[dstReg] = aValue;
  381. }
  382.  
  383.  
  384. //µ   Formatting::GetRegister
  385. #pragma segment Formatting
  386. inline int Formatting::GetRegister(int srcReg) const
  387. {
  388.     return (fContext.fReg[srcReg]);
  389. }
  390.  
  391.  
  392. //µ   Formatting::CurrentColumn
  393. #pragma segment Formatting
  394. inline short &Formatting::CurrentColumn()
  395. {
  396.     return (fContext.fReg[kRegCurrentColumn]);
  397. }
  398.  
  399.  
  400. //µ   Formatting::GetIndent
  401. #pragma segment Formatting
  402. inline short Formatting::GetIndent() const
  403. {
  404.     return (GetRegister(kRegIndent));
  405. }
  406.  
  407.  
  408. //µ   Formatting::SetIndent
  409. #pragma segment Formatting
  410. inline void Formatting::SetIndent(short anIndent)
  411. {
  412.     SetRegister(kRegIndent, anIndent);
  413. }
  414.  
  415.  
  416. //µ   Formatting::AddIndent
  417. #pragma segment Formatting
  418. inline void Formatting::AddIndent(short aDelta)
  419. {
  420.     SetIndent(GetIndent() + aDelta);
  421. }
  422.  
  423.  
  424. //µ   Formatting::IncrIndent
  425. #pragma segment Formatting
  426. inline void Formatting::IncrIndent()
  427. {
  428.     AddIndent(GetRegister(kRegIndentDelta));
  429. }
  430.  
  431.  
  432. //µ   Formatting::CommentColumn
  433. #pragma segment Formatting
  434. inline void Formatting::CommentColumn(short aColumn)
  435. {
  436.     gCommentColumn = aColumn;
  437. }
  438.  
  439.  
  440. //µ   Formatting::CommentColumn
  441. #pragma segment Formatting
  442. inline short Formatting::CommentColumn()
  443. {
  444.     return (gCommentColumn);
  445. }
  446.  
  447.  
  448. //µ   Formatting::TabSize
  449. #pragma segment Formatting
  450. inline void Formatting::TabSize(short n)
  451. {
  452.     gTabSize = n;
  453. }
  454.  
  455.  
  456. //µ   Formatting::TabSize
  457. #pragma segment Formatting
  458. inline short Formatting::TabSize()
  459. {
  460.     return (gTabSize);
  461. }
  462.  
  463.  
  464. //µ   Formatting::LineLength
  465. #pragma segment Formatting
  466. inline void Formatting::LineLength(short aColumn)
  467. {
  468.     gLineLength = aColumn;
  469. }
  470.  
  471.  
  472. //µ   Formatting::LineLength
  473. #pragma segment Formatting
  474. inline short Formatting::LineLength()
  475. {
  476.     return (gLineLength);
  477. }
  478.  
  479.  
  480. //µ   Formatting::ReformatComments
  481. #pragma segment Formatting
  482. inline void Formatting::ReformatComments(Boolean aFlag)
  483. {
  484.     gReformatComments = aFlag;
  485. }
  486.  
  487.  
  488. //µ   Formatting::ReformatComments
  489. #pragma segment Formatting
  490. inline Boolean Formatting::ReformatComments()
  491. {
  492.     return (gReformatComments);
  493. }
  494.  
  495.  
  496. //µ   Formatting::PassSourceNewLines
  497. #pragma segment Formatting
  498. inline void Formatting::PassSourceNewLines(Boolean aFlag)
  499. {
  500.     gPassSourceNewLines = aFlag;
  501. }
  502.  
  503.  
  504. //µ   Formatting::PassSourceNewLines
  505. #pragma segment Formatting
  506. inline Boolean Formatting::PassSourceNewLines()
  507. {
  508.     return (gPassSourceNewLines);
  509. }
  510.  
  511.  
  512. //µ   Formatting::PassConsecutiveNewLines
  513. #pragma segment Formatting
  514. inline void Formatting::PassConsecutiveNewLines(Boolean aFlag)
  515. {
  516.     gPassConsecutiveNewLines = aFlag;
  517. }
  518.  
  519.  
  520. //µ   Formatting::PassConsecutiveNewLines
  521. #pragma segment Formatting
  522. inline Boolean Formatting::PassConsecutiveNewLines()
  523. {
  524.     return (gPassConsecutiveNewLines);
  525. }
  526.  
  527.  
  528. //µ   Formatting::DeclLeft
  529. #pragma segment Formatting
  530. inline Boolean Formatting::DeclLeft() const
  531. {
  532.     return (fContext.fDeclLeft);
  533. }
  534.  
  535.  
  536. //µ   Formatting::Comma
  537. #pragma segment Formatting
  538. inline void Formatting::Comma()
  539. {
  540.     SetGlue(fContext.fComma);
  541. }
  542.  
  543.  
  544. //µ   Formatting::Semi
  545. #pragma segment Formatting
  546. inline void Formatting::Semi()
  547. {
  548.     SetGlue(fContext.fSemi);
  549. }
  550.  
  551.  
  552. //µ   Formatting::LCurly
  553. #pragma segment Formatting
  554. inline void Formatting::LCurly()
  555. {
  556.     SetGlue(fContext.fLCurly);
  557. }
  558.  
  559.  
  560. //µ   Formatting::RCurly
  561. #pragma segment Formatting
  562. inline void Formatting::RCurly()
  563. {
  564.     SetGlue(fContext.fRCurly);
  565. }
  566.  
  567.  
  568. //µ   Formatting::LParen
  569. #pragma segment Formatting
  570. inline void Formatting::LParen()
  571. {
  572.     SetGlue(fContext.fLParen);
  573. }
  574.  
  575.  
  576. //µ   Formatting::RParen
  577. #pragma segment Formatting
  578. inline void Formatting::RParen()
  579. {
  580.     SetGlue(fContext.fRParen);
  581. }
  582.  
  583.  
  584. //µ   Formatting::Name
  585. #pragma segment Formatting
  586. inline void Formatting::Name()
  587. {
  588.     SetGlue(fContext.fName);
  589. }
  590.  
  591.  
  592. //µ   Formatting::Operator
  593. #pragma segment Formatting
  594. inline void Formatting::Operator()
  595. {
  596.     SetGlue(fContext.fOperator);
  597. }
  598.  
  599.  
  600. //µ   Formatting::Assign
  601. #pragma segment Formatting
  602. inline void Formatting::Assign()
  603. {
  604.     SetGlue(fContext.fAssign);
  605. }
  606.  
  607.  
  608. //µ   Formatting::Flush
  609. #pragma segment Formatting
  610. inline void Formatting::Flush()
  611. {
  612.     gOutput->Flush();
  613. }
  614.  
  615.  
  616. //µ   Formatting::SetComma
  617. #pragma segment Formatting
  618. inline void Formatting::SetComma(FormatString aString)
  619. {
  620.     fContext.fComma = aString;
  621. }
  622.  
  623.  
  624. //µ   Formatting::SetSemi
  625. #pragma segment Formatting
  626. inline void Formatting::SetSemi(FormatString aString)
  627. {
  628.     fContext.fSemi = aString;
  629. }
  630.  
  631.  
  632. //µ   Formatting::SetLCurly
  633. #pragma segment Formatting
  634. inline void Formatting::SetLCurly(FormatString aString)
  635. {
  636.     fContext.fLCurly = aString;
  637. }
  638.  
  639.  
  640. //µ   Formatting::SetRCurly
  641. #pragma segment Formatting
  642. inline void Formatting::SetRCurly(FormatString aString)
  643. {
  644.     fContext.fRCurly = aString;
  645. }
  646.  
  647.  
  648. //µ   Formatting::SetLParen
  649. #pragma segment Formatting
  650. inline void Formatting::SetLParen(FormatString aString)
  651. {
  652.     fContext.fLParen = aString;
  653. }
  654.  
  655.  
  656. //µ   Formatting::SetRParen
  657. #pragma segment Formatting
  658. inline void Formatting::SetRParen(FormatString aString)
  659. {
  660.     fContext.fRParen = aString;
  661. }
  662.  
  663.  
  664. //µ   Formatting::SetName
  665. #pragma segment Formatting
  666. inline void Formatting::SetName(FormatString aString)
  667. {
  668.     fContext.fName = aString;
  669. }
  670.  
  671.  
  672. //µ   Formatting::SetOperator
  673. #pragma segment Formatting
  674. inline void Formatting::SetOperator(FormatString aString)
  675. {
  676.     fContext.fOperator = aString;
  677. }
  678.  
  679.  
  680. //µ   Formatting::SetAssign
  681. #pragma segment Formatting
  682. inline void Formatting::SetAssign(FormatString aString)
  683. {
  684.     fContext.fAssign = aString;
  685. }
  686.  
  687.  
  688. //µ   Formatting::NewLineWanted
  689. #pragma segment Formatting
  690. inline static Boolean Formatting::NewLineWanted()
  691. {
  692.     return (gV.fWantNewLine > 0);
  693. }
  694.  
  695.  
  696. //µ   Formatting::SpaceWanted
  697. #pragma segment Formatting
  698. inline Boolean Formatting::SpaceWanted()
  699. {
  700.     return (gV.fWantSpace > 0);
  701. }
  702.  
  703.  
  704. //µ   Formatting::NewLineNeeded
  705. #pragma segment Formatting
  706. inline Boolean Formatting::NewLineNeeded()
  707. {
  708.     return (gV.fNeedNewLine > 0);
  709. }
  710.  
  711.  
  712. //µ   Formatting::SpaceNeeded
  713. #pragma segment Formatting
  714. inline Boolean Formatting::SpaceNeeded()
  715. {
  716.     return (gV.fNeedSpace > 0);
  717. }
  718.  
  719.  
  720. //µ   Formatting::WantNewLine
  721. #pragma segment Formatting
  722. inline void Formatting::WantNewLine(short n)
  723. {
  724.     gV.fWantNewLine += n;
  725. }
  726.  
  727.  
  728. //µ   Formatting::WantSpace
  729. #pragma segment Formatting
  730. inline void Formatting::WantSpace(short n)
  731. {
  732.     gV.fWantSpace += n;
  733. }
  734.  
  735.  
  736. //µ   Formatting::NeedNewLine
  737. #pragma segment Formatting
  738. inline void Formatting::NeedNewLine(short n)
  739. {
  740.     gV.fNeedNewLine += n;
  741. }
  742.  
  743.  
  744. //µ   Formatting::NeedSpace
  745. #pragma segment Formatting
  746. inline void Formatting::NeedSpace(short n)
  747. {
  748.     gV.fNeedSpace += n;
  749. }
  750.  
  751.  
  752. //µ   Formatting::IndentTo
  753. #pragma segment Formatting
  754. inline void Formatting::IndentTo()
  755. {
  756.     IndentTo(GetIndent());
  757. }
  758.  
  759.  
  760. //µ   Formatting::IndentLine
  761. #pragma segment Formatting
  762. inline void Formatting::IndentLine()
  763. {
  764.     IndentLine(GetIndent());
  765. }
  766.  
  767.  
  768. //µ   Formatting::AtBOL
  769. #pragma segment Formatting
  770. inline void Formatting::AtBOL()
  771. {
  772.     gV.fLastTokenType = kSLex_NewLine;
  773. }
  774.  
  775.  
  776. //µ   Formatting::WhatToSqueeze
  777. #pragma segment Formatting
  778. inline short Formatting::WhatToSqueeze() const
  779. {
  780.     return (fContext.fWhatToSqueeze);
  781. }
  782.  
  783.  
  784. //µ   Formatting::SetWhatToSqueeze
  785. #pragma segment Formatting
  786. inline void Formatting::SetWhatToSqueeze(short what)
  787. {
  788.     fContext.fWhatToSqueeze = what;
  789. }
  790.  
  791.  
  792. //µ   Formatting::_Putc
  793. #pragma segment Formatting
  794. inline void Formatting::_Putc(int aChar)
  795. {
  796.     gOutput->Putc(aChar);
  797.     ++CurrentColumn();
  798. }
  799.  
  800.  
  801. //µ   Formatting::_Write
  802. #pragma segment Formatting
  803. inline void Formatting::_Write(const void *aString, size_t n)
  804. {
  805.     gOutput->Write(aString, n);
  806.     CurrentColumn() += n;
  807. }
  808.  
  809.  
  810. #endif
  811.  
  812.  
  813.