Skip to content

Commit

Permalink
[css-shadow-parts-1] Add microsyntaxes for parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
fergald committed Nov 9, 2018
1 parent fa6a6b7 commit 13add36
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions css-shadow-parts-1/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,62 @@ The token set of this particular DOMTokenList object are also known as the eleme

Issue(w3c/csswg-drafts#2414): Define this as a superglobal in the DOM spec.
Issue(w3c/csswg-drafts#2414): Define IDL for structured setting and getting of `exportparts`.

Microsyntaxes for parsing {#parsing}
==============================================

Rules for parsing part mappings {#parsing-mapping}
----------------------------------------------

A <span>valid part mapping</span> is a pair of DOMTokens

This comment has been minimized.

Copy link
@tabatkins

tabatkins Nov 9, 2018

Member

<dfn export>, not <span>

This comment has been minimized.

Copy link
@tabatkins

tabatkins Nov 9, 2018

Member

Linkify pair to its Infra definition. Where is DOMToken defined? Bikeshed doesn't seem to find it.

This comment has been minimized.

Copy link
@fergald

fergald Nov 12, 2018

Author Contributor

<dfn export>, not <span>

Done.

This comment has been minimized.

Copy link
@fergald

fergald Nov 12, 2018

Author Contributor

Linkify pair to its Infra definition. Where is DOMToken defined? Bikeshed doesn't seem to find it.

Actually, it doesn't exist and I couldn't find a definition of "token" either.

separated by a U+003A COLON charater,
with no other characters (e.g. no space characters).
The DOMTokens must not contain U+003A COLON or U+002C COMMA characters.

The rules for parsing a part mapping are as follows:

1. Let <var>input</var> be the string being parsed.

1. Let <var>position</var> be a pointer into <var>input</var>, initially pointing at the start of the string.

1. <span>Collect a sequence of code points</span> that are space characters or U+003A COLON characters.

This comment has been minimized.

Copy link
@tabatkins

tabatkins Nov 9, 2018

Member

[=...=], not <span>.

This is consuming the part of the string before the first token; why are we allowing colons here?

This comment has been minimized.

Copy link
@fergald

fergald Nov 12, 2018

Author Contributor

[=...=], not <span>.

Done.

This is consuming the part of the string before the first token; why are we allowing colons here?

I started off being non-strict, this is left over.

This skips past any leading delimiters.
1. <span>Collect a sequence of code points</span> that are not space characters or U+003A COLON characters,
and let <var>first token</var> be the result.
1. If <var>first token</var> is empty then return error.
1. <span>Collect a sequence of code points</span> that are space characters.
1. If the end of the <var>input</var> has been reached, return the pair <var>first token</var>, <var>first token</var>
1. If character at <var>position</var> is not a U+003A COLON character, return error.
1. Consume the U+003A COLON character.
1. <span>Collect a sequence of code points</span> that are space characters.
1. <span>Collect a sequence of code points</span> that are not space characters or U+003A COLON characters.
and let <var>second token</var> be the result.
1. If <var>second token</var> is empty then return error.
1. Return the pair <var>first token</var>, <var>second token</var>.

This comment has been minimized.

Copy link
@tabatkins

tabatkins Nov 9, 2018

Member

You want to consume more whitespace, then check that we are at the end of input before returning; if we're not, that means there's extra junk at the end and we should return error.


Rules for parsing a list of part mappings {#parsing-mapping-list}
----------------------------------------------

A <span>valid list of part mappings</span> is a number of valid part mappings
separated by a U+002C COMMA charater,
with no other characters (e.g. no space characters).

The rules for parsing a list of part mappings are as follow:

1. Let <var>input</var> be the string being parsed.

1. Let <var>position</var> be a pointer into <var>input</var>, initially pointing at the start of the string.

1. Let <var>mappings</var> be an initially empty list of pairs of DOMTokens.

This comment has been minimized.

Copy link
@tabatkins

tabatkins Nov 9, 2018

Member

Link the Infra definitions for "list" and "pair" here. Link DOMToken too.

This comment has been minimized.

Copy link
@fergald

fergald Nov 12, 2018

Author Contributor

Done (except DOMToken)

This list will be the result of this algorithm.

1. <span>Collect a sequence of code points</span> that are space characters, U+002C COMMA or U+003A COLON characters.
This skips past any leading delimiters.

This comment has been minimized.

Copy link
@tabatkins

tabatkins Nov 9, 2018

Member

Why are we skipping past commas and colons here? I don't understand why we want to allow a string to start with either of these.

This comment has been minimized.

Copy link
@fergald

fergald Nov 12, 2018

Author Contributor

Other lists of things in the HTML spec skip over leading delimiters. Arguably skipping over colons is just wrong but skipping over commas could be reasonable. I'm not too bothered either way.

What I'm going to do is rewrite this to use "split a string input on commas" and then the question is whether to ignore or error on empty items.


1. While <var>position</var> is not past the end of <var>input</var>:

1. <span>Collect a sequence of code points</span> that are not U+002C COMMA characters,
and let <var>unparsed mapping</var> be the result.
1. Let <var>mapping</var> be the result of parsing <var>unparsed mapping</var> using the <span>rules for parsing part mappings</span>.
1. If <var>mapping</var> is an error, continue.
1. Append <var>mapping</var> to <var>mappings</var>.

This comment has been minimized.

Copy link
@tabatkins

tabatkins Nov 9, 2018

Member

You're not consuming the comma, so if there's a comma in the string, this collects the first item then infinite-loops.

This comment has been minimized.

Copy link
@fergald

fergald Nov 12, 2018

Author Contributor

Will be addressed with split on commas.

1 comment on commit 13add36

@fergald
Copy link
Contributor Author

Choose a reason for hiding this comment

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

a0ec26c address many of these. I will follow up with one more for comma-splitting.

Please sign in to comment.