Compare commits
No commits in common. "c6bed88d378232692f6c23ab9af3fb86447eb778" and "0296e6ee1d28b6c2e7949965ef77cd4742c34b5c" have entirely different histories.
c6bed88d37
...
0296e6ee1d
@ -1,5 +1,5 @@
|
|||||||
Language: Cpp
|
Language: Cpp
|
||||||
AccessModifierOffset: -8
|
AccessModifierOffset: -4
|
||||||
AlignAfterOpenBracket: Align
|
AlignAfterOpenBracket: Align
|
||||||
AlignArrayOfStructures: Left
|
AlignArrayOfStructures: Left
|
||||||
AlignConsecutiveMacros: None
|
AlignConsecutiveMacros: None
|
||||||
@ -56,8 +56,8 @@ BreakStringLiterals: true
|
|||||||
ColumnLimit: 99
|
ColumnLimit: 99
|
||||||
QualifierAlignment: Left
|
QualifierAlignment: Left
|
||||||
CompactNamespaces: false
|
CompactNamespaces: false
|
||||||
ConstructorInitializerIndentWidth: 8
|
ConstructorInitializerIndentWidth: 4
|
||||||
ContinuationIndentWidth: 8
|
ContinuationIndentWidth: 4
|
||||||
Cpp11BracedListStyle: true
|
Cpp11BracedListStyle: true
|
||||||
DeriveLineEnding: true
|
DeriveLineEnding: true
|
||||||
DerivePointerAlignment: false
|
DerivePointerAlignment: false
|
||||||
@ -79,7 +79,7 @@ IndentGotoLabels: false
|
|||||||
IndentPPDirectives: None
|
IndentPPDirectives: None
|
||||||
IndentExternBlock: AfterExternBlock
|
IndentExternBlock: AfterExternBlock
|
||||||
IndentRequires: false
|
IndentRequires: false
|
||||||
IndentWidth: 8
|
IndentWidth: 4
|
||||||
IndentWrappedFunctionNames: false
|
IndentWrappedFunctionNames: false
|
||||||
InsertTrailingCommas: Wrapped
|
InsertTrailingCommas: Wrapped
|
||||||
InsertBraces: true
|
InsertBraces: true
|
||||||
@ -141,7 +141,7 @@ SpacesInSquareBrackets: false
|
|||||||
SpaceBeforeSquareBrackets: false
|
SpaceBeforeSquareBrackets: false
|
||||||
BitFieldColonSpacing: Both
|
BitFieldColonSpacing: Both
|
||||||
Standard: Cpp11
|
Standard: Cpp11
|
||||||
TabWidth: 8
|
TabWidth: 4
|
||||||
UseCRLF: false
|
UseCRLF: false
|
||||||
UseTab: Always
|
UseTab: Always
|
||||||
|
|
||||||
|
|||||||
44
src/main.cpp
44
src/main.cpp
@ -1,16 +1,16 @@
|
|||||||
#include <argparse/argparse.hpp>
|
|
||||||
#include <bits/stdc++.h>
|
#include <bits/stdc++.h>
|
||||||
|
#include <argparse/argparse.hpp>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
enum class TokenType {
|
enum class TokenType {
|
||||||
COMMA, // ,
|
COMMA, // ,
|
||||||
SEMI, // ;
|
SEMI, // ;
|
||||||
LB, // {
|
LB,
|
||||||
RB, // }
|
RB,
|
||||||
LP, // (
|
LP,
|
||||||
RP, // )
|
RP,
|
||||||
LT, // <
|
LT,
|
||||||
RT, // >
|
RT, // { } ( ) < >
|
||||||
ASSIGN, // =
|
ASSIGN, // =
|
||||||
DOT, // .
|
DOT, // .
|
||||||
COLON, // :
|
COLON, // :
|
||||||
@ -21,8 +21,7 @@ enum class TokenType {
|
|||||||
RETURN, // return
|
RETURN, // return
|
||||||
TYPEOF, // typeof
|
TYPEOF, // typeof
|
||||||
PUBLIC, // public
|
PUBLIC, // public
|
||||||
ID, // identifier
|
ID
|
||||||
EXCEED
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Token {
|
struct Token {
|
||||||
@ -56,8 +55,7 @@ void printTokens() {
|
|||||||
"public",
|
"public",
|
||||||
"ID"};
|
"ID"};
|
||||||
for (auto u : tokens) {
|
for (auto u : tokens) {
|
||||||
cout << mp[static_cast<int>(u.type)] << " " << u.line << " " << cvt.to_bytes(u.s)
|
cout << mp[static_cast<int>(u.type)] << " " << u.line << " " << cvt.to_bytes(u.s) << endl;
|
||||||
<< endl;
|
|
||||||
}
|
}
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
@ -193,8 +191,7 @@ bool sameType(shared_ptr<ValType> a, shared_ptr<ValType> b) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (a->type() == 0) {
|
if (a->type() == 0) {
|
||||||
auto aa = static_pointer_cast<TemplateType>(a),
|
auto aa = static_pointer_cast<TemplateType>(a), bb = static_pointer_cast<TemplateType>(b);
|
||||||
bb = static_pointer_cast<TemplateType>(b);
|
|
||||||
return aa == bb || eq.find({aa, bb}) != eq.end();
|
return aa == bb || eq.find({aa, bb}) != eq.end();
|
||||||
}
|
}
|
||||||
if (a->type() == 1) {
|
if (a->type() == 1) {
|
||||||
@ -204,8 +201,7 @@ bool sameType(shared_ptr<ValType> a, shared_ptr<ValType> b) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
assert(aa->mp.size() == bb->mp.size());
|
assert(aa->mp.size() == bb->mp.size());
|
||||||
for (auto ia = aa->mp.begin(), ib = bb->mp.begin(); ia != aa->mp.end();
|
for (auto ia = aa->mp.begin(), ib = bb->mp.begin(); ia != aa->mp.end(); ia++, ib++) {
|
||||||
ia++, ib++) {
|
|
||||||
assert(ia->first == ib->first);
|
assert(ia->first == ib->first);
|
||||||
if (!sameType(ia->second, ib->second)) {
|
if (!sameType(ia->second, ib->second)) {
|
||||||
return false;
|
return false;
|
||||||
@ -327,8 +323,7 @@ shared_ptr<ValType> struct_replace(shared_ptr<ValType> vt, shared_ptr<StructType
|
|||||||
for (auto u = vtt->str; u.get() != nullptr; u = u->fa.lock()) {
|
for (auto u = vtt->str; u.get() != nullptr; u = u->fa.lock()) {
|
||||||
vis.insert(u);
|
vis.insert(u);
|
||||||
}
|
}
|
||||||
for (auto u = ut->str; u.get() != nullptr && vis.find(u) == vis.end();
|
for (auto u = ut->str; u.get() != nullptr && vis.find(u) == vis.end(); u = u->fa.lock()) {
|
||||||
u = u->fa.lock()) {
|
|
||||||
for (auto tem : u->c1) {
|
for (auto tem : u->c1) {
|
||||||
tt->mp.erase(tem);
|
tt->mp.erase(tem);
|
||||||
}
|
}
|
||||||
@ -512,8 +507,7 @@ shared_ptr<ValType> createVal() {
|
|||||||
bool legal = vals.size() == tt->str->c2.size();
|
bool legal = vals.size() == tt->str->c2.size();
|
||||||
if (legal) {
|
if (legal) {
|
||||||
for (size_t i = 0; i < vals.size(); i++) {
|
for (size_t i = 0; i < vals.size(); i++) {
|
||||||
if (!sameType(vals[i],
|
if (!sameType(vals[i], struct_replace(tt->str->c2[i], tt))) {
|
||||||
struct_replace(tt->str->c2[i], tt))) {
|
|
||||||
legal = 0;
|
legal = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -823,17 +817,15 @@ void work() {
|
|||||||
createVar();
|
createVar();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
argparse::ArgumentParser program("acpa",
|
argparse::ArgumentParser program("acpa", APP_VERSION
|
||||||
APP_VERSION,
|
, argparse::default_arguments::help, false);
|
||||||
argparse::default_arguments::help,
|
|
||||||
false);
|
|
||||||
program.add_argument("input_file")
|
program.add_argument("input_file")
|
||||||
.help("Source proof file")
|
.help("Source proof file")
|
||||||
.action([](const std::string& value) { return value; });
|
.action([](const std::string &value) { return value; });
|
||||||
try {
|
try {
|
||||||
program.parse_args(argc, argv);
|
program.parse_args(argc, argv);
|
||||||
} catch (const std::runtime_error& err) {
|
} catch (const std::runtime_error &err) {
|
||||||
cerr << err.what() << std::endl;
|
cerr << err.what() << std::endl;
|
||||||
cerr << program;
|
cerr << program;
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@ -1,16 +0,0 @@
|
|||||||
struct {
|
|
||||||
|
|
||||||
struct And<P, Q>(p: P, q: Q) {
|
|
||||||
left = Fn<>() -> P {
|
|
||||||
return p;
|
|
||||||
};
|
|
||||||
right = Fn<>() -> Q {
|
|
||||||
return q;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
AndLeft = Fn<P, Q>(h: And<P, Q>) -> P {
|
|
||||||
return h.p;
|
|
||||||
};
|
|
||||||
|
|
||||||
} main;
|
|
||||||
Loading…
x
Reference in New Issue
Block a user