Skip to content

Commit e05d8dd

Browse files
committed
Note why the lexers match digits with [0-9]
Records why \d must not come back, and why the negated classes keep it.
1 parent 5d3f52f commit e05d8dd

3 files changed

Lines changed: 5 additions & 0 deletions

File tree

‎ly/lex/html.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class StringSQEnd(String, _token.StringEnd, _token.Leaver):
9595
rx = r"'"
9696

9797

98+
# [0-9], not \d: a numeric character reference is ASCII digits only
9899
class EntityRef(_token.Character):
99100
rx = r"\&(#[0-9]+|#[xX][0-9A-Fa-f]+|[A-Za-z_:][\w.:_-]*);"
100101

‎ly/lex/lilypond.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
from . import _token
2929
from . import Parser, FallthroughParser
3030

31+
# digit patterns use [0-9]: \d also matches Unicode digits that are not legal
32+
# LilyPond. \d in a negated class excludes those too, so it stays
33+
3134
# an identifier allowing letters and single hyphens in between
3235
re_identifier = r"[^\W\d_]+([_-][^\W\d_]+)*"
3336

‎ly/lex/scheme.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def test_match(cls, match):
138138
return match.group() in data.scheme_constants()
139139

140140

141+
# [0-9], not \d, which also matches Unicode digits that are not legal LilyPond
141142
class Number(_token.Item, _token.Numeric):
142143
rx = (r"("
143144
r"-?[0-9]+|"

0 commit comments

Comments
 (0)