mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-07 23:48:44 +00:00
or references, prining improvements, comments now printed, fixes
This commit is contained in:
parent
73263193a9
commit
5e70f0015f
19 changed files with 354 additions and 429 deletions
|
|
@ -7,14 +7,28 @@
|
|||
|
||||
namespace nodes {
|
||||
|
||||
// replace enum with structure ??
|
||||
enum class Modifier {
|
||||
OUT, // -> x
|
||||
IN, // <- x
|
||||
REF, // <> x // IN and OUT
|
||||
OR_OUT, // |-> // OUT or NONE
|
||||
OR_IN, // <-| // IN or NONE
|
||||
OPTIONAL, // x?
|
||||
RESULT, // x!
|
||||
IN, // <- x
|
||||
REF, // <> x
|
||||
CONST, // -- x (or nothing sometimes)
|
||||
OUT, // -> x
|
||||
//
|
||||
IN_OR_REF, // <-|<> x
|
||||
IN_OR_CONST, // <-|-- x
|
||||
REF_OR_OUT, // <>|-> x
|
||||
CONST_OR_OUT, // --|-> x
|
||||
REF_OR_CONST, // <>|-- x
|
||||
IN_OR_OUT, // <-|-> x
|
||||
//
|
||||
IN_OR_REF_OR_OUT, // <-|<>|-> x
|
||||
IN_OR_CONST_OR_OUT, // <-|--|-> x
|
||||
IN_OR_REF_OR_CONST, // <-|<>|-- x
|
||||
REF_OR_CONST_OR_OUT, //<>|--|-> x
|
||||
//
|
||||
IN_OR_REF_OR_CONST_OR_OUT, //<-|<>|--|-> x
|
||||
OPTIONAL, // x?
|
||||
RESULT, // x!
|
||||
NONE,
|
||||
};
|
||||
|
||||
|
|
@ -86,23 +100,51 @@ public:
|
|||
|
||||
IdentifierType get_type() const { return type_; }
|
||||
|
||||
//
|
||||
|
||||
std::string *get() { return &value_; }
|
||||
|
||||
const std::string *get() const { return &value_; }
|
||||
|
||||
//
|
||||
|
||||
void append_before(const std::string &name) { value_ = name + "." + value_; }
|
||||
|
||||
void append_after(const std::string &name) {
|
||||
value_ += ".";
|
||||
value_ += name;
|
||||
}
|
||||
|
||||
private:
|
||||
IdentifierType type_;
|
||||
std::string value_;
|
||||
};
|
||||
|
||||
class EmptyLines : public Node {
|
||||
class Extra : public Node {
|
||||
public:
|
||||
EmptyLines(Node node, size_t size) : Node(node), size_(size) {}
|
||||
Extra(Node node, std::string &&content)
|
||||
: Node(node), content_(std::move(content)) {}
|
||||
|
||||
size_t size() const { return size_; }
|
||||
Extra(Node node, const std::string &content)
|
||||
: Node(node), content_(content) {}
|
||||
|
||||
std::string *content() { return &content_; }
|
||||
|
||||
const std::string *content() const { return &content_; }
|
||||
|
||||
private:
|
||||
size_t size_;
|
||||
std::string content_;
|
||||
};
|
||||
|
||||
class EmptyLines : public Node {
|
||||
public:
|
||||
EmptyLines(Node node, size_t line_count)
|
||||
: Node(node), line_count_(line_count) {}
|
||||
|
||||
size_t line_count() const { return line_count_; }
|
||||
|
||||
private:
|
||||
size_t line_count_;
|
||||
};
|
||||
|
||||
} // namespace nodes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue