Skip to content

No way to tell if nested block closed by delimiter or EOF #69

Closed
@luniv

Description

@luniv

I'm working on parsing media queries, and my understanding is that the syntax specifies that a media feature must end with a ) [1].

For example, if you have the string "(width", Parser::parse_nested_block will return Ok(_). And there is no easy way to determine how if it was closed by a ) or EOF, as far as I can see.

#[test]
fn block_closed_by_delimiter() {
    let mut input = Parser::new("(width");

    assert!(input.expect_parenthesis_block().is_ok());
    let result = input.parse_nested_block(|input| {
        assert!(input.expect_ident_matching("width").is_ok());
        assert!(input.is_exhausted());
        Ok(true)
    });
    assert!(result.is_err());
}

1: http://drafts.csswg.org/mediaqueries/#typedef-media-feature

<media-feature> = ( [ <mf-plain> | <mf-boolean> | <mf-range> ] )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions