What's an “additional tie breaker” for Perl 6 longest token matching?

喜你入骨 提交于 2019-12-10 03:52:10

问题


The docs for Perl 6 longest alternation in regexes punt to Synopsis 5 to document the rules for longest token matching. There are three rules if different alternatives would match a substring of the same length:

  • The longest declarative prefix breaks the tie
  • The highest specificity breaks the tie
  • "If it's still a tie, use additional tie-breakers."
  • The left most alternation finally wins

It's that third rule that I'm curious about.


回答1:


First the way the text is organized makes clear that the behaviour of the implementation must be deterministic (not random).

Second - and more important - describing the exact behaviour of existing implementations could fill an entire, hard-to-understand page as every corner case has to be described. In addition such a specification would limit degrees of freedom of the implementation. Let's assume some implementation supports a "fastest implementation" flag. Such an implementation can use unspecified parts to make short-cuts. So leaving the behaviour unspecified resp. restricted to the minimum has some advantages.



来源:https://stackoverflow.com/questions/49943078/whats-an-additional-tie-breaker-for-perl-6-longest-token-matching

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!