Arena  1.0
A content management system
 All Classes Files Functions Variables Pages
Library.Parse.Parsers.AParser Class Reference

A parser. More...

+ Inheritance diagram for Library.Parse.Parsers.AParser:

Public Member Functions

def __init__
 Constructor. More...
 
def init
 Initializer.
 
def __del__
 Destructor.
 
def syntaxError
 
def fatalError
 Log a fatal error. More...
 
def hint
 Log a hint. More...
 
def warn
 Log a warning. More...
 
def note
 Log a note. More...
 
def parseCurrentToken
 Parse the current token. More...
 
def parseUntil
 Parse tokens until one of the specified tokens is encountered.
 
def parse
 Execute the parser. More...
 
def PeekToken
 Peek at the next token from the source. More...
 
def NextToken
 Retrieve the next token from the source. More...
 
def NextTokenIfMatch
 Retrieve the next token from the source only if the current token matches the specified token code. More...
 
def skipTo
 Skip tokens until one of the specified tokens is encountered. More...
 
def resyncTo
 Resynchronize the parser to the specified opcode or opcodes. More...
 
def Scanner
 Retrieve the scanner used by the parser. More...
 
def Token
 Retrieve the most recent token retrieved from the scanner. More...
 
def PreviousToken
 Retrieve the previous token retrieved from the scanner.
 
def Log
 Retrieve the log used by the parser. More...
 
def Source
 Retrieve the source stream used by the parser. More...
 
def Output
 Retrieve the output stream used by the parser.
 
def OutputTo
 Set the output stream used by the parser. More...
 
def line
 Retrieve the current line number from the scanner. More...
 
def __iter__
 Iterate through the tokens in the source. More...
 
- Public Member Functions inherited from Library.Base.Events.ALoggingEventfulObject
def __init__
 Constructor. More...
 
def init
 Initializer.
 
def error
 Generate an error event. More...
 
def log
 Log the specified item. More...
 
def Log
 Retrieve the log used by the class.
 
- Public Member Functions inherited from Library.Base.Events.AnEventfulObject
def __init__
 Constructor. More...
 
def init
 Initializer.
 
def __del__
 Destructor.
 
def parseParams
 Parse the specified parameters, looking for named events and setting event handlers as appropriate. More...
 
def generate
 Generate the named event.
 
def update
 Update the events generated by the object.
 
def error
 Generate an error event. More...
 
def toString
 Construct a string representation of the object. More...
 
def on
 Set the handler for the specified event. More...
 
def onMultiple
 Set handlers for multiple events. More...
 
def handlerFor
 Retrieve the handler for the specified event. More...
 
def generates
 Determine whether or not the object generates the named event. More...
 
def __getitem__
 Retrieve the value of the named property.
 
def __setitem__
 Set the value of the named property.
 
- Public Member Functions inherited from Library.Base.Classwork.AnObject
def init
 Initialize a new object instance. More...
 
def __init__
 Construct and initialize a new instance of AnObject. More...
 
def __del__
 Destroy the object instance. More...
 
def displayName
 Construct a "pretty" display name for the class instance, based on the name of its class. More...
 
def implements
 Determine whether the class instance is related to the specified class. More...
 
def toString
 Return a string representation of the class, suitable for output to a console or text-based device. More...
 
def __str__
 Return a string representation of the class. More...
 
def classname
 Return the name of the class from which the instance was created. More...
 
def name
 Return the name of the class. More...
 
- Public Member Functions inherited from Library.String.Utilities.IsPrintable
def toString
 Return a string representation of the class conveniently. More...
 
def __str__
 Return a string representation of the class. More...
 
def printTo
 Print a string representation of the class to the specified stream. More...
 

Detailed Description

A parser.

Constructor & Destructor Documentation

def Library.Parse.Parsers.AParser.__init__ (   Self,
  params 
)

Constructor.

In addition to the parameters expected by ALoggingEventfulObject.__init__(), this method expects that params will contain the following items:

  • Source – A reference to the stream to be used for input.

Member Function Documentation

def Library.Parse.Parsers.AParser.__iter__ (   Self)

Iterate through the tokens in the source.

This routine is provided for convenience, so that the parser can be used in a for...in loop.

def Library.Parse.Parsers.AParser.fatalError (   Self,
  msg,
  params 
)

Log a fatal error.

If an event handler is specified for this event, it will receive an instance of AnEvent with the msg and params parameters passed to this method. The handler should set Event.handled() to True in order to prevent the error from being logged.

def Library.Parse.Parsers.AParser.hint (   Self,
  msg,
  params 
)

Log a hint.

If an event handler is specified for this event, it will receive an instance of AnEvent with the msg and params parameters passed to this method. The handler should set Event.handled() to True in order to prevent the hint from being logged.

def Library.Parse.Parsers.AParser.line (   Self)

Retrieve the current line number from the scanner.

def Library.Parse.Parsers.AParser.Log (   Self)

Retrieve the log used by the parser.

def Library.Parse.Parsers.AParser.NextToken (   Self)

Retrieve the next token from the source.

def Library.Parse.Parsers.AParser.NextTokenIfMatch (   Self,
  thisTokenCode,
  muteCurrentToken = False 
)

Retrieve the next token from the source only if the current token matches the specified token code.

If /p muteCurrentToken is /p True, the /p silent property of the current token is set to /p True, which will prevent it from being written to the destination stream.

def Library.Parse.Parsers.AParser.note (   Self,
  msg,
  params 
)

Log a note.

If an event handler is specified for this event, it will receive an instance of AnEvent with the msg and params parameters passed to this method. The handler should set Event.handled() to True in order to prevent the note from being logged.

def Library.Parse.Parsers.AParser.OutputTo (   Self,
  NewOutput 
)

Set the output stream used by the parser.

Returns the previous output stream, if any.

def Library.Parse.Parsers.AParser.parse (   Self)

Execute the parser.

This method checks that the parser has a valid output stream. If not, it raises an exception; otherwise it calls AParser.parseUntil() to parse tokens until the end of the stream is encountered.

def Library.Parse.Parsers.AParser.parseCurrentToken (   Self)

Parse the current token.

This method should be implemented by descendant classes. It may parse one or more tokens and then return control to the calling method.

There is little need to call this method directly (from outside an implementation of this class), as it is called by AParser.parseUntil().

def Library.Parse.Parsers.AParser.PeekToken (   Self)

Peek at the next token from the source.

def Library.Parse.Parsers.AParser.resyncTo (   Self,
  theseTokenCodes 
)

Resynchronize the parser to the specified opcode or opcodes.

def Library.Parse.Parsers.AParser.Scanner (   Self)

Retrieve the scanner used by the parser.

def Library.Parse.Parsers.AParser.skipTo (   Self,
  theseTokenCodes 
)

Skip tokens until one of the specified tokens is encountered.

Tokens encountered along the way are muted, and so excluded from the parser output.

def Library.Parse.Parsers.AParser.Source (   Self)

Retrieve the source stream used by the parser.

def Library.Parse.Parsers.AParser.Token (   Self)

Retrieve the most recent token retrieved from the scanner.

def Library.Parse.Parsers.AParser.warn (   Self,
  msg,
  params 
)

Log a warning.

If an event handler is specified for this event, it will receive an instance of AnEvent with the msg and params parameters passed to this method. The handler should set Event.handled() to True in order to prevent the warning from being logged.


The documentation for this class was generated from the following file: