// ---------------------------------------------------------------------------
// - Reader.hpp -
// - afnix engine - reader class definition -
// ---------------------------------------------------------------------------
// - This program is free software; you can redistribute it and/or modify -
// - it provided that this copyright notice is kept intact. -
// - -
// - This program is distributed in the hope that it will be useful, but -
// - without any warranty; without even the implied warranty of -
// - merchantability or fitness for a particular purpose. In no event shall -
// - the copyright holder be liable for any direct, indirect, incidental or -
// - special damages arising in any way out of the use of this software. -
// ---------------------------------------------------------------------------
// - copyright (c) 1999-2007 amaury darsch -
// ---------------------------------------------------------------------------
#ifndef AFNIX_READER_HPP
#define AFNIX_READER_HPP
#ifndef AFNIX_LEXER_HPP
#include "Lexer.hpp"
#endif
#ifndef AFNIX_FORMER_HPP
#include "Former.hpp"
#endif
namespace afnix {
/// The Reader class is the general purpose form reader which supports the
/// unified afnix syntax. The reader is primarily used to parse file or
/// be run interactively. The reader consumes tokens until a complete form
/// can be built. The form does not have any particular meaning and must be
/// post processed by the application.
/// @author amaury darsch
class Reader : public Former {
private:
/// the lexer class
Lexer* p_lex;
/// the input stream used by this reader
Input* p_is;
/// the file name we are reading
String d_fname;
public:
/// create a new reader with an input stream
/// @param is the input s
Reader (Input* is);
/// destroy this reader
~Reader (void);
/// @return the class name
String repr (void) const;
/// @return a form from this reader or nil in case of eof
Form* parse (void);
/// set the reader file name
/// @param fname the reader file name
void setfname (const String& fname);
/// @return an approximate line number for this reader
long getlnum (void) const;
private:
// make the copy constructor private
Reader (const Reader&);
// make the assignement operator private
Reader& operator = (const Reader&);
// private reader procedures
Form* rform (bool);
Form* bform (bool);
};
}
#endif
syntax highlighted by Code2HTML, v. 0.9.1