Skip to main content

%Library.SyntaxColorReader

class %Library.SyntaxColorReader extends %Library.RegisteredObject

Front end for reading the CSV output from %SyntaxColor:Color. Instead of reading the stream directly and reconstructing the lines you can use a %SyntaxColorReader object and call its NextLine method.

To create a %SyntaxColorReader object you can pass a CSV stream to %New; alternatively you can call FromCode and it will call %SyntaxColor for you.

Method Inventory

Methods

method %OnNew(CSV As %Stream.Object, BufferStream As %Boolean = 0) as %Status

Create a %SyntaxColorReader over the given CSV stream

method AtEndGet() as %Boolean

The AtEnd property can be used to check for the end of the reader over the CSV stream

method ForgetNotedPosition() as %Status

Forget the noted position

classmethod FromCode(Code As %Stream.Object, Language As %String, ExtraFlags As %String, ByRef Reader As %Library.SyntaxColorReader, ByRef AnyColoringErrors As %Boolean, ByRef AnyColoringWarnings As %Boolean, Symbols As %String = "", BufferStream As %Boolean = 0) as %Status

Given a code stream, language, optional extra flags and/or symbols string for %SyntaxColor:Color

Return a %SyntaxColorReader over the resulting CSV and whether there were any coloring errors/warnings (anywhere in the document)

method GetInfoLine() as %String
Return the info line, if any Not valid until AtEnd
method NextErrorInfo(Output Description As %String, Output Source As %String, Output Location As %String, Output LineNumber As %Integer, Output LineOffset As %Integer) as %Boolean
Return the next error info Not valid until AtEnd
method NextLine(ByRef LineCSV As %List, ByRef ColoringErrors As %Boolean, ByRef ColoringWarnings As %Boolean) as %Boolean

Return a structured list of coloring information about the current line of code represented by the CSV stream, advancing the stream. In general, a number of lines will be read from the CSV stream to make up one logical line corresponding to a line of the original code. CSV lines of the form "\n" determine logical line boundaries.

If the stream is at its end this method returns 0, otherwise 1.

If 1 is returned the ByRef parameters are set up from the stream items which were read :-

  • LineCSV is set to a list of items, where each item is $LB(lang,terminal,code)
  • ColoringErrors and ColoringWarnings are set to whether there were any coloring errors/warnings at all on the line
method NotePosition() as %Status

Note the current stream position, caller must call RestorePosition or ForgetPosition later.

method RestoreNotedPosition() as %Status

Restore the noted position

method Rewind() as %Status

Move back to the beginning of the stream

- not allowed if the position is noted

method SkipLines(N As %Integer)

Move forward N lines - stops if end of file found first (doesn't report any error)

Inherited Members

Inherited Methods

FeedbackOpens in a new tab