feat(furas): introduce basic generator

Closes: #56
This commit is contained in:
2026-07-17 20:43:34 +02:00
parent dfaa3081cb
commit 9f950e45e7
6 changed files with 654 additions and 13 deletions
+36
View File
@@ -0,0 +1,36 @@
#ifndef FURAS_GEN_HPP
#define FURAS_GEN_HPP
#include "furas/lexer.hpp"
#include "furvm/module.hpp"
#include <string>
namespace furas {
struct generator_error {
enum type {
Success = 0,
Eof = 1,
UnexpectedEof = -1,
UnexpectedToken = -2,
UnknownCharacter = -3,
UnknownType = -4,
} type = Success;
std::string message;
};
class generator {
public:
struct result {
generator_error error;
furvm::mod mod;
};
public:
static result generate(lexer lexer);
};
} // namespace furas
#endif // FURAS_GEN_HPP
+8 -2
View File
@@ -18,9 +18,14 @@ struct token {
Sha256, /**< Label marker(`#`). */
Percent, /**< Variable marker(`%`). The more the better. */
Dot, /**< . */
EqSign, /**< `=` */
Dot, /**< . */
Colon, /**< `:` */
// Keywords
Func, /**< `func` keyword for defining functions. */
Type, /**< `type` keyword for defining types. */
Native, /**< `native` keyword for native functions. :v: */
Import, /**< `import` keyword for importing functions and types. */
Public, /**< `public` access specifier. */
Private, /**< `private` access specifier. */
@@ -29,6 +34,7 @@ struct token {
Push,
Array,
Get,
Set,
Drop,
Dup,
Clone,
@@ -50,7 +56,7 @@ struct token {
Load,
Store,
Call,
Jump,
Jmp,
Jnz,
Ret,