revert before stack
This commit is contained in:
InventorX 2026-04-13 22:59:49 -04:00
parent 51968d1f87
commit 41930a28e0
8 changed files with 490 additions and 360 deletions

View file

@ -1,10 +1,10 @@
CC = gcc CC = gcc
CXX = g++ CXX = g++
CPPFLAGS = -std=c++20 -g -Wall -Wextra -Wpedantic #-O3 -ffast-math CPPFLAGS = -g #-O3 -ffast-math
CFLAGS = -g -Wall -Wextra -Wpedantic #-O3 -ffast-math CFLAGS = -g #-O3 -ffast-math
LDFLAGS = -g -Wall -Wextra -Wpedantic #-O3 -ffast-math LDFLAGS = -g #-O3 -ffast-math
LDLIBS = LDLIBS = -lfltk -lcurl -lfltk_images
SRC_DIR = src SRC_DIR = src
@ -33,7 +33,7 @@ $(EXE): $(OBJ) | $(BIN_DIR)
$(CXX) $(LDFLAGS) $^ $(LDLIBS) -o $@ $(CXX) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR) $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR) $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)

44
src/curlwrap.cpp Normal file
View file

@ -0,0 +1,44 @@
#include <iostream>
#include "curlwrap.hpp"
#include <curl/curl.h>
#include <curl/easy.h>
#include <string>
size_t writeback(char * ptr, size_t size, size_t nmemb, void * data) {
std::string* us = (std::string*) data;
us->append(ptr, nmemb);
return nmemb;
}
Curl::Curl() {
handle = curl_easy_init();
}
Curl::~Curl() {
if (handle) {
curl_easy_cleanup(handle);
}
}
void Curl::seturl(std::string url) {
data = "";
curl_easy_setopt(handle, CURLOPT_URL, url.c_str());
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, writeback);
curl_easy_setopt(handle, CURLOPT_WRITEDATA, &data);
}
std::string Curl::get() {
curl_easy_perform(handle);
return data;
}

21
src/curlwrap.hpp Normal file
View file

@ -0,0 +1,21 @@
#ifndef CURLWRAP_HEADER
#define CURLWRAP_HEADER
#include <curl/curl.h>
#include <string>
struct Curl {
CURL * handle;
std::string data;
Curl();
~Curl();
void seturl(std::string url);
std::string get();
};
#endif

67
src/images.cpp Normal file
View file

