From 56760f0517c646f41dd179e1f365d3268df3ec50 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 9 Feb 2023 10:30:55 -0500 Subject: initial commit --- alee.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 alee.cpp (limited to 'alee.cpp') diff --git a/alee.cpp b/alee.cpp new file mode 100644 index 0000000..8ca209c --- /dev/null +++ b/alee.cpp @@ -0,0 +1,58 @@ +/** + * Alee Forth: A portable and concise Forth implementation in modern C++. + * Copyright (C) 2023 Clyne Sullivan + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#include "memdict.hpp" +#include "parser.hpp" + +#include + +// : variable create 0 , ; +// : create here constant ; +// : constant + +int main() +{ + MemDict dict; + State state (dict); + Parser parser; + + for (;;) { + std::string line; + std::cout << state.size() << ' ' << state.compiling << "> "; + std::getline(std::cin, line); + + ParseStatus r; + std::string_view lv (line); + do { + r = parser.parse(state, lv); + } while (r == ParseStatus::Continue); + + if (r != ParseStatus::Finished) + std::cout << "r " << to_string(r) << std::endl; + } + + return 0; +} + +int user_sys(State& state) +{ + const auto value = state.pop(); + std::cout << value << std::endl; + return 0; +} + -- cgit v1.2.3