Compare commits

..

No commits in common. "c6bed88d378232692f6c23ab9af3fb86447eb778" and "0296e6ee1d28b6c2e7949965ef77cd4742c34b5c" have entirely different histories.

3 changed files with 846 additions and 870 deletions

View File

@ -1,5 +1,5 @@
Language: Cpp
AccessModifierOffset: -8
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignArrayOfStructures: Left
AlignConsecutiveMacros: None
@ -56,8 +56,8 @@ BreakStringLiterals: true
ColumnLimit: 99
QualifierAlignment: Left
CompactNamespaces: false
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
@ -79,7 +79,7 @@ IndentGotoLabels: false
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWidth: 8
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: Wrapped
InsertBraces: true
@ -141,7 +141,7 @@ SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: Cpp11
TabWidth: 8
TabWidth: 4
UseCRLF: false
UseTab: Always

View File

@ -1,28 +1,27 @@
#include <argparse/argparse.hpp>
#include <bits/stdc++.h>
#include <argparse/argparse.hpp>
using namespace std;
enum class TokenType {
COMMA, // ,
SEMI, // ;
LB, // {
RB, // }
LP, // (
RP, // )
LT, // <
RT, // >
COMMA, // ,
SEMI, // ;
LB,
RB,
LP,
RP,
LT,
RT, // { } ( ) < >
ASSIGN, // =
DOT, // .
COLON, // :
SCOPE, // ::
IMPLY, // ->
STRUCT, // struct
FN, // Fn
FN, // Fn
RETURN, // return
TYPEOF, // typeof
PUBLIC, // public
ID, // identifier
EXCEED
ID
};
struct Token {
@ -37,27 +36,26 @@ vector<Token> tokens;
void printTokens() {
wstring_convert<codecvt_utf8<wchar_t>> cvt;
string mp[] = {",",
";",
"{",
"}",
"(",
")",
"<",
">",
"=",
".",
":",
"::",
"->",
"struct",
"Fn",
"return",
"typeof",
"public",
"ID"};
";",
"{",
"}",
"(",
")",
"<",
">",
"=",
".",
":",
"::",
"->",
"struct",
"Fn",
"return",
"typeof",
"public",
"ID"};
for (auto u : tokens) {
cout << mp[static_cast<int>(u.type)] << " " << u.line << " " << cvt.to_bytes(u.s)
<< endl;
cout << mp[static_cast<int>(u.type)] << " " << u.line << " " << cvt.to_bytes(u.s) << endl;
}
cout << endl;
}
@ -116,12 +114,12 @@ void read() {
printf("error on line %d", line), exit(1);
}
} else if ((s[pt] >= 0 && s[pt] < 128) ? (iswalpha(s[pt]) || s[pt] == L'_')
: iswprint(s[pt])) {
: iswprint(s[pt])) {
size_t r = pt + 1;
while (r < s.size()
&& ((s[r] >= 0 && s[r] < 128)
? (iswalpha(s[r]) || s[r] == L'_' || iswdigit(s[r]))
: iswprint(s[r]))) {
&& ((s[r] >= 0 && s[r] < 128)
? (iswalpha(s[r]) || s[r] == L'_' || iswdigit(s[r]))
: iswprint(s[r]))) {
r++;
}
t = s.substr(pt, r - pt);
@ -193,8 +191,7 @@ bool sameType(shared_ptr<ValType> a, shared_ptr<ValType> b) {
return false;
}
if (a->type() == 0) {
auto aa = static_pointer_cast<TemplateType>(a),
bb = static_pointer_cast<TemplateType>(b);
auto aa = static_pointer_cast<TemplateType>(a), bb = static_pointer_cast<TemplateType>(b);
return aa == bb || eq.find({aa, bb}) != eq.end();
}
if (a->type() == 1) {
@ -204,8 +201,7 @@ bool sameType(shared_ptr<ValType> a, shared_ptr<ValType> b) {
return false;
}
assert(aa->mp.size() == bb->mp.size());
for (auto ia = aa->mp.begin(), ib = bb->mp.begin(); ia != aa->mp.end();
ia++, ib++) {
for (auto ia = aa->mp.begin(), ib = bb->mp.begin(); ia != aa->mp.end(); ia++, ib++) {
assert(ia->first == ib->first);
if (!sameType(ia->second, ib->second)) {
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()) {
vis.insert(u);
}
for (auto u = ut->str; u.get() != nullptr && vis.find(u) == vis.end();
u = u->fa.lock()) {
for (auto u = ut->str; u.get() != nullptr && vis.find(u) == vis.end(); u = u->fa.lock()) {
for (auto tem : u->c1) {
tt->mp.erase(tem);
}
@ -512,8 +507,7 @@ shared_ptr<ValType> createVal() {
bool legal = vals.size() == tt->str->c2.size();
if (legal) {
for (size_t i = 0; i < vals.size(); i++) {
if (!sameType(vals[i],
struct_replace(tt->str->c2[i], tt))) {
if (!sameType(vals[i], struct_replace(tt->str->c2[i], tt))) {
legal = 0;
break;
}
@ -823,17 +817,15 @@ void work() {
createVar();
}
int main(int argc, char* argv[]) {
argparse::ArgumentParser program("acpa",
APP_VERSION,
argparse::default_arguments::help,
false);
int main(int argc, char *argv[]) {
argparse::ArgumentParser program("acpa", APP_VERSION
, argparse::default_arguments::help, false);
program.add_argument("input_file")
.help("Source proof file")
.action([](const std::string& value) { return value; });
.action([](const std::string &value) { return value; });
try {
program.parse_args(argc, argv);
} catch (const std::runtime_error& err) {
} catch (const std::runtime_error &err) {
cerr << err.what() << std::endl;
cerr << program;
return 1;

View File

@ -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;