Skip to content

Commit

Permalink
UR type
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Nov 14, 2024
1 parent 0043d63 commit a64156b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 15 deletions.
4 changes: 2 additions & 2 deletions v0.5/fastn-lang/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ pub async fn compile(
) -> Result<fastn_lang::compiler::Output, fastn_lang::compiler::Error> {
// this guy will maintain symbols that failed to resolve, along with their dependencies, or maybe
// just the one dependency that failed?
let _d = fastn_unresolved::parse(document_id, source);
for c in _d.content {}
let d = fastn_unresolved::parse(document_id, source);
for _c in d.content {}
todo!()
}

Expand Down
38 changes: 29 additions & 9 deletions v0.5/fastn-unresolved/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@ pub struct Definition {
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub enum InnerDefinition {
Component {
properties: Vec<Property>,
properties: Vec<Argument>,
body: Vec<ComponentInvocation>,
},
Variable {
arguments: Vec<Argument>,
arguments: Vec<Property>,
caption: Vec<fastn_section::Tes>,
},
Function {
properties: Vec<Property>,
properties: Vec<Argument>,
return_type: Option<Kind>,
body: Vec<fastn_section::Tes>,
},
// -- type foo: person
// name: foo ;; we are updating / setting the default value
TypeAlias {
kind: Kind,
arguments: Vec<Argument>,
arguments: Vec<Property>,
},
Record {
properties: Vec<Property>,
properties: Vec<Argument>,
},
// TODO: OrType(fastn_section::Section),
// TODO: Module(fastn_section::Section),
Expand All @@ -69,23 +69,43 @@ pub struct Import {
pub exposing: Option<Export>,
}

// #[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)]
// pub struct ComponentInvocation {
// #[serde(skip_serializing_if = "Option::is_none")]
// pub id: Option<String>,
// pub name: String,
// pub properties: Vec<Property>,
// pub iteration: Box<Option<Loop>>,
// pub condition: Box<Option<fastn_type::Expression>>,
// pub events: Vec<Event>,
// pub children: Vec<ComponentInvocation>,
// pub source: ComponentSource,
// pub line_number: usize,
// }

#[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)]
pub enum UR<U, R> {
Resolved(R),
UnResolved(U),
}

#[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct ComponentInvocation {
pub name: Identifier,
pub name: UR<Identifier, Identifier>,
pub caption: Option<fastn_section::HeaderValue>,
pub arguments: Vec<Argument>,
pub properties: Vec<Property>,
pub body: Vec<fastn_section::Tes>,
pub children: Vec<ComponentInvocation>,
}

#[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct Argument {
pub struct Property {
pub name: Identifier,
pub value: Vec<fastn_section::Tes>,
}

#[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct Property {
pub struct Argument {
pub name: Identifier,
pub kind: Kind,
pub visibility: fastn_section::Visibility,
Expand Down
8 changes: 4 additions & 4 deletions v0.5/fastn-unresolved/src/parser/component_invocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ pub(super) fn component_invocation(
document
.content
.push(fastn_unresolved::ComponentInvocation {
name: fastn_unresolved::Identifier(section.name(source).to_string()),
name: fastn_unresolved::Identifier(section.name(source).to_string()).into(),
caption: section.caption,
arguments: vec![], // todo
body: vec![], // todo
children: vec![], // todo
properties: vec![], // todo
body: vec![], // todo
children: vec![], // todo
})
}

Expand Down
6 changes: 6 additions & 0 deletions v0.5/fastn-unresolved/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ impl std::str::FromStr for fastn_unresolved::Identifier {
Ok(fastn_unresolved::Identifier(s.to_string()))
}
}

impl<U, R> From<U> for fastn_unresolved::UR<U, R> {
fn from(u: U) -> fastn_unresolved::UR<U, R> {
fastn_unresolved::UR::UnResolved(u)
}
}

0 comments on commit a64156b

Please sign in to comment.