Skip to content

Commit

Permalink
Some header cleanups in the lexer, symtable is now not initialized in…
Browse files Browse the repository at this point in the history
… main anymore
  • Loading branch information
psde committed Jan 16, 2013
1 parent ade6ac8 commit 299d15e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
13 changes: 10 additions & 3 deletions src/Lexer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
//#define LEXER_DEBUG
#include "BufferReader.hpp"
#include "Symtable.hpp"
#include "String.hpp"

#include "Lexer.hpp"

#ifdef _DEBUG
#define LEXER_DEBUG
#endif

String LexerStateStrings[] =
{
"STATE_ERROR",
Expand Down Expand Up @@ -28,10 +35,10 @@ String LexerStateStrings[] =
"STATE_NOSTATE"
};

Lexer::Lexer(BufferReader *buffer, Symtable *symtable)
Lexer::Lexer(BufferReader *buffer)
{
this->buffer = buffer;
this->symtable = symtable;
this->symtable = new Symtable(4096);
this->setup();

this->pos.line = 1;
Expand Down
8 changes: 3 additions & 5 deletions src/Lexer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
#define LEXER_HPP

#include <ctype.h>
#include "Symtable.hpp"
#include "Token.hpp"
#include "BufferReader.hpp"
#include "String.hpp"

//#define LEXER_DEBUG
class BufferReader;
class Symtable;

class Position
{
Expand Down Expand Up @@ -73,7 +71,7 @@ class Lexer
bool isComment();

public:
Lexer(BufferReader *buffer, Symtable *symtable);
Lexer(BufferReader *buffer);

Token nextToken();
};
Expand Down
11 changes: 2 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Debug stuff...
#define NO_DIRECT_IO // Use this if developing on crypto fs

#define VERSION "0.1"
#define VERSION "0.2"

#ifndef __GNUC__
#error "You need GCC to compile this."
Expand All @@ -10,7 +9,6 @@
#include <iostream>
#include <iomanip>

// TODO: Beautfiy this
#include "String.hpp"
#include "BufferReader.hpp"
#include "BufferWriter.hpp"
Expand Down Expand Up @@ -54,10 +52,8 @@ int main(int argc, char *argv[])
{
std::cout << "Using stdout for code output." << std::endl;
}

Symtable *symtable = new Symtable(1024);

Lexer *lex = new Lexer(buf, symtable);
Lexer *lex = new Lexer(buf);

Parser *parser = new Parser(lex);

Expand All @@ -71,7 +67,6 @@ int main(int argc, char *argv[])
{
std::cout << "failed." << std::endl;
std::cout << err.what() << std::endl;
std::cout << "Exiting." << std::endl;
return 1;
}
std::cout << "done." << std::endl;
Expand Down Expand Up @@ -142,8 +137,6 @@ int main(int argc, char *argv[])

delete buf;
delete lex;
delete symtable;

std::cout << "Finished." << std::endl;
return 0;
}

0 comments on commit 299d15e

Please sign in to comment.