Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1460,8 +1460,8 @@ module.exports = grammar({
seq(
"'",
choice(
token.immediate(prec(2, /[^\\\n\r']/)),
alias($._char_escape_sequence, $.escape_sequence)
alias($._char_escape_sequence, $.escape_sequence),
alias(token.immediate(prec(2, /[^\\\n\r']/)), $.char_content)
),
token.immediate("'")
),
Expand Down
27 changes: 16 additions & 11 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -13563,17 +13563,6 @@
{
"type": "CHOICE",
"members": [
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "PREC",
"value": 2,
"content": {
"type": "PATTERN",
"value": "[^\\\\\\n\\r']"
}
}
},
{
"type": "ALIAS",
"content": {
Expand All @@ -13582,6 +13571,22 @@
},
"named": true,
"value": "escape_sequence"
},
{
"type": "ALIAS",
"content": {
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "PREC",
"value": 2,
"content": {
"type": "PATTERN",
"value": "[^\\\\\\n\\r']"
}
}
},
"named": true,
"value": "char_content"
}
]
},
Expand Down
10 changes: 9 additions & 1 deletion src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -1948,8 +1948,12 @@
"fields": {},
"children": {
"multiple": false,
"required": false,
"required": true,
"types": [
{
"type": "char_content",
"named": true
},
{
"type": "escape_sequence",
"named": true
Expand Down Expand Up @@ -12111,6 +12115,10 @@
"type": "cast",
"named": false
},
{
"type": "char_content",
"named": true
},
{
"type": "comment_content",
"named": true
Expand Down
6 changes: 3 additions & 3 deletions src/parser.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions test/corpus/deviations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ r"string
(string_content)
(block_comment
(comment_content)))
(char_literal
(block_comment
(comment_content)))
(char_literal
(char_content)
(block_comment
(comment_content)))
(raw_string_literal
(string_content)
(block_comment
Expand Down
12 changes: 8 additions & 4 deletions test/corpus/literals.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,14 @@ Character literals
--------------------------------------------------------------------------------

(source_file
(char_literal)
(char_literal)
(char_literal)
(char_literal)
(char_literal
(char_content))
(char_literal
(char_content))
(char_literal
(char_content))
(char_literal
(char_content))
(char_literal
(escape_sequence))
(char_literal
Expand Down