From 1ee5f374ed986333d5cdbbf41390f1c4c755a8e3 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 12 Oct 2010 06:09:48 +0000 Subject: This commit has a minor tweak to the variant class to make it easier to use, and introduces the parser and lexer classes. I also made a test for parser and put it in the tools directory. That is silly, it shouldn't be. However, it's necesarry right now, because I don't want to do a full build to compile all the parser tests. However, this commit doesn't actually build yet. It will soon, I just wanted to get it all committed. --- src/parser.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/parser.cpp (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp new file mode 100644 index 0000000..7015070 --- /dev/null +++ b/src/parser.cpp @@ -0,0 +1,43 @@ +#include "bu/parser.h" +#include "bu/lexer.h" + +#include "bu/sio.h" +using namespace Bu; + +Bu::Parser::Parser() +{ +} + +Bu::Parser::~Parser() +{ +} + +void Bu::Parser::pushLexer( Lexer *pLex ) +{ + sLexer.push( pLex ); +} + +void Bu::Parser::popLexer() +{ + delete sLexer.peekPop(); +} + +void Bu::Parser::parse() +{ + for(;;) + { + Bu::Lexer::Token *pToken = sLexer.peek()->nextToken(); + sio << sLexer.peek()->tokenToString( *pToken ) << sio.nl; + if( pToken->iToken < 0 ) + { + delete sLexer.peekPop(); + if( sLexer.isEmpty() ) + { + delete pToken; + return; + } + } + delete pToken; + } +} + -- cgit v1.2.3