some improvements i think
This commit is contained in:
27
asmrigs/brb/brb.h
Normal file
27
asmrigs/brb/brb.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef BRB_H
|
||||
#define BRB_H
|
||||
|
||||
#include "tier2/tokenizer.h"
|
||||
#include "tier3/lexer.h"
|
||||
|
||||
#define B_LEXEL_INTERFACE_NAME "BLexer001"
|
||||
|
||||
|
||||
enum EBWordType
|
||||
{
|
||||
BWORDTYPE_CONST_WORD,
|
||||
|
||||
BWORDTYPE_FUNCTION,
|
||||
BWORDTYPE_FUNCTION_ARGS,
|
||||
BWORDTYPE_FUNCTION_ARG,
|
||||
BWORDTYPE_FUNCTION_SCOPE,
|
||||
|
||||
BWORDTYPE_RETURN,
|
||||
};
|
||||
|
||||
abstract_class IBLexerWord: public ILexerWord
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
#endif
|
||||
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;
|
||||
};
|
||||
19
asmrigs/brb/main.cpp
Normal file
19
asmrigs/brb/main.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "brb.h"
|
||||
#include "tier0/commandline.h"
|
||||
#include "tier2/ifilesystem.h"
|
||||
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
CommandLine()->CreateCommandLine(argc, argv);
|
||||
|
||||
CreateInterfaceFn filesystemFactory = Sys_GetFactory("filesystem_std");
|
||||
filesystem = (IFileSystem*)filesystemFactory(FILESYSTEM_INTERFACE_VERSION, NULL);
|
||||
|
||||
IFileHandle *pFile = filesystem->Open(argv[1], FILEMODE_READ);
|
||||
const char *szFileContents = filesystem->ReadString(pFile);
|
||||
filesystem->Close(pFile);
|
||||
|
||||
|
||||
V_free((void*)szFileContents);
|
||||
}
|
||||
Reference in New Issue
Block a user