@ -0,0 +1,67 @@
unsigned char icon_inspect_file_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30,
0x08, 0x03, 0x00, 0x00, 0x00, 0x60, 0xdc, 0x09, 0xb5, 0x00, 0x00, 0x00,
0x04, 0x67, 0x41, 0x4d, 0x41, 0x00, 0x00, 0xb1, 0x8f, 0x0b, 0xfc, 0x61,
0x05, 0x00, 0x00, 0x00, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x00, 0x00, 0x7a,
0x26, 0x00, 0x00, 0x80, 0x84, 0x00, 0x00, 0xfa, 0x00, 0x00, 0x00, 0x80,
0xe8, 0x00, 0x00, 0x75, 0x30, 0x00, 0x00, 0xea, 0x60, 0x00, 0x00, 0x3a,
0x98, 0x00, 0x00, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x00, 0x00, 0x00,
0x75, 0x50, 0x4c, 0x54, 0x45, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x86,
0x86, 0x86, 0xff, 0xfb, 0xf0, 0x99, 0x99, 0x99, 0x55, 0x55, 0x55, 0xea,
0xea, 0xea, 0xcc, 0xcc, 0xcc, 0xd7, 0xd7, 0xd7, 0xe7, 0xe7, 0xd6, 0x99,
0xcc, 0xff, 0x99, 0x99, 0xcc, 0x5f, 0x5f, 0x5f, 0x99, 0xff, 0xff, 0xc0,
0xc0, 0xc0, 0xcc, 0xff, 0xff, 0xcc, 0xff, 0xcc, 0x66, 0xff, 0xff, 0x33,
0xff, 0xff, 0x4d, 0x4d, 0x4d, 0x33, 0x33, 0x33, 0xcc, 0xec, 0xff, 0x00,
0xff, 0xff, 0x11, 0x11, 0x11, 0x66, 0x66, 0x66, 0x1c, 0x1c, 0x1c, 0x22,
0x22, 0x22, 0xb2, 0xb2, 0xb2, 0x00, 0x66, 0xff, 0x00, 0x33, 0x99, 0x00,
0xcc, 0xff, 0x00, 0x99, 0xff, 0x00, 0x66, 0x99, 0x00, 0x33, 0xcc, 0x00,
0x00, 0x80, 0x00, 0x00, 0x66, 0x00, 0x00, 0xff, 0x00, 0x33, 0x66, 0xff,
0xff, 0xff, 0x1d, 0x20, 0xae, 0x06, 0x00, 0x00, 0x00, 0x01, 0x74, 0x52,
0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00, 0x00, 0x01, 0x62,
0x4b, 0x47, 0x44, 0x26, 0x5a, 0x08, 0x98, 0xb5, 0x00, 0x00, 0x00, 0x07,
0x74, 0x49, 0x4d, 0x45, 0x07, 0xe2, 0x06, 0x1a, 0x00, 0x32, 0x12, 0x39,
0x75, 0x77, 0x4b, 0x00, 0x00, 0x01, 0x74, 0x49, 0x44, 0x41, 0x54, 0x48,
0xc7, 0xed, 0xd4, 0xcb, 0x56, 0x83, 0x30, 0x14, 0x05, 0xd0, 0x86, 0xbc,
0x9a, 0x94, 0x90, 0x04, 0x0a, 0x56, 0x05, 0x5b, 0xad, 0xfe, 0xff, 0x2f,
0x7a, 0x6f, 0x12, 0xa4, 0xba, 0xc2, 0xa3, 0x13, 0x97, 0x03, 0xcf, 0xa4,
0x0c, 0xd8, 0xdc, 0x93, 0x90, 0xb2, 0xdb, 0xfd, 0xe7, 0x4f, 0x86, 0x14,
0x3f, 0xb2, 0x0a, 0xe8, 0xf7, 0x30, 0x7e, 0x2f, 0x58, 0x13, 0x44, 0x40,
0x6e, 0x81, 0x5c, 0x12, 0x24, 0x66, 0x2f, 0xd4, 0x04, 0xd4, 0xbc, 0x20,
0x44, 0x63, 0x0e, 0x84, 0x97, 0xfb, 0xaf, 0x29, 0x8c, 0xce, 0x0a, 0xa2,
0x4d, 0xa5, 0xac, 0x71, 0xd6, 0xeb, 0xb2, 0x94, 0xe3, 0x10, 0x46, 0xe7,
0x04, 0xd1, 0xd6, 0x02, 0xb0, 0x35, 0x44, 0x97, 0x5c, 0x4a, 0xa5, 0xd0,
0xf0, 0xe6, 0x88, 0xc9, 0x01, 0xab, 0x00, 0x38, 0xcb, 0x30, 0x30, 0x83,
0xc3, 0x0f, 0x00, 0x21, 0x2b, 0xc6, 0x08, 0xcf, 0x0f, 0xa0, 0x38, 0xc1,
0x8a, 0xd6, 0xfb, 0x4e, 0x97, 0x4c, 0xc6, 0x75, 0x04, 0x91, 0x03, 0x86,
0x0a, 0x04, 0xae, 0x0e, 0xd1, 0x1c, 0x40, 0x5c, 0x05, 0x8a, 0x3c, 0xa0,
0x61, 0x42, 0xa8, 0xc4, 0x24, 0x4c, 0x50, 0x31, 0x28, 0xf2, 0x00, 0x2b,
0x39, 0x6b, 0x5b, 0x67, 0x3c, 0x6c, 0x14, 0x67, 0x29, 0x38, 0x23, 0x0b,
0x84, 0x15, 0xe3, 0x2e, 0xe1, 0x3e, 0xe1, 0x1a, 0x44, 0x7a, 0xed, 0x59,
0xe0, 0x8d, 0x68, 0x71, 0x0d, 0xa9, 0x52, 0x33, 0x55, 0x9a, 0x01, 0xda,
0xb7, 0x0e, 0x27, 0x38, 0x67, 0x3a, 0xd8, 0xa5, 0xa6, 0x99, 0x2a, 0x65,
0x01, 0x8c, 0xf0, 0xf8, 0x1e, 0x4c, 0x68, 0xd4, 0x15, 0x4d, 0xb5, 0x52,
0x09, 0x46, 0xd4, 0xbe, 0x52, 0xc6, 0x87, 0xa7, 0x16, 0x0f, 0xc5, 0xd8,
0x68, 0xae, 0x12, 0x0a, 0x5d, 0xa9, 0xda, 0x77, 0x90, 0x02, 0x0e, 0x43,
0x33, 0xfe, 0xf7, 0x66, 0x01, 0x9c, 0xd6, 0x43, 0x38, 0xae, 0x92, 0x1c,
0x19, 0x3b, 0x1d, 0x61, 0xc6, 0x62, 0xa5, 0x48, 0xc8, 0x23, 0xe4, 0x89,
0xd1, 0xe7, 0x53, 0x3f, 0xa4, 0x56, 0x4b, 0x00, 0x8d, 0x84, 0x10, 0x75,
0x7a, 0x39, 0xf7, 0x43, 0xb3, 0x52, 0x29, 0x82, 0xf0, 0xd4, 0x4b, 0xdf,
0xa1, 0x08, 0xad, 0xd6, 0x00, 0x0d, 0xc5, 0x2f, 0x67, 0x14, 0xaf, 0x20,
0xe8, 0x2a, 0x88, 0x89, 0x62, 0x88, 0x62, 0x0b, 0x48, 0xe2, 0x2d, 0x88,
0x4d, 0x20, 0x89, 0x2b, 0x8a, 0x6d, 0x60, 0x12, 0xeb, 0xdb, 0x9a, 0x32,
0x44, 0xc1, 0x16, 0xbf, 0x7e, 0x84, 0xdf, 0x04, 0x45, 0x7f, 0xc5, 0xab,
0xdd, 0xc6, 0x0c, 0xe7, 0xfe, 0xfd, 0x63, 0xeb, 0xcd, 0x51, 0x0c, 0xc3,
0x5d, 0xf7, 0xff, 0xe7, 0x97, 0xf2, 0x09, 0x81, 0xc5, 0x1c, 0x78, 0xc0,
0x82, 0x16, 0xc0, 0x00, 0x00, 0x00, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64,
0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x00, 0x32,
0x30, 0x31, 0x38, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x36, 0x54, 0x30, 0x30,
0x3a, 0x35, 0x30, 0x3a, 0x31, 0x38, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30,
0x0e, 0x62, 0x1d, 0x0e, 0x00, 0x00, 0x00, 0x25, 0x74, 0x45, 0x58, 0x74,
0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x00,
0x32, 0x30, 0x31, 0x38, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x36, 0x54, 0x30,
0x30, 0x3a, 0x35, 0x30, 0x3a, 0x31, 0x38, 0x2d, 0x30, 0x34, 0x3a, 0x30,
0x30, 0x7f, 0x3f, 0xa5, 0xb2, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e,
0x44, 0xae, 0x42, 0x60, 0x82
};
unsigned int icon_inspect_file_png_len = 761;

