Skip to content

Commit fca55bf

Browse files
p-e-wMax Brunsfeld
authored and
Max Brunsfeld
committedMar 3, 2018
Allow string prefixes to be either case (#19)
* Allow string prefixes to be either case * Add test cases * Regenerate parser
1 parent 9d09884 commit fca55bf

File tree

4 files changed

+38414
-35899
lines changed

4 files changed

+38414
-35899
lines changed
 

‎corpus/literals.txt

+4
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ Strings
9292
'"ok"'
9393
r'hi'
9494
ur"bye"
95+
UR'bye'
9596
b'sup'
97+
B"sup"
9698
`1`
9799
"\\"
98100
"/"
@@ -110,6 +112,8 @@ string"
110112
(expression_statement (string))
111113
(expression_statement (string))
112114
(expression_statement (string))
115+
(expression_statement (string))
116+
(expression_statement (string))
113117
(expression_statement (string)))
114118

115119
=====================================

‎grammar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ module.exports = grammar({
705705
),
706706

707707
string: $ => token(seq(
708-
repeat(choice('u', 'r', 'b')),
708+
repeat(choice(/[uU]/, /[rR]/, /[bB]/)),
709709
choice(
710710
seq('`', repeat(choice(/[^\\`\n]/, /\\./, /\\\n/)), '`'),
711711
seq('"', repeat(choice(/[^\\"\n]/, /\\./, /\\\n/)), '"'),

‎src/grammar.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -3393,16 +3393,16 @@
33933393
"type": "CHOICE",
33943394
"members": [
33953395
{
3396-
"type": "STRING",
3397-
"value": "u"
3396+
"type": "PATTERN",
3397+
"value": "[uU]"
33983398
},
33993399
{
3400-
"type": "STRING",
3401-
"value": "r"
3400+
"type": "PATTERN",
3401+
"value": "[rR]"
34023402
},
34033403
{
3404-
"type": "STRING",
3405-
"value": "b"
3404+
"type": "PATTERN",
3405+
"value": "[bB]"
34063406
}
34073407
]
34083408
}

‎src/parser.c

+38,403-35,892
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.