Source: graph/parser.h


Annotated List
Files
Globals
Hierarchy
Index
/***************************************************************************
                          parser.h  -  description
                             -------------------
    begin                : Thu Apr 20 2000
    copyright            : (C) 2000 by Jan H. Meinke
    email                : meinke@bigfoot.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef PARSER_H
#define PARSER_H
#include <iostream>
#include <string>
#include <cctype>
#include <stdlib.h>

/** Takes an input stream and divides it into tokens.
  * This code was mostly inspired by the calculator example by
  * Bjarne Stroustrup, "The C++ Programming Language", 3rd., pp. 108ff (1997)
  *
  *@author Jan H. Meinke
  */

class Parser {
public: 
	Parser(istream* is);
	~Parser();
	
public: // Public attributes
  /** Possible token values used by the Parser. */
  enum Tokens{
  	STRING, NUMBER, END, BAD, NEWLINE, DIRECTIVE,
  	COLON = ':', OTAG = '<', CTAG ='>', DEFTAG = '!'
  };

  enum Tag{
  	DIR
  };
  /** This variable contains the numerical value of the last token
  * if appropriate.
  */
  double numberValue;

  /** Holds the type of the last token read. */
  Tokens currentToken;
  /** This variable contains the string value of the last token
   *  if appropriate.
   */
  string stringValue;

  /** Returns the next token in the stream. The value
  * is stored in  the public variables stringValue
  * and numberValue if appropriate.
  */
  Tokens nextToken();
  /** Tries to construct a tag of the form < element.name attribute1 attribute2 ... >.
  * The elementName will be stored in tagAttribute[0] and all following attributes
  * in tagAttribute[1..n].
  */
  Tag getTag();

private: // Private attributes
  /** Data input stream to be tokenized */
  istream* is;
};

#endif

Generated by: meinke@orion on Mon May 8 18:18:46 2000, using kdoc 2.0a35.