Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(parse): add proto::extensions::SimpleExtensionDeclaration parser #170

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

ilikepi63
Copy link

Adds a parser for proto::extensions::SimpleExtensionDeclaration that parses the declaration.

@CLAassistant
Copy link

CLAassistant commented Apr 4, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@mbrobbel mbrobbel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. I left some comments.

Marked this as non-breaking (for now).

type Parsed = ExtensionFunction;
type Error = SimpleExtensionDeclarationError;

fn parse(self, _ctx: &mut C) -> Result<Self::Parsed, Self::Error> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parser should add the function to the context, checking that the referenced extension uri is valid, the used anchor is unique, and that the definition contains a matching function with the given name in the referenced extension.

Comment on lines +1 to +2
use crate::parse::{Anchor, Context, Parse};
use crate::proto;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can you merge those?

type Parsed = ExtensionTypeVariation;
type Error = SimpleExtensionDeclarationError;

fn parse(self, _ctx: &mut C) -> Result<Self::Parsed, Self::Error> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.


Ok(SimpleExtensionDeclaration {
mapping_type: mapping_type
.map(|mapping_type| mapping_type.parse(ctx).ok())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want this to silently error on parser errors.

@mbrobbel mbrobbel changed the title feat(parse)!: add proto::extensions::SimpleExtensionDeclaration parser feat(parse): add proto::extensions::SimpleExtensionDeclaration parser Apr 4, 2024
ilikepi63 and others added 11 commits April 8, 2024 05:37
…ion_function.rs

Co-authored-by: Matthijs Brobbel <m1brobbel@gmail.com>
…ion_function.rs

Co-authored-by: Matthijs Brobbel <m1brobbel@gmail.com>
…ion_function.rs

Co-authored-by: Matthijs Brobbel <m1brobbel@gmail.com>
…ion_type.rs

Co-authored-by: Matthijs Brobbel <m1brobbel@gmail.com>
…ion_type.rs

Co-authored-by: Matthijs Brobbel <m1brobbel@gmail.com>
…ion_type_variation.rs

Co-authored-by: Matthijs Brobbel <m1brobbel@gmail.com>
…ion_type_variation.rs

Co-authored-by: Matthijs Brobbel <m1brobbel@gmail.com>
…g_type.rs

Co-authored-by: Matthijs Brobbel <m1brobbel@gmail.com>
…_extension_declaration.rs

Co-authored-by: Matthijs Brobbel <m1brobbel@gmail.com>
Co-authored-by: Matthijs Brobbel <m1brobbel@gmail.com>
@mbrobbel mbrobbel marked this pull request as ready for review April 8, 2024 14:11
@mbrobbel mbrobbel marked this pull request as draft April 8, 2024 14:11
@mbrobbel mbrobbel mentioned this pull request Apr 9, 2024
32 tasks
Comment on lines 42 to 50
/// Add a [ExtensionFunction] to this context. Must return an error for duplicate
/// anchors, when the URI is not supported or if the definition does not contain a matching function with the given name.
///
/// This function must eagerly resolve and parse the simple extension, returning an
/// error if either fails.
fn add_extension_function(
&mut self,
extension_function: &ExtensionFunction,
) -> Result<&SimpleExtensions, ContextError>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return types and comments of these functions should be updated.

ilikepi63 and others added 5 commits May 2, 2024 12:20
…_extension_declaration.rs

Co-authored-by: Matthijs Brobbel <m1brobbel@gmail.com>
…_extension_declaration.rs

Co-authored-by: Matthijs Brobbel <m1brobbel@gmail.com>
@ilikepi63 ilikepi63 marked this pull request as ready for review May 5, 2024 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants