Parser.h

Go to the documentation of this file.
00001 
00005 #ifndef Parser_h
00006 #define Parser_h
00007 
00008 #include "Vector.h"
00009 #include "Point.h"
00010 #include "Color.h"
00011 #include <iostream>
00012 #include <string>
00013 #include <map>
00014 
00015 class Camera;
00016 class Background;
00017 class Light;
00018 class Material;
00019 class Object;
00020 class Scene;
00021 class Triangle;
00022 
00023 class Parser {
00024 
00025   struct Token {
00026     enum type {
00027       end_of_file,
00028       integer, real, string,
00029       left_brace, right_brace,
00030       left_bracket, right_bracket,
00031       comma
00032     };
00033     type token_type;
00034     std::string string_value;
00035     int integer_value;
00036     double real_value;
00037     int line_number;
00038     int column_number;
00039   };
00040   std::istream &input;
00041   int line_number;
00042   int column_number;
00043   Token next_token;
00044   Material *default_material;
00045   std::map< std::string, Material * > defined_materials;
00046   std::map< std::string, Object * > defined_objects;
00047 
00048   void throwParseException(
00049     std::string const &message ) const;
00050 
00051   void readNextToken();
00052   bool peek(Token::type const type );
00053   bool peek(std::string const &keyword );
00054   Token match(
00055     Token::type const type,
00056     std::string const &failure_message );
00057   Token match(
00058     std::string const &keyword,
00059     std::string const &failure_message );
00060 
00061   std::string parseString();
00062   bool parseBoolean();
00063   int parseInteger();
00064   double parseReal();
00065   Vector const parseVector();
00066   Point const parsePoint();
00067   Color const parseColor();
00068 
00069   Camera *parsePinholeCamera();
00070   Camera *parseCamera();
00071 
00072   Background *parseConstantBackground();
00073   Background *parseBackground();
00074 
00075   Light *parsePointLight();
00076   Light *parseLight();
00077 
00078   Material *parseLambertianMaterial();
00079   Material *parseMaterial();
00080 
00081   Object *parseGroupObject();
00082   Object *parsePlaneObject();
00083   Object *parseSphereObject();
00084   Object *parseCylObject();
00085   Object *parseTriangleObject();
00086   Object *parseRingObject();
00087   Object *parseBoxObject();
00088   Object *parseObject();
00089 
00090   public:
00091 
00092   Parser(
00093     std::istream &input );
00094 
00095   Scene *parseScene(
00096     std::string &filename );
00097 
00098 };
00099 
00100 #endif

Generated on Tue Jan 29 21:34:53 2008 for specter by  doxygen 1.4.6