Files
BlitzLLVM/code_compiler/source/ast/ast.hpp
T

79 lines
2.7 KiB
C++
Raw Normal View History

2024-06-25 18:59:15 +02:00
/// AUTOGENERATED COPYRIGHT HEADER START
// Copyright (C) 2017-2025 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
2024-06-25 18:59:15 +02:00
// AUTOGENERATED COPYRIGHT HEADER END
2024-06-06 13:37:13 +02:00
#pragma once
2024-06-26 00:31:06 +02:00
#include <list>
#include <memory>
#include <optional>
#include <string>
#include "../lexer.hpp"
#include "../types.hpp"
2024-06-26 00:31:06 +02:00
// BlitzBasic Built-Ins
// - Include: Followed by a String, which is the file to include at this location.
// - Const: Defines one or more constants, which can not be modified.
// - Local: Defines one or more local variables, which can be modified.
// - Global: Defines one or more global variables, which can be modified from anywhere.
// - Dim: Defines a dynamically resizable array, globally accessible and modifyable.
// - If, Then, ElseIf, EndIf: Your classic If.
// - Select, Case, Default, End Select: Your classic Select.
// - For, To, Step, Next: Your classic For loop.
// - While, Wend: Your classic While loop.
// - Repeat, Until, Forever: Similar to While/Wend, but the condition is at the end and will only loop if the condition is false.
// - Exit: Exit from any currently active loops. I guess this allows leaving Repeat/Forever combinations.
// - True, False: True and False. What, did you expect something else?
// - Stop: Pause the program for the debugger, if there happens to be one.
// - End: Terminate the program.
// - Goto: Jump to a specific label, without setting the return address.
// - Gosub, Return: Jump to a specific label (subroutine), setting the return address appropriately, and Return from it eventually.
// - Function, Return, End Function: Defines a function, and allows returning values. Yes, I know, End itself terminates the program, this is a special case. Thanks younger Sibly.
// - And, Or, Not: Logical operator, self-explanatory really.
2024-06-06 14:04:34 +02:00
namespace blitz {
2024-06-25 18:59:15 +02:00
namespace ast {
struct node {
std::vector<blitz::token> tokens;
2025-01-25 16:27:50 +01:00
virtual ~node() = default;
2024-06-26 00:31:06 +02:00
};
struct variable : public node {
std::string name;
blitz::types::type type;
std::string struct_name;
2024-06-26 00:31:06 +02:00
2025-01-25 16:27:50 +01:00
virtual ~variable();
2024-06-26 00:31:06 +02:00
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);
2024-06-26 00:31:06 +02:00
};
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;
2024-06-26 00:31:06 +02:00
virtual ~value();
2024-06-26 00:31:06 +02:00
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);
};
2024-06-26 00:31:06 +02:00
struct expression : public node {};
2024-06-26 00:31:06 +02:00
} // namespace ast
} // namespace blitz