BIE::AsciiLexer Class Reference

A simple ascii lexer used by the RecordInputStream_Ascii class. More...

#include <AsciiLexer.h>

List of all members.

Public Types

enum  {
  AL_NEWLINE_, AL_INT_KEYWORD_, AL_REAL_KEYWORD_, AL_BOOL_KEYWORD_,
  AL_STRING_KEYWORD_, AL_STRING_VALUE_, AL_INT_VALUE_, AL_REAL_VALUE_,
  AL_COMMA_, AL_EQUALS_, AL_LEFT_CURLY_, AL_RIGHT_CURLY_,
  AL_LEFT_SQUAREBRACKET_, AL_ATRATE_, AL_EOF_, AL_ERROR_
}
 Codes returned by the lexer method nextToken().

Public Member Functions

 AsciiLexer (string filename)
 Creates a new lexer object by opening the specified file.
 AsciiLexer (istream *stream)
 Creates a new lexer object which reads from the specified input stream.
 ~AsciiLexer ()
 destructor - closes the input file if it was opened by this class.
int nextToken ()
 Gets the nextToken from the input file.
const char * tokenText ()
 Returns the text of the token.


Detailed Description

A simple ascii lexer used by the RecordInputStream_Ascii class.

The bulk of the class is implemented by code automatically produced by FLEX. An AsciiLexer object can be created by passing the name of a file, or an open stream. To advance to the next token in the stream, use the nextToken() method -- this returns a code describing the type of token discover. To obtain the text of the token, call the tokenText() method. The text of the token is NULL (0) until nextToken is called.

The flexer's tokens are as follows: newline, string literals (including the escaped characters \n, \t, \\, and \", in their usual interpretion) integer literals, floating point literals (including INF, NaN), keywords INT, BOOL, REAL, STRING (all case insensitive), and several single character symbols. See the symbol enumeration for a full list.

This class inherits from two different classes - BaseObject (persistence) and yyFlexLexer (Flex). I didn't see any simple way around this with the tools we currently have.

See also:
RecordInputStream_Ascii

Constructor & Destructor Documentation

BIE::AsciiLexer::AsciiLexer ( string  filename  ) 

Creates a new lexer object by opening the specified file.

FileException is thrown if the file does not exist.

BIE::AsciiLexer::AsciiLexer ( istream *  stream  ) 

Creates a new lexer object which reads from the specified input stream.


Member Function Documentation

int BIE::AsciiLexer::nextToken (  )  [inline]

Gets the nextToken from the input file.

The code returned by this routine is one of the codes in the enumeration defined below.

const char* BIE::AsciiLexer::tokenText (  )  [inline]

Returns the text of the token.

The memory belongs to FLEX, and should not be interfered with!


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

Send suggestions, questions, and feedback to WEINBERG at ASTRO dot UMASS dot EDU.
Documentation generated at Fri Mar 26 00:35:12 2010 by doxygen