some improvements i think
This commit is contained in:
53
asmrigs/brb/lexer.cpp
Normal file
53
asmrigs/brb/lexer.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "brb.h"
|
||||
|
||||
abstract_class CBLexerWord: public IBLexerWord
|
||||
{
|
||||
public:
|
||||
virtual int GetType() override;
|
||||
|
||||
CUtlVector<ILexerWord*> m_children;
|
||||
EBWordType m_eType;
|
||||
};
|
||||
|
||||
int CBLexerWord::GetType()
|
||||
{
|
||||
return m_eType;
|
||||
}
|
||||
|
||||
uint32_t CBLexerWord::GetNumChildren()
|
||||
{
|
||||
return m_children.GetSize();
|
||||
}
|
||||
|
||||
ILexerWord **CBLexerWord::GetChildren()
|
||||
{
|
||||
return m_children.GetData();
|
||||
}
|
||||
|
||||
|
||||
|
||||
class CBLexer: public ILexer
|
||||
{
|
||||
public:
|
||||
virtual ILexerWord *ParseTokens( CUtlVector<Token_t> tokens ) override;
|
||||
|
||||
CBLexerWord *ParseFunctionBody( Token_t *&pToken, const Token_t *pEnding );
|
||||
|
||||
bool GetExpectedToken();
|
||||
CUtlString GetStringLiteral();
|
||||
};
|
||||
|
||||
#define NEXT_TOKEN() \
|
||||
pToken++; \
|
||||
if (pToken == pEnding) \
|
||||
goto eof \
|
||||
|
||||
ILexerWord *CBLexer::ParseTokens( CUtlVector<Token_t> tokens )
|
||||
{
|
||||
Token_t *pCurrentToken = tokens.GetData();
|
||||
Token_t *pEndingToken = tokens.GetData() + tokens.GetSize();
|
||||
CBLexerWord *pGlobalWord = new CBLexerWord;
|
||||
|
||||
|
||||
return pGlobalWord;
|
||||
};
|
||||
Reference in New Issue
Block a user