Skip to content

Commit

Permalink
wip caption resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Dec 2, 2024
1 parent b0ed2ca commit 1ce8480
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions v0.5/fastn-section/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ fn error(e: &fastn_section::Error, _s: Option<fastn_section::Span>) -> serde_jso
fastn_section::Error::ComponentIsNotAFunction => "component_is_not_a_function",
fastn_section::Error::SymbolNotFound => "symbol_not_found",
fastn_section::Error::InvalidIdentifier => "invalid_identifier",
fastn_section::Error::UnexpectedCaption => "unexpected_caption",
};

serde_json::json!({ "error": v})
Expand Down
1 change: 1 addition & 0 deletions v0.5/fastn-section/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub enum Error {
ComponentIsNotAFunction,
SymbolNotFound,
InvalidIdentifier,
UnexpectedCaption,
// SectionNotFound(&'a str),
// MoreThanOneCaption,
// ParseError,
Expand Down
25 changes: 19 additions & 6 deletions v0.5/fastn-unresolved/src/resolver/arguments.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#[allow(clippy::too_many_arguments)]
pub fn arguments(
_arguments: &[fastn_resolved::Argument],
_caption: &mut fastn_unresolved::UR<Option<fastn_section::HeaderValue>, ()>,
_properties: &mut [fastn_unresolved::UR<
fastn_unresolved::Property,
fastn_resolved::Property,
>],
arguments: &[fastn_resolved::Argument],
caption: &mut fastn_unresolved::UR<Option<fastn_section::HeaderValue>, ()>,
_properties: &mut Vec<
fastn_unresolved::UR<fastn_unresolved::Property, fastn_resolved::Property>,
>,
_body: &mut fastn_unresolved::UR<Vec<fastn_section::Tes>, ()>,
_children: &[fastn_unresolved::UR<
fastn_unresolved::ComponentInvocation,
Expand All @@ -16,4 +15,18 @@ pub fn arguments(
_arena: &mut fastn_unresolved::Arena,
_output: &mut fastn_unresolved::resolver::Output,
) {
if let fastn_unresolved::UR::UnResolved(None) = caption {
*caption = fastn_unresolved::UR::Resolved(())
}
if let fastn_unresolved::UR::UnResolved(Some(_v)) = caption {
// see if any of the arguments are of type caption.
// assume there is only one such argument, because otherwise arguments would have failed
// to resolve
match arguments.iter().find(|v| v.is_caption()) {
Some(_v) => todo!(),
None => {
*caption = fastn_unresolved::UR::Invalid(fastn_section::Error::UnexpectedCaption)
}
}
}
}
6 changes: 3 additions & 3 deletions v0.5/fastn-unresolved/src/resolver/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ pub fn symbol(
todo!()
}
None => {
// there are two case where this is valid.
// a, if the module was defined in the current module using the `-- module foo:`
// syntax, which we currently do not support
// there are two cases where this is valid.
// a, if the module was defined in the current module using the future
// `-- module foo: ` syntax.
// b, this is a foo.bar case, where foo is the name of component, and we have
// to look for bar in the arguments.
//
Expand Down

0 comments on commit 1ce8480

Please sign in to comment.