DIRECTORY IO, Rope, TextNode, TiogaFileOps; TiogaStreams: CEDAR DEFINITIONS = BEGIN ROPE: TYPE = Rope.ROPE; CreateInput: PROC [from: TextNode.Ref, commentHandling: CommentHandling ¬ [FALSE[]], levelPrefix: ROPE ¬ NIL] RETURNS [in: IO.STREAM]; CommentHandling: TYPE = RECORD [variant: SELECT see: BOOL FROM FALSE => [], TRUE => [prefix, suffix: ROPE ¬ NIL], ENDCASE]; CurInLoc: PROC [s: IO.STREAM] RETURNS [loc: TextNode.Location]; SkipChildren: PROC [s: IO.STREAM]; CreateOutput: PROC [to: TiogaFileOps.Ref, breakAtNewline: BOOL ¬ FALSE, levelPrefix, defaultFormat: ROPE ¬ NIL, flexilevel: BOOL ¬ FALSE, spacesPerTab, normalNestIndent, minFmtIndent: INT ¬ 0, maxFmtIndent: INT ¬ -1, commentHandling: CommentHandling ¬ [FALSE[]] ] RETURNS [out: IO.STREAM]; CurOutNode: PROC [s: IO.STREAM] RETURNS [n: TiogaFileOps.Ref]; EndNode: PROC [s: IO.STREAM, depthOp: DepthOp ¬ reset, idempotently: BOOLEAN ¬ FALSE]; DepthOp: TYPE = {same, reset}; SetFormat: PROC [of: IO.STREAM, format: ROPE]; ChangeDepth: PROC [s: IO.STREAM, deltaDepth: INTEGER ¬ 0, autoEndNode: BOOL ¬ TRUE, idempotently: BOOL ¬ FALSE]; NotNow: ERROR [s: IO.STREAM]; BadDepth: ERROR [s: IO.STREAM, depth: INT]; CallerBug: ERROR [s: IO.STREAM, message: ROPE]; IsATS: PROC [s: IO.STREAM] RETURNS [is: BOOLEAN]; CopyChildren: PROC [from: TextNode.Ref, to: TiogaFileOps.Ref]; END. & TiogaStreams.Mesa Copyright Σ 1992 by Xerox Corporation. All rights reserved. Mike Spreitzer May 12, 1992 9:15 am PDT Input Create a Tioga Input Stream on descendents of from. Each subnode's chars are prefixed by levelPrefix * (-1 + its depth realtive to from), then maybe prefix for comment nodes. Each subnode's chars are suffixed by a newline, after the comment suffix (if any). What to do about comment nodes. Where the "carat" is. This is a position between characters, or index of next character. Phony prefixes and postfixes get "squeezed" out. Skips children of CurInNode[s]. Output Creates children of to. IF breakAtNewline, THEN s.PutChar['\n] gets translated to s.EndNode[reset, FALSE]. IF (NOT flexilevel) AND levelPrefix # NIL, THEN every node that begins with N repetitions of levelPrefix will be indented N levels deeper than it otherwise would be. IF flexilevel, THEN the depth of each node is 1 more than the depth of the most recent node with less leading whitespace. Spaces are white; tabs are white iff spacesPerTab>0; nothing else is white. Each child node will have format=defaultFormat, unless explicitly overridden by SetFormat. IF flexilevel AND normalNestIndent>0 AND maxFmtIndent= minFmtIndent, THEN each node whose amount of leading white space exceeds it parent's by N is created with format defaultFormat-N if N IN [minFmtIndent..maxFmtIndent], otherwise with format defaultFormat-M and a postfix property (M IN {minFmtIndent, maxFmtIndent}); normalNestIndent is indentation of children relative to parent. When commentHandling.see, nodes with the given prefix and suffix become comment nodes without the prefix or suffix. Returns the one just before the "carat", which is, of course, between characters. depthOp says whether new node should have same depth as previous, or revert to initial (direct child of CreateOutput's to). May be further modified by ChangeDepth or receiving levelPrefixes. Applies to CurOutNode only. IF autoEndNode, THEN first EndNode[same, idempotently]. Must be called "between" nodes (autoEndNode trivializes that). Changes depth of following node from what it would otherwise be. Can't be called on flexilevel streams. Raised by ChangeDepth when called before node ended. Raised when depth (relative to CreateOutput's to) goes negative --- usually from IO operations (like PutChar) that put the first character on a node. When depth jumps deeper than Tioga will (i.e., more than one level per jump), the difference is made up by prefixing with copies of levelPrefix. General escape. Other Accepts either input or output streams. Κn–(cedarcode) style•NewlineDelimiter ™™Jšœ Οeœ1™Kšžœ˜ Kšžœžœžœ˜%Kšžœ˜ K™—K˜š  œžœžœžœžœ˜?K™‹—K˜š  œžœžœžœ˜"K™——™š  œžœ(žœžœžœžœžœžœ0žœžœ+žœžœžœžœ˜‘Kšœœ™KšœR™RKšœ₯™₯KšœΖ™ΖKšœZ™ZKšœ“™“Kšœκ™κKšœs™s—K˜š   œžœžœžœžœ˜>Kšœ>œ ™Q—K˜š  œžœžœžœ*žœžœ˜VKšœwœE™Ύ—K˜Kšœ žœ˜K˜š   œžœžœžœ žœ˜.Kšœ™—K˜š  œžœžœžœžœžœžœžœžœ˜pKšœ7™7Kšœ>™>K™@K™&—K˜šΠblœžœžœžœ˜Kšœ4™4—K˜š ‘œžœžœžœ žœ˜+Kšœ.œe™•K™—K˜š Ρbln œžœžœžœ žœ˜/K™——™š  œžœžœžœžœžœ˜1K™'—K˜Kš  œžœ,˜>—K˜Kšžœ˜—…—Jή