More work on getting parsing to be functional

This commit is contained in:
Michael Fabian 'Xaymar' Dirks
2025-01-25 19:25:14 +01:00
parent e191173e7b
commit b61005bcaa
16 changed files with 855 additions and 400 deletions
+33 -18
View File
@@ -1,5 +1,5 @@
/// AUTOGENERATED COPYRIGHT HEADER START
// Copyright (C) 2017-2024 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
// Copyright (C) 2017-2025 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
// AUTOGENERATED COPYRIGHT HEADER END
#pragma once
#include <list>
@@ -7,6 +7,7 @@
#include <optional>
#include <string>
#include "../lexer.hpp"
#include "../types.hpp"
// BlitzBasic Built-Ins
// - Include: Followed by a String, which is the file to include at this location.
@@ -30,34 +31,48 @@
namespace blitz {
namespace ast {
class node {
public:
struct node {
std::vector<blitz::token> tokens;
virtual ~node() = default;
};
class expression : public node {};
struct variable : public node {
std::string name;
blitz::types::type type;
std::string struct_name;
class variable : public node {
blitz::token _token;
std::shared_ptr<blitz::ast::expression> _value;
public:
virtual ~variable();
variable(blitz::token token);
void set_value(std::shared_ptr<blitz::ast::expression> value);
static bool can_parse(std::shared_ptr<blitz::lexer> lexer);
static std::shared_ptr<blitz::ast::node> try_parse(std::shared_ptr<blitz::lexer> lexer);
};
class call : public node {};
struct value : public node {
enum class variant {
UNKNOWN,
NULL,
BOOL,
INTEGER,
UNSIGNED_INTEGER,
REAL,
STRING,
} type;
union {
bool b;
intmax_t i;
uintmax_t ui;
double f;
} number;
std::string text;
class local : public node {
public:
~local();
local();
virtual ~value();
static bool can_parse(std::shared_ptr<blitz::lexer> lexer);
static std::shared_ptr<blitz::ast::node> try_parse(std::shared_ptr<blitz::lexer> lexer);
};
class global : public node {};
struct expression : public node {};
} // namespace ast
} // namespace blitz