You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

55 lines
1.7 KiB

#include "molasses/lexer.h"
#include "molasses/parser_primitives.h"
#include <iostream>
int main() {
/*
molasses::lexed_output initial;
initial.dictionary[1] = "+";
{
auto v = molasses::lex("hello hello potato 128 hello 128 +");
auto v2 = molasses::lex("salad hello potato 129 hello 128");
for (auto symbol: v.symbols) {
std::cout << "v: " << symbol << " - " << v.dictionary.at(symbol) << "\n";
}
std::cout << "\n";
for (auto symbol: v2.symbols) {
std::cout << "v2: " << symbol << " - " << v2.dictionary.at(symbol) << "\n";
}
auto v_merged = molasses::concatenate(initial, molasses::concatenate(v, v2));
std::cout << "\n";
for (auto symbol: v_merged.symbols) {
std::cout << "v_merged: " << symbol << " - " << v_merged.dictionary.at(symbol) << "\n";
}
}
auto v = molasses::lex("1 2 +");
molasses::parser_context ctx;
ctx = molasses::register_integers(ctx);
ctx.operations.emplace_back(std::make_shared<molasses::primitive_operation>(std::string{"+"}, std::vector<std::string>({"i32", "i32"}), std::vector<std::string>({"i32"})));
if(molasses::type_check(ctx, v, v.symbols, {}, {"i32"})) {
std::cout << "Checks out\n";
}*/
/*
auto lexed = molasses::lex("__PROC__ sum\n"
"i32 i32\n"
"__--__\n"
"i32\n"
"__DO__\n"
"+\n"
"__END__");*/
auto lexed = molasses::lex("__PROC__ main\n"
"__--__\n"
"__DO__\n"
"__END__");
molasses::parser_context ctx;
ctx = molasses::register_integers(ctx);
ctx = molasses::register_i32_operations(ctx);
molasses::parse(ctx, lexed);
}