graphic.cpp // CMSC 405 Computer Graphics
// Project 1
// Duane J. Jarc
// August 1, 2013
// Function bodies of class that defines all graphic objects
#include “stdafx.h”
// Constructor that can only be called by the subclasses to initialize the color
Graphic::Graphic(Color color)
{
this->color = color;
}
// Sets the color of the graphic to be draw. Must be called first by the draw function of the subclasses
void Graphic::colorDrawing() const
{
glColor3d(color.red, color.green, color.blue);
}
graphic.h // CMSC 405 Computer Graphics
// Project 1
// Duane J. Jarc
// August 1, 2013
// An abstract class that defines all graphic objects
// All subclasses must define the abstract (pure virtual) function draw
class Graphic
{
public:
virtual void draw() const = 0;
protected:
Graphic(Color color);
void colorDrawing() const;
private:
Color color;
};
lexer.cpp // CMSC 405 Computer Graphics
// Project 1
// Duane J. Jarc
// August 1, 2013
// Function bdies of lexical analyzer used by the parser to parse the scene definition file
#include “stdafx.h”
static string punctuation = “,;.()”;
static Token punctuationTokens[] = {COMMA, SEMICOLON, PERIOD, LEFT_PAREN, RIGHT_PAREN};
// Constructor which must be supplied the name of the scene definition file
Lexer::Lexer(string fileName)
{
in = new ifstream(fileName);
lineNo = 1;
}
// Returns the next token each time it is called, Tokens are defined in token.h
Token Lexer::getNextToken()
{
stringstream ss;
// Skips leading spaces
while (isspace(in->peek()))
{
if (in->peek() == ‘n’)
lineNo++;
in->get();
}
// Checks for a string token
if (in->peek() == ‘”‘)
{
in->get();
while (in->peek() != ‘”‘)
ss get();
in->get();
lexeme = ss.str();
return STRING;
}
// Checks for punctuation tokens
for (unsigned i = 0; i peek() ==…