11
src/images.h Normal file
View file

@ -0,0 +1,11 @@
#ifndef IMAGES_H
#define IMAGES_H
#include <cstddef>
extern unsigned char icon_inspect_file_png[];
extern size_t icon_inspect_file_png_len;
#endif

View file

@ -1,365 +1,289 @@
#include <cassert> #include <FL/Enumerations.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Widget.H>
#include <fstream>
#include <iostream> #include <iostream>
#include <istream>
#include "curlwrap.hpp"
#include "images.h"
#include "summarymanager.hpp"
#include "testcpp.hpp"
#include <FL/Fl.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Flex.H>
#include <FL/Fl_Multi_Browser.H>
#include <FL/Fl_PNG_Image.H>
#include <FL/Fl_Tile.H>
#include <FL/Fl_Window.H>
#include <FL/fl_ask.H>
#include <memory>
#include <string> #include <string>
#include <unordered_map>
#include <unordered_set>
#include <variant>
#include <vector> #include <vector>
struct Data { using namespace std;
virtual ~Data() {}
};
struct SelfEval : Data { struct Person {
virtual ~SelfEval() {} std::string year;
}; std::string name;
struct Applyable : Data { Person(std::string &y, std::string &n) : year(y), name(n) {}
virtual ~Applyable() {} std::string toString() const {
}; return "{(Person): " + year + ", " + name + "}";
struct Cell {
Data *d;
size_t cdr = 0;
};
struct Env {
std::unordered_set<std::string> builtin;
std::unordered_map<std::string, size_t> userdef;
};
struct Symbol : Data{
std::string data;
std::string Get() {
return data;
} }
}; };
struct String : SelfEval { std::ostream &operator<<(std::ostream &os, const Person &e) {
std::string data; // os << "{(Person): " << e.year << ", " << e.name << "}";
std::string Get() { os << e.toString();
return data; return os;
} }
};
struct BasicEntry {
struct Number : SelfEval { Person A;
int data; Person B;
int Get() {
return data; std::string matchlink;
}
}; int Apercent;
int Bpercent;
struct Fork : Data {
size_t data; std::string toString() const {
size_t Get() { return "{(BasicEntry): " + A.toString() + ", " + B.toString() + ", " + matchlink + +", " +
return data; std::to_string(Apercent) + "%, " + std::to_string(Bpercent) + "%}";
} }
}; };
std::ostream &operator<<(std::ostream &os, const BasicEntry &e) {
struct Lambda : Data { // os << "{(BasicEntry): " << e.A << ", " << e.B << ", " << e.matchlink << "}";
Env env; os << e.toString();
Cell args; return os;
Cell f; }
};
struct Selected {
struct Registers { Fl_Multi_Browser &browser;
std::variant<size_t, Data *, Cell> A; Selected(Fl_Multi_Browser &browser_in) : browser(browser_in) {}
std::variant<size_t, Data *, Cell> B; };
std::variant<size_t, Data *, Cell> C;
Env E; void show_callback(Fl_Widget *w, void *data) {
}; Selected *rdata = (Selected *)data;
struct Machine { auto s = rdata->browser.size() + 1;
size_t maxCells;
size_t freepos = 1; for (size_t i = 0; i < s; i++) {
std::vector<Cell> mem; if (rdata->browser.selected(i)) {
fl_alert("%s", rdata->browser.text(i));
std::vector<Registers> stack; }
}
Registers reg; }
Machine(size_t max) : mem(max) { std::vector<BasicEntry> MakeEntires(std::string filename) {
maxCells = max;
reg.E.builtin.insert("+"); std::vector<BasicEntry> out;
reg.E.builtin.insert("-");
reg.E.builtin.insert("lambda"); std::ifstream matches(filename);
reg.E.builtin.insert("set");
} if (!matches.is_open()) {
std::cout << "Err reading " << filename << std::endl;
size_t Apply(Data * d, size_t cdr) { exit(1);
if (Symbol * fname = dynamic_cast<Symbol*>(d)) { }
if (reg.E.builtin.contains(fname->data)) {
return ApplyBuiltin(fname->data, cdr); std::string line;
} else { //defined symbol.
return 0; //TODO std::string line1;
} std::string line2;
} else if (Lambda * f = dynamic_cast<Lambda*>(d)) { size_t linenum = 1; // One indexed like devtools
reg.A = f->args; while (std::getline(matches, line)) {
reg.A = ((Fork *) (std::get<Cell>(reg.A)).d)->data; if (linenum < 15) {
reg.B = cdr; } else {
auto tmp = reg.E; if ((linenum - 15) % 3 == 0) {
//reg.E = f->env; line1 = line;
reg.E.userdef.merge(f->env.userdef); if (line == "</td></tr></tbody></table>" || line == "</TABLE>")
while (std::get<size_t>(reg.A) != 0) { break;
reg.E.userdef[ ((Symbol *) mem[std::get<size_t>(reg.A)].d )->data] = std::get<size_t>(reg.B); } else if ((linenum - 15) % 3 == 1) {
reg.A = mem[std::get<size_t>(reg.A)].cdr; line2 = line;
reg.B = mem[std::get<size_t>(reg.B)].cdr;
} // std::cout << "Debug: L1: " << line1 << std::endl;
// std::cout << "Debug: L2: " << line2 << std::endl;
auto ret = Eval(f->f.d);
reg.E = tmp; auto firstquote = line1.find("\"");
return newCell(ret); // printf("fq: %ld\n", firstquote);
auto secondquote = line1.find("\"", firstquote + 1);
} else { // printf("sq: %ld\n", secondquote);
return 0; auto matchlink = line1.substr(firstquote + 1, secondquote - (firstquote + 1));
}
} auto firstslash = line1.find("/", secondquote + 1);
auto secondslash = line1.find("/", firstslash + 1);
auto thirdslash = line1.find("/", secondslash + 1);
size_t ApplyBuiltin(std::string fname, size_t cdr) {
if (fname == "+") { auto firstpar = line1.find("(", thirdslash + 1);
int base = 0; auto secondpar = line1.find(")", firstpar + 1);
while (cdr != 0) {
Number *a = dynamic_cast<Number *>(mem[cdr].d); auto p1class = line1.substr(firstslash + 1, secondslash - firstslash - 1);
base += a->data; auto p1name = line1.substr(secondslash + 1, thirdslash - secondslash - 1);
cdr = mem[cdr].cdr;
} auto p1match = line1.substr(firstpar + 1, secondpar - firstpar - 2);
Number *n = new Number;
n->data = base; std::cout << p1match << std::endl;
return newCell(n);
firstquote = line2.find("\"");
} else if (fname == "-") { secondquote = line2.find("\"", firstquote + 1);
Number *s = dynamic_cast<Number *>(mem[cdr].d); firstslash = line2.find("/", secondquote + 1);
int base = s->data; secondslash = line2.find("/", firstslash + 1);
thirdslash = line2.find("/", secondslash + 1);
cdr = mem[cdr].cdr; firstpar = line2.find("(", thirdslash + 1);
if (cdr == 0) { secondpar = line2.find(")", firstpar + 1);
Number *n = new Number;
n->data = -base; auto p2class = line2.substr(firstslash + 1, secondslash - (firstslash + 1));
return newCell(n); auto p2name = line2.substr(secondslash + 1, thirdslash - (secondslash + 1));
} else {
while (cdr != 0) { auto p2match = line2.substr(firstpar + 1, secondpar - firstpar - 2);
Number *a = dynamic_cast<Number *>(mem[cdr].d); std::cout << p2match << std::endl;
base -= a->data;
cdr = mem[cdr].cdr; auto p1 = Person(p1class, p1name);
}
Number *n = new Number; auto p2 = Person(p2class, p2name);
n->data = base;
return newCell(n); BasicEntry finent = {.A = p1,
} .B = p2,
} else if (fname == "lambda") { .matchlink = matchlink,
Fork * args = dynamic_cast<Fork*>(mem[cdr].d); .Apercent = std::stoi(p1match),
Fork * f = dynamic_cast<Fork*>(mem[mem[cdr].cdr].d); .Bpercent = std::stoi(p2match)};
Lambda * l = new Lambda; out.push_back(finent);
l->env = reg.E; }
l->args = mem[cdr]; //mem[args->data]; }
l->f = mem[mem[cdr].cdr]; //mem[f->data]; linenum++;
//std::cout <<"got lambd" << std::endl; }
return newCell(l); return out;
}
}
return 0; struct State {
} std::vector<BasicEntry> entries;
};
size_t newCell() {
if (freepos >= maxCells) { void changelayout(Fl_Widget *w, void *meow) {
exit(1); std::pair<Fl_Flex &, SummaryManager &> *in = (std::pair<Fl_Flex &, SummaryManager &> *)meow;
} in->second.show();
auto nc = freepos; // in->second.parent()->redraw();
freepos += 1; // in->first.window()->redraw();
return nc; // in->first.init_sizes();
} in->first.layout();
in->second.redraw();
size_t newCell(Data *d) { // in->first.redraw();
auto t = newCell(); }
mem[t].d = d;
return t; struct Topbar : Fl_Group {
}
Fl_PNG_Image inspectIcon;
Data *Eval(Data *d) {
// std::cout << "Eval top" << std::endl; Fl_Box *titleText;
if (SelfEval *h = dynamic_cast<SelfEval *>(d)) { Fl_Button *inspect;
return h;
} else if (Symbol *h = dynamic_cast<Symbol*>(d)) { Topbar(int x, int y, int w, int h)
if (reg.E.builtin.contains(h->data)) return h; : Fl_Group(x, y, w, h),
return mem[reg.E.userdef[h->data]].d; inspectIcon("Inspect", icon_inspect_file_png, icon_inspect_file_png_len) {
} else if (Fork *h = dynamic_cast<Fork *>(d)) {
// std::cout << "Eval callllled" << std::endl; titleText = new Fl_Box(0, 0, 100, 50, "MossMan");
// Symbol *car = dynamic_cast<Symbol *>(mem[h->data].d); titleText->labelsize(36);
//new car: titleText->labelfont(FL_TIMES | FL_BOLD);
auto car = mem[h->data].d; titleText->align(FL_ALIGN_INSIDE | FL_ALIGN_TOP_LEFT);
inspect = new Fl_Button(950, 0, 50, 50);
// if (!car) { resizable(titleText);
// throw(100);
// } inspect->image(inspectIcon);
size_t front = 0; inspect->tooltip("Inspect Entr(ies)");
size_t current = 0;
size_t firstargleft = mem[h->data].cdr; end();
}
// std::cout << "Farg " << firstargleft << std::endl; };
while (firstargleft != 0) { struct MainGui : Fl_Window {
if (auto c = dynamic_cast<Symbol*>(car)) { Topbar *topbar;
if(c->data == "lambda") {
front = mem[h->data].cdr; Fl_Tile *tilebox;
break; Fl_Multi_Browser *list;
} SummaryManager *summaryEditor;
} MainGui() : Fl_Window(0, 0, 1000, 750, "MossMan :3") {
topbar = new Topbar(0, 0, 1000, 50);
if (front == 0) {
front = newCell(); tilebox = new Fl_Tile(0, 50, 1000, 700); // parent is maingui, will be freed at decon
current = front; list = new Fl_Multi_Browser(0, 50, 150, 700);
} else { summaryEditor = new SummaryManager(150, 50, 850, 700);
auto temp = newCell();
mem[current].cdr = temp; tilebox->end();
current = temp;
} end();
// std::cout << "here" << std::endl; resizable(tilebox);
mem[current].d = Eval(mem[firstargleft].d); }
};
// std::cout << "there" << std::endl;
firstargleft = mem[firstargleft].cdr; int main(int argc, char **argv) {
} if (argc < 2) {
std::cout << "Not enough args" << std::endl;
return mem[Apply(Eval(car), front)].d; exit(1);
} else { }
throw("err");
} State s;
return NULL; s.entries = MakeEntires(argv[1]);
}
for (auto e : s.entries) {
void ListPrint(Cell c) { std::cout << e << std::endl;
while (true) { }
if (typeid(*(c.d)) == typeid(Number)) {
auto p = dynamic_cast<Number *>(c.d); Fl::scheme("base");
std::cout << p->Get() << " "; // auto window = std::make_unique<Fl_Window>(300, 300, 300, 300, "MossMan :D");
} else if (typeid(*(c.d)) == typeid(Symbol)) {
auto p = dynamic_cast<Symbol *>(c.d); // auto group = std::make_unique<Fl_Group>(0,0,300,300);
std::cout << p->Get() << " "; // auto group2 = std::make_unique<Fl_Group>(0, 0, 300, 50);
} else if (typeid(*(c.d)) == typeid(String)) { // auto box = std::make_unique<Fl_Box>(0,0,100,50,"MossMan");
auto p = dynamic_cast<String *>(c.d); // box->labelsize(36);
std::cout << "@\"" << p->Get() << "\"@ "; // box->labelfont(FL_TIMES | FL_BOLD);
} else if (typeid(*(c.d)) == typeid(Fork)) { // box->align(FL_ALIGN_INSIDE | FL_ALIGN_TOP_LEFT);
std::cout << "("; // auto button = std::make_unique<Fl_Button>(250, 0, 50, 50);
auto p = dynamic_cast<Fork *>(c.d); // auto button2 = std::make_unique<Fl_Button>(200,0, 50, 50);
ListPrint(mem[p->Get()]); // group2->resizable(*box);
std::cout << ")"; // group2->end();
}
if (c.cdr == 0) // auto group3 = std::make_unique<Fl_Flex>(0,51,300, 250, Fl_Flex::HORIZONTAL);
break; // // auto browser = std::make_unique<Fl_Multi_Browser>(0,51,300,250);
c = mem[c.cdr]; // // auto browser2 = std::make_unique<Fl_Multi_Browser>(0,51,300,250);
} // auto browser = std::make_unique<Fl_Multi_Browser>(0,0,0,0);
} // auto tabs = std::make_unique<SummaryManager>(0,0,300,300);
// //auto browser2 = std::make_unique<Fl_Multi_Browser>(0,0,0,0);
Cell read_atom(std::istream &in) { // tabs->hide();
bool isnum = true; // group3->end();
// std::pair<Fl_Flex&, SummaryManager&> saved(*group3, *tabs);
std::string pass = ""; // button2->callback(changelayout,&saved);
char ch;
// auto icon = std::make_unique<Fl_PNG_Image>("Inspect", icon_inspect_file_png,
if (in.peek() == '"') { // icon_inspect_file_png_len); button->image(*icon); button->tooltip("Inspect Entr(ies)");
in.get(ch);
while (true) { // for (auto e : s.entries) {
in.get(ch); // auto h = ((e.A.year + "/" + e.A.name) + " and " + (e.B.year + "/" + e.B.name) + " (" +
if (ch == '\\') { // std::to_string(e.Apercent) + "%, " + std::to_string(e.Bpercent) + "%)");
in.get(ch); // browser->add(h.c_str());
pass += ch; // }
} else if (ch == '"') {
break; // group->resizable(*group3);
} else { // group->end();
pass += ch;
} // window->resizable(*group);
} // window->end();
Cell c;
c.cdr = 0; // MainGui x;
auto n = new String;
n->data = pass; // Selected callbackdata(*browser);
c.d = n;
return c; // button->callback(show_callback, (void*) &callbackdata);
}
// window->show();
while (in.get(ch) && ch != '(' && ch != ' ' && ch != ')') {
if (ch != '0' && ch != '1' && ch != '2' && ch != '3' && ch != '4' && ch != '5' && MainGui x;
ch != '6' && ch != '7' && ch != '8' && ch != '9') { x.show();
isnum = false;
} return Fl::run();
pass += ch;
}
in.unget();
Cell c;
c.cdr = 0;
if (isnum) {
auto n = new Number;
n->data = std::stoi(pass);
c.d = n;
} else {
auto s = new Symbol;
s->data = pass;
c.d = s;
}
return c;
}
size_t read_expr(std::istream &in) {
size_t front = 0;
size_t current = 0;
char ch;
while (in.get(ch)) {
if (!std::isspace(ch)) {
if (ch == '(') {
auto temp = newCell();
mem[current].cdr = temp;
current = temp;
if (front == 0) {
front = current;
}
auto x = new Fork;
mem[current].d = x;
x->data = read_expr(in);
} else if (ch == ')') {
break;
} else {
auto temp = newCell();
mem[current].cdr = temp;
current = temp;
if (front == 0) {
front = current;
}
in.unget();
mem[current] = read_atom(in);
}
}
}
return front;
}
};
int main() {
auto m = Machine(1000);
auto exp = m.read_expr(std::cin);
m.ListPrint(m.mem[exp]);
std::cout << std::endl;
Cell c;
c.d = m.Eval(m.mem[exp].d);
m.ListPrint(c);
std::cout << std::endl;
return 0;
} }

45
src/summarymanager.cpp Normal file
View file

@ -0,0 +1,45 @@
#include "summarymanager.hpp"
#include <FL/Fl.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Tabs.H>
#include <FL/Fl_Window.H>
#include <iostream>
#include <memory>
SummaryManager::SummaryManager(int x, int y, int w, int h)
: Fl_Group(x, y, w, h), tabs(x, y, w, h) {
Fl_Group *grp1 = new Fl_Group(x, y + 30, w, h - 30, "Tab1");
{
Fl_Window *win1 = new Fl_Window(x, y + 30, w, h - 30, "Tab1W");
std::cout << "here" << std::endl;
{
auto butt = new Fl_Button(0, 0, 100, 200, "test");
}
win1->end();
auto butt = new Fl_Button(0, 30, 100, 200, "nyaaa");
}
grp1->end();
// Fl_Group *grp2 = new Fl_Group(20, 30, 280, 170, "Tab2");
// {
// }
// grp2->end();
// Fl_Group *grp3 = new Fl_Group(20, 30, 280, 170, "Tab3");
// {
// }
// grp3->end();
// Fl_Group *grp4 = new Fl_Group(20, 30, 280, 170, "Tab4");
// {
// }
// grp4->end();
// Fl_Group *grp5 = new Fl_Group(20, 30, 280, 170, "Tab5");
// {
// }
// grp5->end();
tabs.end();
tabs.handle_overflow(Fl_Tabs::OVERFLOW_DRAG);
tabs.resizable(grp1);
end();
}

18
src/summarymanager.hpp Normal file
View file

@ -0,0 +1,18 @@
#ifndef SUMMARYMANAGER_HEADER
#define SUMMARYMANAGER_HEADER
#include <FL/Fl_Button.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Tabs.H>
#include <memory>
#include <vector>
struct SummaryManager : Fl_Group {
SummaryManager(int x, int y, int w, int h);
Fl_Tabs tabs;
std::vector<Fl_Button*> items;
};
#endif