的作用是什么? W3C CSS 规范的标记化部分中的意思是什么?
自从我使用 cssparser 的糟糕经历以来,我给自己设定了一个任务:使用 Parboiled 在 Java 中实现 CSS 解析器。我已经涵盖了所有颜色规范,但当然我需要所有其余的...
所以,我去寻找 CSS 规范并在 W3C 网站。我现在正在为所有“原子”编写规则,但在 本节:
UNICODE-RANGE u\+[0-9a-f?]{1,6}(-[0-9a-f]{1,6})?
令我不安的部分是[0-9a-f?]
中的问号。
段落标题表明这里使用的正则表达式是 Lex 风格的。 ?
在字符类中没有特殊含义(感谢@scizzo 的确认)。那么,这是 W3C 规范中的拼写错误,还是 ?
在 Unicode 范围内确实允许?如果是的话,这意味着什么?
总结:我有我的答案。然而,该规范是错误的:“问号 unicode 范围”只能是单独的。鉴于上述正则表达式,该表达式将被允许,但显然是非法的:u+4??-733f
Ever since my awful experience with cssparser, I have set myself the task of implementing a CSS parser in Java using Parboiled. I already have all color specification covered, but of course I need all the rest...
So, I went to look for the CSS specification and found it on the W3C website. I am now in the process of writing rules for all "atoms", but found something disturbing in this section:
UNICODE-RANGE u\+[0-9a-f?]{1,6}(-[0-9a-f]{1,6})?
The part that disturbs me is the question mark in [0-9a-f?]
.
The paragraph heading says the regular expressions used here are Lex-style. The ?
has no special meaning in a character class (thanks @scizzo for the confirmation). So, is this a typo in the W3C specification, or is ?
really allowed in a Unicode range? If yes, what does it mean?
Wrap up: I have my answer. However, the specification is wrong: a "question mark unicode range" can only be by itself. Given the above regex, this expression would be allowed whereas it is clearly illegal: u+4??-733f
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这是一个字面上的问号。 来自 Flex 文档:
现在,根据 W3C,
?
可以用作一种通配符:Yup, that's a literal question mark. From the Flex documentation:
Now, according to the W3C,
?
can be used as a kind of wildcard: