update according to compiler's complain

Signed-off-by: szdytom <szdytom@qq.com>
This commit is contained in:
方而静 2023-08-29 20:29:32 +08:00
parent a9666c9857
commit b05b91a7ff
Signed by: szTom
GPG Key ID: 072D999D60C6473C
10 changed files with 69 additions and 57 deletions

View File

@ -2,15 +2,15 @@
#define ACPA_ELEMENT_H
#include <map>
#include <vector>
#include <string>
#include <memory>
#include <string>
#include <vector>
using std::map;
using std::vector;
using std::string;
using std::weak_ptr;
using std::shared_ptr;
using std::string;
using std::vector;
using std::weak_ptr;
struct Struct;
struct ValType;
@ -27,27 +27,22 @@ struct Struct {
};
struct ValType {
virtual const int type() = 0;
virtual int type() const = 0;
virtual ~ValType() = default;
};
struct TemplateType : ValType {
const int type() override {
return 0;
}
int type() const override;
};
struct StructType : ValType {
const int type() override {
return 1;
}
int type() const override;
shared_ptr<Struct> str;
map<shared_ptr<TemplateType>, shared_ptr<ValType>> mp;
};
struct FunctionType : ValType {
const int type() override {
return 2;
}
int type() const override;
vector<shared_ptr<TemplateType>> c1;
vector<shared_ptr<ValType>> c2;
shared_ptr<ValType> c3;

View File

@ -1,8 +1,8 @@
#ifndef ACPA_TOKEN_H
#define ACPA_TOKEN_H
#include <vector>
#include <string>
#include <vector>
enum class TokenType {
COMMA, // ,
@ -27,25 +27,7 @@ enum class TokenType {
EXCEED
};
std::string token_mp[] = {",",
";",
"{",
"}",
"(",
")",
"<",
">",
"=",
".",
":",
"::",
"->",
"struct",
"Fn",
"return",
"typeof",
"public",
"ID"};
extern std::string token_mp[];
struct Token {
int line;

View File

@ -1,8 +1,8 @@
#ifndef ACPA_WORK_H
#define ACPA_WORK_H
#include "token.h"
#include "element.h"
#include "token.h"
#include <vector>
void work(std::vector<Token>);

View File

@ -1,9 +1,21 @@
#include "element.h"
#include <set>
#include <assert.h>
#include <set>
using namespace std;
int TemplateType::type() const {
return 0;
}
int StructType::type() const {
return 1;
}
int FunctionType::type() const {
return 2;
}
bool sameType(shared_ptr<ValType> a, shared_ptr<ValType> b) {
static set<pair<shared_ptr<TemplateType>, shared_ptr<TemplateType>>> eq;
if (a->type() != b->type()) {

View File

@ -1,16 +1,15 @@
#include "element.h"
#include "read.h"
#include "scan.h"
#include "token.h"
#include "element.h"
#include "work.h"
#include <argparse/argparse.hpp>
using namespace std;
int main(int argc, char* argv[]) {
#define AS_STR(x) #x
argparse::ArgumentParser program("acpa",
AS_STR(APP_VERSION),
"0.1a0",
argparse::default_arguments::help,
false);
@ -33,4 +32,3 @@ int main(int argc, char* argv[]) {
return 0;
}

View File

@ -2,9 +2,10 @@
using namespace std;
string read()
{
string read() {
string s;
for(char ch=getchar();ch!=EOF;ch=getchar()) s+=ch;
for (char ch = getchar(); ch != EOF; ch = getchar()) {
s += ch;
}
return s;
}

View File

@ -0,0 +1,22 @@
#include <string>
std::string token_mp[] = {",",
";",
"{",
"}",
"(",
")",
"<",
">",
"=",
".",
":",
"::",
"->",
"struct",
"Fn",
"return",
"typeof",
"public",
"ID"};

View File

@ -1,6 +1,6 @@
#include "work.h"
#include <set>
#include <assert.h>
#include <set>
using namespace std;
@ -10,32 +10,34 @@ vector<Token> tokens;
// void printTokens() {
// wstring_convert<codecvt_utf8<wchar_t>> cvt;
// for (auto u : tokens) {
// cout << token_mp[static_cast<int>(u.type)] << " " << u.line << " " << cvt.to_bytes(u.s)
// cout << token_mp[static_cast<int>(u.type)] << " " << u.line << " " <<
// cvt.to_bytes(u.s)
// << endl;
// }
// cout << endl;
// }
struct Def {
virtual const int type() = 0;
virtual int type() const = 0;
virtual ~Def() = default;
};
struct DefTemplate : Def {
const int type() override {
int type() const override {
return 0;
}
shared_ptr<TemplateType> def_template;
};
struct DefStruct : Def {
const int type() override {
int type() const override {
return 1;
}
shared_ptr<Struct> def_struct;
};
struct DefVar : Def {
const int type() override {
int type() const override {
return 2;
}
shared_ptr<ValType> def_var;

View File

@ -12,7 +12,7 @@ target("build")
set_default(true)
set_warnings("allextra")
add_files("src/**.cpp")
-- add_includedirs("include/")
add_includedirs("include/")
add_includedirs("third-party/")
add_defines("APP_VERSION=" .. app_version)
if is_mode("release") then