irc: add Float and URI literal support
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I40c59d94f650e7b9e68f77598492d7ab6a6a6964
This commit is contained in:
parent
3dd2d604ce
commit
95baf44a9c
6 changed files with 126 additions and 9 deletions
|
|
@ -19,10 +19,12 @@ constexpr uint32_t IR_VERSION = 2;
|
|||
|
||||
enum class NodeType : uint8_t {
|
||||
CONST_INT = 0x01,
|
||||
CONST_FLOAT = 0x06,
|
||||
CONST_STRING = 0x02,
|
||||
CONST_PATH = 0x03,
|
||||
CONST_BOOL = 0x04,
|
||||
CONST_NULL = 0x05,
|
||||
CONST_URI = 0x07,
|
||||
VAR = 0x10,
|
||||
LAMBDA = 0x20,
|
||||
APP = 0x21,
|
||||
|
|
@ -77,6 +79,18 @@ struct ConstNullNode {
|
|||
ConstNullNode(uint32_t l = 0) : line(l) {}
|
||||
};
|
||||
|
||||
struct ConstFloatNode {
|
||||
double value;
|
||||
uint32_t line = 0;
|
||||
ConstFloatNode(double v = 0.0, uint32_t l = 0) : value(v), line(l) {}
|
||||
};
|
||||
|
||||
struct ConstURINode {
|
||||
std::string value;
|
||||
uint32_t line = 0;
|
||||
ConstURINode(std::string v = "", uint32_t l = 0) : value(std::move(v)), line(l) {}
|
||||
};
|
||||
|
||||
struct VarNode {
|
||||
uint32_t index = 0;
|
||||
std::optional<std::string> name;
|
||||
|
|
@ -189,10 +203,11 @@ struct ForceNode {
|
|||
// Node wraps a variant for type-safe AST
|
||||
class Node {
|
||||
public:
|
||||
using Variant = std::variant<ConstIntNode, ConstStringNode, ConstPathNode, ConstBoolNode,
|
||||
ConstNullNode, VarNode, LambdaNode, AppNode, BinaryOpNode,
|
||||
UnaryOpNode, AttrsetNode, SelectNode, HasAttrNode, WithNode, IfNode,
|
||||
LetNode, LetRecNode, AssertNode, ThunkNode, ForceNode>;
|
||||
using Variant = std::variant<ConstIntNode, ConstFloatNode, ConstStringNode, ConstPathNode,
|
||||
ConstBoolNode, ConstNullNode, ConstURINode, VarNode, LambdaNode,
|
||||
AppNode, BinaryOpNode, UnaryOpNode, AttrsetNode, SelectNode,
|
||||
HasAttrNode, WithNode, IfNode, LetNode, LetRecNode, AssertNode,
|
||||
ThunkNode, ForceNode>;
|
||||
|
||||
Variant data;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue