mirror of https://github.com/x64dbg/btparser
changed AST
This commit is contained in:
parent
8227ec126c
commit
4b4cda91cb
|
@ -55,21 +55,30 @@ namespace AST
|
|||
{
|
||||
};
|
||||
|
||||
class Builtin : public Decl //built-in declaration (int x)
|
||||
class BuiltinVar : public Decl //built-in variable declaration (int x)
|
||||
{
|
||||
Type mType;
|
||||
string mId;
|
||||
string mName;
|
||||
public:
|
||||
explicit Builtin(Type type, const string & id)
|
||||
: mType(type), mId(id) {}
|
||||
explicit BuiltinVar(Type type, const string & id)
|
||||
: mType(type), mName(id) {}
|
||||
};
|
||||
|
||||
class Struct : public Decl //struct (can contain code, not just declarations)
|
||||
class Struct : public Decl //struct declaration (can contain code, not just declarations)
|
||||
{
|
||||
string mId;
|
||||
string mName;
|
||||
uptr<Block> mBlock;
|
||||
public:
|
||||
explicit Struct(const string & id, uptr<Block> block)
|
||||
: mId(id), mBlock(move(block)) {}
|
||||
: mName(id), mBlock(move(block)) {}
|
||||
};
|
||||
|
||||
class StructVar : public Decl //struct variable declaration: (struct {...} x;)
|
||||
{
|
||||
string mVarName; //name of the variable
|
||||
string mStructName; //name of the struct
|
||||
public:
|
||||
explicit StructVar(const string & varName, const string & structName)
|
||||
: mVarName(varName), mStructName(structName) {}
|
||||
};
|
||||
};
|
|
@ -128,7 +128,7 @@ uptr<Return> Parser::ParseReturn()
|
|||
|
||||
uptr<Decl> Parser::ParseDecl()
|
||||
{
|
||||
auto builtin = ParseBuiltin();
|
||||
auto builtin = ParseBuiltinVar();
|
||||
if (builtin)
|
||||
return move(builtin);
|
||||
auto stru = ParseStruct();
|
||||
|
@ -137,7 +137,7 @@ uptr<Decl> Parser::ParseDecl()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
uptr<Builtin> Parser::ParseBuiltin()
|
||||
uptr<BuiltinVar> Parser::ParseBuiltinVar()
|
||||
{
|
||||
if (CurToken.Token == Lexer::tok_uint) //TODO: properly handle types
|
||||
{
|
||||
|
@ -145,18 +145,18 @@ uptr<Builtin> Parser::ParseBuiltin()
|
|||
NextToken();
|
||||
if (CurToken.Token != Lexer::tok_identifier)
|
||||
{
|
||||
ReportError("failed to parse Builtin (no identifier)");
|
||||
ReportError("failed to parse BuiltinVar (no identifier)");
|
||||
return nullptr;
|
||||
}
|
||||
auto id = CurToken.IdentifierStr;
|
||||
NextToken();
|
||||
if (CurToken.Token != Lexer::tok_semic)
|
||||
{
|
||||
ReportError("failed to parse Builtin (no semicolon)");
|
||||
ReportError("failed to parse BuiltinVar (no semicolon)");
|
||||
return nullptr;
|
||||
}
|
||||
NextToken();
|
||||
return make_uptr<Builtin>(type, id);
|
||||
return make_uptr<BuiltinVar>(type, id);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -182,3 +182,8 @@ uptr<Struct> Parser::ParseStruct()
|
|||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AST::uptr<AST::StructVar> Parser::ParseStructVar()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ private:
|
|||
AST::uptr<AST::Return> ParseReturn();
|
||||
|
||||
AST::uptr<AST::Decl> ParseDecl();
|
||||
AST::uptr<AST::Builtin> ParseBuiltin();
|
||||
AST::uptr<AST::BuiltinVar> ParseBuiltinVar();
|
||||
AST::uptr<AST::Struct> ParseStruct();
|
||||
AST::uptr<AST::StructVar> ParseStructVar();
|
||||
};
|
Loading…
Reference in New Issue