From 98ac2e8f26ff4d90c37bb9c9536e9eb14e31efb4 Mon Sep 17 00:00:00 2001 From: Mel Date: Sun, 14 Nov 2021 19:31:48 +0100 Subject: Parse and walk str embeds. --- src/parse/ast/nodes.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/parse/ast/nodes.rs') diff --git a/src/parse/ast/nodes.rs b/src/parse/ast/nodes.rs index 2bf3f17..c4bb1e8 100644 --- a/src/parse/ast/nodes.rs +++ b/src/parse/ast/nodes.rs @@ -64,7 +64,6 @@ impl UnaryOperator { pub enum SimpleLiteral { Int(u32), Float(f32), - Str(String), Bool(bool), } @@ -73,7 +72,6 @@ impl SimpleLiteral { match token.variant { Int(int) => Self::Int(int), Float(float) => Self::Float(float), - Str(string) => Self::Str(string), KeywordTrue => Self::Bool(true), KeywordFalse => Self::Bool(false), _ => panic!("Can't create literal from '{:?}'.", token.variant), @@ -110,14 +108,20 @@ pub struct MemberAccessNode { } #[derive(Debug, Clone)] -pub struct FnNode { - pub header: FnHeader, - pub body: BlockNode, +pub struct StrNode { + pub parts: Vec, } #[derive(Debug, Clone)] -pub struct ArrayNode { - pub elements: Vec, +pub enum StrPart { + Literal(String), + Embed(Expression) +} + +#[derive(Debug, Clone)] +pub struct FnNode { + pub header: FnHeader, + pub body: BlockNode, } #[derive(Debug, Clone)] @@ -127,6 +131,10 @@ pub struct FnHeader { pub return_type: Option, } +#[derive(Debug, Clone)] +pub struct ArrayNode { + pub elements: Vec, +} #[derive(Debug, Clone)] pub struct IfNode { pub conditionals: Vec, -- cgit 1.4.1