Skip to content

Commit

Permalink
Merge pull request Wilfred#12 from gpanders/multiline-string-prefix
Browse files Browse the repository at this point in the history
Include leading \\ characters as anonymous nodes
  • Loading branch information
maxxnino authored Apr 2, 2022
2 parents 42e93d0 + 2761ae3 commit 664ebbf
Show file tree
Hide file tree
Showing 5 changed files with 74,127 additions and 73,729 deletions.
7 changes: 3 additions & 4 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ const AMPERSAND = "&",
dec_int = seq(dec, repeat(dec_)),
hex_int = seq(hex, repeat(hex_)),
unescaped_string_fragment = token.immediate(prec(1, /[^"\\\{\}]+/)),
unescaped_char_fragment = token.immediate(prec(1, /[^'\\]/)),
line_string = token(seq("\\\\", /[^\n]*/));
unescaped_char_fragment = token.immediate(prec(1, /[^'\\]/));

module.exports = grammar({
name: "zig",
Expand Down Expand Up @@ -843,9 +842,9 @@ module.exports = grammar({
'"'
),

LINESTRING: (_) => repeat1(line_string),
LINESTRING: (_) => seq("\\\\", /[^\n]*/),

_STRINGLITERAL: ($) => choice($.STRINGLITERALSINGLE, $.LINESTRING),
_STRINGLITERAL: ($) => choice($.STRINGLITERALSINGLE, repeat1($.LINESTRING)),

Variable: ($) => field("variable", $.IDENTIFIER),

Expand Down
33 changes: 15 additions & 18 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -5288,23 +5288,17 @@
]
},
"LINESTRING": {
"type": "REPEAT1",
"content": {
"type": "TOKEN",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "\\\\"
},
{
"type": "PATTERN",
"value": "[^\\n]*"
}
]
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "\\\\"
},
{
"type": "PATTERN",
"value": "[^\\n]*"
}
}
]
},
"_STRINGLITERAL": {
"type": "CHOICE",
Expand All @@ -5314,8 +5308,11 @@
"name": "STRINGLITERALSINGLE"
},
{
"type": "SYMBOL",
"name": "LINESTRING"
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "LINESTRING"
}
}
]
},
Expand Down
4 changes: 4 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -3321,6 +3321,10 @@
"type": "[",
"named": false
},
{
"type": "\\\\",
"named": false
},
{
"type": "]",
"named": false
Expand Down
Loading

0 comments on commit 664ebbf

Please sign in to comment.