socket-function 0.12.16 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -248,39 +248,43 @@ function peg$parse(input, options) {
248
248
  peg$c89 = peg$literalExpectation("0", false),
249
249
  peg$c90 = peg$otherExpectation("string"),
250
250
  peg$c91 = function(chars) { return chars.join(""); },
251
- peg$c92 = "\"",
252
- peg$c93 = peg$literalExpectation("\"", false),
253
- peg$c94 = "\\",
254
- peg$c95 = peg$literalExpectation("\\", false),
255
- peg$c96 = "/",
256
- peg$c97 = peg$literalExpectation("/", false),
257
- peg$c98 = "b",
258
- peg$c99 = peg$literalExpectation("b", false),
259
- peg$c100 = function() { return "\b"; },
260
- peg$c101 = "f",
261
- peg$c102 = peg$literalExpectation("f", false),
262
- peg$c103 = function() { return "\f"; },
263
- peg$c104 = "n",
264
- peg$c105 = peg$literalExpectation("n", false),
265
- peg$c106 = function() { return "\n"; },
266
- peg$c107 = "r",
267
- peg$c108 = peg$literalExpectation("r", false),
268
- peg$c109 = function() { return "\r"; },
269
- peg$c110 = "t",
270
- peg$c111 = peg$literalExpectation("t", false),
271
- peg$c112 = function() { return "\t"; },
272
- peg$c113 = "u",
273
- peg$c114 = peg$literalExpectation("u", false),
274
- peg$c115 = function(digits) {
251
+ peg$c92 = "\\",
252
+ peg$c93 = peg$literalExpectation("\\", false),
253
+ peg$c94 = "/",
254
+ peg$c95 = peg$literalExpectation("/", false),
255
+ peg$c96 = "b",
256
+ peg$c97 = peg$literalExpectation("b", false),
257
+ peg$c98 = function() { return "\b"; },
258
+ peg$c99 = "f",
259
+ peg$c100 = peg$literalExpectation("f", false),
260
+ peg$c101 = function() { return "\f"; },
261
+ peg$c102 = "n",
262
+ peg$c103 = peg$literalExpectation("n", false),
263
+ peg$c104 = function() { return "\n"; },
264
+ peg$c105 = "r",
265
+ peg$c106 = peg$literalExpectation("r", false),
266
+ peg$c107 = function() { return "\r"; },
267
+ peg$c108 = "t",
268
+ peg$c109 = peg$literalExpectation("t", false),
269
+ peg$c110 = function() { return "\t"; },
270
+ peg$c111 = "u",
271
+ peg$c112 = peg$literalExpectation("u", false),
272
+ peg$c113 = function(digits) {
275
273
  return String.fromCharCode(parseInt(digits, 16));
276
274
  },
277
- peg$c116 = function(sequence) { return sequence; },
278
- peg$c117 = /^[^\0-\x1F"\\]/,
279
- peg$c118 = peg$classExpectation([["\0", "\x1F"], "\"", "\\"], true, false),
280
- peg$c119 = /^[0-9]/,
281
- peg$c120 = peg$classExpectation([["0", "9"]], false, false),
282
- peg$c121 = /^[0-9a-f]/i,
283
- peg$c122 = peg$classExpectation([["0", "9"], ["a", "f"]], false, true),
275
+ peg$c114 = function(sequence) { return sequence; },
276
+ peg$c115 = "\"",
277
+ peg$c116 = peg$literalExpectation("\"", false),
278
+ peg$c117 = "'",
279
+ peg$c118 = peg$literalExpectation("'", false),
280
+ peg$c119 = /^[^\0-\t\x0B-\x1F"\\]/,
281
+ peg$c120 = peg$classExpectation([["\0", "\t"], ["\x0B", "\x1F"], "\"", "\\"], true, false),
282
+ peg$c121 = /^[^\0-\t\x0B-\x1F'\\]/,
283
+ peg$c122 = peg$classExpectation([["\0", "\t"], ["\x0B", "\x1F"], "'", "\\"], true, false),
284
+ peg$c123 = /^[0-9]/,
285
+ peg$c124 = peg$classExpectation([["0", "9"]], false, false),
286
+ peg$c125 = /^[0-9a-f]/i,
287
+ peg$c126 = peg$classExpectation([["0", "9"], ["a", "f"]], false, true),
284
288
 
285
289
  peg$currPos = 0,
286
290
  peg$savedPos = 0,
@@ -1894,10 +1898,10 @@ function peg$parse(input, options) {
1894
1898
  s1 = peg$parsequotation_mark();
1895
1899
  if (s1 !== peg$FAILED) {
1896
1900
  s2 = [];
1897
- s3 = peg$parsechar();
1901
+ s3 = peg$parsechar_double_quote();
1898
1902
  while (s3 !== peg$FAILED) {
1899
1903
  s2.push(s3);
1900
- s3 = peg$parsechar();
1904
+ s3 = peg$parsechar_double_quote();
1901
1905
  }
1902
1906
  if (s2 !== peg$FAILED) {
1903
1907
  s3 = peg$parsequotation_mark();
@@ -1917,6 +1921,35 @@ function peg$parse(input, options) {
1917
1921
  peg$currPos = s0;
1918
1922
  s0 = peg$FAILED;
1919
1923
  }
1924
+ if (s0 === peg$FAILED) {
1925
+ s0 = peg$currPos;
1926
+ s1 = peg$parsesingle_quotation_mark();
1927
+ if (s1 !== peg$FAILED) {
1928
+ s2 = [];
1929
+ s3 = peg$parsechar_single_quote();
1930
+ while (s3 !== peg$FAILED) {
1931
+ s2.push(s3);
1932
+ s3 = peg$parsechar_single_quote();
1933
+ }
1934
+ if (s2 !== peg$FAILED) {
1935
+ s3 = peg$parsesingle_quotation_mark();
1936
+ if (s3 !== peg$FAILED) {
1937
+ peg$savedPos = s0;
1938
+ s1 = peg$c91(s2);
1939
+ s0 = s1;
1940
+ } else {
1941
+ peg$currPos = s0;
1942
+ s0 = peg$FAILED;
1943
+ }
1944
+ } else {
1945
+ peg$currPos = s0;
1946
+ s0 = peg$FAILED;
1947
+ }
1948
+ } else {
1949
+ peg$currPos = s0;
1950
+ s0 = peg$FAILED;
1951
+ }
1952
+ }
1920
1953
  peg$silentFails--;
1921
1954
  if (s0 === peg$FAILED) {
1922
1955
  s1 = peg$FAILED;
@@ -1926,115 +1959,284 @@ function peg$parse(input, options) {
1926
1959
  return s0;
1927
1960
  }
1928
1961
 
1929
- function peg$parsechar() {
1962
+ function peg$parsechar_double_quote() {
1930
1963
  var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
1931
1964
 
1932
- s0 = peg$parseunescaped();
1965
+ s0 = peg$parseunescaped_double_quote();
1933
1966
  if (s0 === peg$FAILED) {
1934
1967
  s0 = peg$currPos;
1935
1968
  s1 = peg$parseescape();
1936
1969
  if (s1 !== peg$FAILED) {
1937
- if (input.charCodeAt(peg$currPos) === 34) {
1938
- s2 = peg$c92;
1939
- peg$currPos++;
1970
+ s2 = peg$parsequotation_mark();
1971
+ if (s2 === peg$FAILED) {
1972
+ if (input.charCodeAt(peg$currPos) === 92) {
1973
+ s2 = peg$c92;
1974
+ peg$currPos++;
1975
+ } else {
1976
+ s2 = peg$FAILED;
1977
+ if (peg$silentFails === 0) { peg$fail(peg$c93); }
1978
+ }
1979
+ if (s2 === peg$FAILED) {
1980
+ if (input.charCodeAt(peg$currPos) === 47) {
1981
+ s2 = peg$c94;
1982
+ peg$currPos++;
1983
+ } else {
1984
+ s2 = peg$FAILED;
1985
+ if (peg$silentFails === 0) { peg$fail(peg$c95); }
1986
+ }
1987
+ if (s2 === peg$FAILED) {
1988
+ s2 = peg$currPos;
1989
+ if (input.charCodeAt(peg$currPos) === 98) {
1990
+ s3 = peg$c96;
1991
+ peg$currPos++;
1992
+ } else {
1993
+ s3 = peg$FAILED;
1994
+ if (peg$silentFails === 0) { peg$fail(peg$c97); }
1995
+ }
1996
+ if (s3 !== peg$FAILED) {
1997
+ peg$savedPos = s2;
1998
+ s3 = peg$c98();
1999
+ }
2000
+ s2 = s3;
2001
+ if (s2 === peg$FAILED) {
2002
+ s2 = peg$currPos;
2003
+ if (input.charCodeAt(peg$currPos) === 102) {
2004
+ s3 = peg$c99;
2005
+ peg$currPos++;
2006
+ } else {
2007
+ s3 = peg$FAILED;
2008
+ if (peg$silentFails === 0) { peg$fail(peg$c100); }
2009
+ }
2010
+ if (s3 !== peg$FAILED) {
2011
+ peg$savedPos = s2;
2012
+ s3 = peg$c101();
2013
+ }
2014
+ s2 = s3;
2015
+ if (s2 === peg$FAILED) {
2016
+ s2 = peg$currPos;
2017
+ if (input.charCodeAt(peg$currPos) === 110) {
2018
+ s3 = peg$c102;
2019
+ peg$currPos++;
2020
+ } else {
2021
+ s3 = peg$FAILED;
2022
+ if (peg$silentFails === 0) { peg$fail(peg$c103); }
2023
+ }
2024
+ if (s3 !== peg$FAILED) {
2025
+ peg$savedPos = s2;
2026
+ s3 = peg$c104();
2027
+ }
2028
+ s2 = s3;
2029
+ if (s2 === peg$FAILED) {
2030
+ s2 = peg$currPos;
2031
+ if (input.charCodeAt(peg$currPos) === 114) {
2032
+ s3 = peg$c105;
2033
+ peg$currPos++;
2034
+ } else {
2035
+ s3 = peg$FAILED;
2036
+ if (peg$silentFails === 0) { peg$fail(peg$c106); }
2037
+ }
2038
+ if (s3 !== peg$FAILED) {
2039
+ peg$savedPos = s2;
2040
+ s3 = peg$c107();
2041
+ }
2042
+ s2 = s3;
2043
+ if (s2 === peg$FAILED) {
2044
+ s2 = peg$currPos;
2045
+ if (input.charCodeAt(peg$currPos) === 116) {
2046
+ s3 = peg$c108;
2047
+ peg$currPos++;
2048
+ } else {
2049
+ s3 = peg$FAILED;
2050
+ if (peg$silentFails === 0) { peg$fail(peg$c109); }
2051
+ }
2052
+ if (s3 !== peg$FAILED) {
2053
+ peg$savedPos = s2;
2054
+ s3 = peg$c110();
2055
+ }
2056
+ s2 = s3;
2057
+ if (s2 === peg$FAILED) {
2058
+ s2 = peg$currPos;
2059
+ if (input.charCodeAt(peg$currPos) === 117) {
2060
+ s3 = peg$c111;
2061
+ peg$currPos++;
2062
+ } else {
2063
+ s3 = peg$FAILED;
2064
+ if (peg$silentFails === 0) { peg$fail(peg$c112); }
2065
+ }
2066
+ if (s3 !== peg$FAILED) {
2067
+ s4 = peg$currPos;
2068
+ s5 = peg$currPos;
2069
+ s6 = peg$parseHEXDIG();
2070
+ if (s6 !== peg$FAILED) {
2071
+ s7 = peg$parseHEXDIG();
2072
+ if (s7 !== peg$FAILED) {
2073
+ s8 = peg$parseHEXDIG();
2074
+ if (s8 !== peg$FAILED) {
2075
+ s9 = peg$parseHEXDIG();
2076
+ if (s9 !== peg$FAILED) {
2077
+ s6 = [s6, s7, s8, s9];
2078
+ s5 = s6;
2079
+ } else {
2080
+ peg$currPos = s5;
2081
+ s5 = peg$FAILED;
2082
+ }
2083
+ } else {
2084
+ peg$currPos = s5;
2085
+ s5 = peg$FAILED;
2086
+ }
2087
+ } else {
2088
+ peg$currPos = s5;
2089
+ s5 = peg$FAILED;
2090
+ }
2091
+ } else {
2092
+ peg$currPos = s5;
2093
+ s5 = peg$FAILED;
2094
+ }
2095
+ if (s5 !== peg$FAILED) {
2096
+ s4 = input.substring(s4, peg$currPos);
2097
+ } else {
2098
+ s4 = s5;
2099
+ }
2100
+ if (s4 !== peg$FAILED) {
2101
+ peg$savedPos = s2;
2102
+ s3 = peg$c113(s4);
2103
+ s2 = s3;
2104
+ } else {
2105
+ peg$currPos = s2;
2106
+ s2 = peg$FAILED;
2107
+ }
2108
+ } else {
2109
+ peg$currPos = s2;
2110
+ s2 = peg$FAILED;
2111
+ }
2112
+ }
2113
+ }
2114
+ }
2115
+ }
2116
+ }
2117
+ }
2118
+ }
2119
+ }
2120
+ if (s2 !== peg$FAILED) {
2121
+ peg$savedPos = s0;
2122
+ s1 = peg$c114(s2);
2123
+ s0 = s1;
1940
2124
  } else {
1941
- s2 = peg$FAILED;
1942
- if (peg$silentFails === 0) { peg$fail(peg$c93); }
2125
+ peg$currPos = s0;
2126
+ s0 = peg$FAILED;
1943
2127
  }
2128
+ } else {
2129
+ peg$currPos = s0;
2130
+ s0 = peg$FAILED;
2131
+ }
2132
+ }
2133
+
2134
+ return s0;
2135
+ }
2136
+
2137
+ function peg$parsechar_single_quote() {
2138
+ var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
2139
+
2140
+ s0 = peg$parseunescaped_single_quote();
2141
+ if (s0 === peg$FAILED) {
2142
+ s0 = peg$currPos;
2143
+ s1 = peg$parseescape();
2144
+ if (s1 !== peg$FAILED) {
2145
+ s2 = peg$parsesingle_quotation_mark();
1944
2146
  if (s2 === peg$FAILED) {
1945
2147
  if (input.charCodeAt(peg$currPos) === 92) {
1946
- s2 = peg$c94;
2148
+ s2 = peg$c92;
1947
2149
  peg$currPos++;
1948
2150
  } else {
1949
2151
  s2 = peg$FAILED;
1950
- if (peg$silentFails === 0) { peg$fail(peg$c95); }
2152
+ if (peg$silentFails === 0) { peg$fail(peg$c93); }
1951
2153
  }
1952
2154
  if (s2 === peg$FAILED) {
1953
2155
  if (input.charCodeAt(peg$currPos) === 47) {
1954
- s2 = peg$c96;
2156
+ s2 = peg$c94;
1955
2157
  peg$currPos++;
1956
2158
  } else {
1957
2159
  s2 = peg$FAILED;
1958
- if (peg$silentFails === 0) { peg$fail(peg$c97); }
2160
+ if (peg$silentFails === 0) { peg$fail(peg$c95); }
1959
2161
  }
1960
2162
  if (s2 === peg$FAILED) {
1961
2163
  s2 = peg$currPos;
1962
2164
  if (input.charCodeAt(peg$currPos) === 98) {
1963
- s3 = peg$c98;
2165
+ s3 = peg$c96;
1964
2166
  peg$currPos++;
1965
2167
  } else {
1966
2168
  s3 = peg$FAILED;
1967
- if (peg$silentFails === 0) { peg$fail(peg$c99); }
2169
+ if (peg$silentFails === 0) { peg$fail(peg$c97); }
1968
2170
  }
1969
2171
  if (s3 !== peg$FAILED) {
1970
2172
  peg$savedPos = s2;
1971
- s3 = peg$c100();
2173
+ s3 = peg$c98();
1972
2174
  }
1973
2175
  s2 = s3;
1974
2176
  if (s2 === peg$FAILED) {
1975
2177
  s2 = peg$currPos;
1976
2178
  if (input.charCodeAt(peg$currPos) === 102) {
1977
- s3 = peg$c101;
2179
+ s3 = peg$c99;
1978
2180
  peg$currPos++;
1979
2181
  } else {
1980
2182
  s3 = peg$FAILED;
1981
- if (peg$silentFails === 0) { peg$fail(peg$c102); }
2183
+ if (peg$silentFails === 0) { peg$fail(peg$c100); }
1982
2184
  }
1983
2185
  if (s3 !== peg$FAILED) {
1984
2186
  peg$savedPos = s2;
1985
- s3 = peg$c103();
2187
+ s3 = peg$c101();
1986
2188
  }
1987
2189
  s2 = s3;
1988
2190
  if (s2 === peg$FAILED) {
1989
2191
  s2 = peg$currPos;
1990
2192
  if (input.charCodeAt(peg$currPos) === 110) {
1991
- s3 = peg$c104;
2193
+ s3 = peg$c102;
1992
2194
  peg$currPos++;
1993
2195
  } else {
1994
2196
  s3 = peg$FAILED;
1995
- if (peg$silentFails === 0) { peg$fail(peg$c105); }
2197
+ if (peg$silentFails === 0) { peg$fail(peg$c103); }
1996
2198
  }
1997
2199
  if (s3 !== peg$FAILED) {
1998
2200
  peg$savedPos = s2;
1999
- s3 = peg$c106();
2201
+ s3 = peg$c104();
2000
2202
  }
2001
2203
  s2 = s3;
2002
2204
  if (s2 === peg$FAILED) {
2003
2205
  s2 = peg$currPos;
2004
2206
  if (input.charCodeAt(peg$currPos) === 114) {
2005
- s3 = peg$c107;
2207
+ s3 = peg$c105;
2006
2208
  peg$currPos++;
2007
2209
  } else {
2008
2210
  s3 = peg$FAILED;
2009
- if (peg$silentFails === 0) { peg$fail(peg$c108); }
2211
+ if (peg$silentFails === 0) { peg$fail(peg$c106); }
2010
2212
  }
2011
2213
  if (s3 !== peg$FAILED) {
2012
2214
  peg$savedPos = s2;
2013
- s3 = peg$c109();
2215
+ s3 = peg$c107();
2014
2216
  }
2015
2217
  s2 = s3;
2016
2218
  if (s2 === peg$FAILED) {
2017
2219
  s2 = peg$currPos;
2018
2220
  if (input.charCodeAt(peg$currPos) === 116) {
2019
- s3 = peg$c110;
2221
+ s3 = peg$c108;
2020
2222
  peg$currPos++;
2021
2223
  } else {
2022
2224
  s3 = peg$FAILED;
2023
- if (peg$silentFails === 0) { peg$fail(peg$c111); }
2225
+ if (peg$silentFails === 0) { peg$fail(peg$c109); }
2024
2226
  }
2025
2227
  if (s3 !== peg$FAILED) {
2026
2228
  peg$savedPos = s2;
2027
- s3 = peg$c112();
2229
+ s3 = peg$c110();
2028
2230
  }
2029
2231
  s2 = s3;
2030
2232
  if (s2 === peg$FAILED) {
2031
2233
  s2 = peg$currPos;
2032
2234
  if (input.charCodeAt(peg$currPos) === 117) {
2033
- s3 = peg$c113;
2235
+ s3 = peg$c111;
2034
2236
  peg$currPos++;
2035
2237
  } else {
2036
2238
  s3 = peg$FAILED;
2037
- if (peg$silentFails === 0) { peg$fail(peg$c114); }
2239
+ if (peg$silentFails === 0) { peg$fail(peg$c112); }
2038
2240
  }
2039
2241
  if (s3 !== peg$FAILED) {
2040
2242
  s4 = peg$currPos;
@@ -2072,7 +2274,7 @@ function peg$parse(input, options) {
2072
2274
  }
2073
2275
  if (s4 !== peg$FAILED) {
2074
2276
  peg$savedPos = s2;
2075
- s3 = peg$c115(s4);
2277
+ s3 = peg$c113(s4);
2076
2278
  s2 = s3;
2077
2279
  } else {
2078
2280
  peg$currPos = s2;
@@ -2092,7 +2294,7 @@ function peg$parse(input, options) {
2092
2294
  }
2093
2295
  if (s2 !== peg$FAILED) {
2094
2296
  peg$savedPos = s0;
2095
- s1 = peg$c116(s2);
2297
+ s1 = peg$c114(s2);
2096
2298
  s0 = s1;
2097
2299
  } else {
2098
2300
  peg$currPos = s0;
@@ -2111,11 +2313,11 @@ function peg$parse(input, options) {
2111
2313
  var s0;
2112
2314
 
2113
2315
  if (input.charCodeAt(peg$currPos) === 92) {
2114
- s0 = peg$c94;
2316
+ s0 = peg$c92;
2115
2317
  peg$currPos++;
2116
2318
  } else {
2117
2319
  s0 = peg$FAILED;
2118
- if (peg$silentFails === 0) { peg$fail(peg$c95); }
2320
+ if (peg$silentFails === 0) { peg$fail(peg$c93); }
2119
2321
  }
2120
2322
 
2121
2323
  return s0;
@@ -2125,21 +2327,21 @@ function peg$parse(input, options) {
2125
2327
  var s0;
2126
2328
 
2127
2329
  if (input.charCodeAt(peg$currPos) === 34) {
2128
- s0 = peg$c92;
2330
+ s0 = peg$c115;
2129
2331
  peg$currPos++;
2130
2332
  } else {
2131
2333
  s0 = peg$FAILED;
2132
- if (peg$silentFails === 0) { peg$fail(peg$c93); }
2334
+ if (peg$silentFails === 0) { peg$fail(peg$c116); }
2133
2335
  }
2134
2336
 
2135
2337
  return s0;
2136
2338
  }
2137
2339
 
2138
- function peg$parseunescaped() {
2340
+ function peg$parsesingle_quotation_mark() {
2139
2341
  var s0;
2140
2342
 
2141
- if (peg$c117.test(input.charAt(peg$currPos))) {
2142
- s0 = input.charAt(peg$currPos);
2343
+ if (input.charCodeAt(peg$currPos) === 39) {
2344
+ s0 = peg$c117;
2143
2345
  peg$currPos++;
2144
2346
  } else {
2145
2347
  s0 = peg$FAILED;
@@ -2149,7 +2351,7 @@ function peg$parse(input, options) {
2149
2351
  return s0;
2150
2352
  }
2151
2353
 
2152
- function peg$parseDIGIT() {
2354
+ function peg$parseunescaped_double_quote() {
2153
2355
  var s0;
2154
2356
 
2155
2357
  if (peg$c119.test(input.charAt(peg$currPos))) {
@@ -2163,7 +2365,7 @@ function peg$parse(input, options) {
2163
2365
  return s0;
2164
2366
  }
2165
2367
 
2166
- function peg$parseHEXDIG() {
2368
+ function peg$parseunescaped_single_quote() {
2167
2369
  var s0;
2168
2370
 
2169
2371
  if (peg$c121.test(input.charAt(peg$currPos))) {
@@ -2177,6 +2379,34 @@ function peg$parse(input, options) {
2177
2379
  return s0;
2178
2380
  }
2179
2381
 
2382
+ function peg$parseDIGIT() {
2383
+ var s0;
2384
+
2385
+ if (peg$c123.test(input.charAt(peg$currPos))) {
2386
+ s0 = input.charAt(peg$currPos);
2387
+ peg$currPos++;
2388
+ } else {
2389
+ s0 = peg$FAILED;
2390
+ if (peg$silentFails === 0) { peg$fail(peg$c124); }
2391
+ }
2392
+
2393
+ return s0;
2394
+ }
2395
+
2396
+ function peg$parseHEXDIG() {
2397
+ var s0;
2398
+
2399
+ if (peg$c125.test(input.charAt(peg$currPos))) {
2400
+ s0 = input.charAt(peg$currPos);
2401
+ peg$currPos++;
2402
+ } else {
2403
+ s0 = peg$FAILED;
2404
+ if (peg$silentFails === 0) { peg$fail(peg$c126); }
2405
+ }
2406
+
2407
+ return s0;
2408
+ }
2409
+
2180
2410
  peg$result = peg$startRuleFunction();
2181
2411
 
2182
2412
  if (peg$result !== peg$FAILED && peg$currPos === input.length) {
@@ -212,13 +212,32 @@ zero
212
212
  // ----- 7. Strings -----
213
213
 
214
214
  string "string"
215
- = quotation_mark chars:char* quotation_mark { return chars.join(""); }
215
+ = quotation_mark chars:char_double_quote* quotation_mark { return chars.join(""); }
216
+ / single_quotation_mark chars:char_single_quote* single_quotation_mark { return chars.join(""); }
216
217
 
217
- char
218
- = unescaped
218
+ char_double_quote
219
+ = unescaped_double_quote
219
220
  / escape
220
221
  sequence:(
221
- '"'
222
+ quotation_mark
223
+ / "\\"
224
+ / "/"
225
+ / "b" { return "\b"; }
226
+ / "f" { return "\f"; }
227
+ / "n" { return "\n"; }
228
+ / "r" { return "\r"; }
229
+ / "t" { return "\t"; }
230
+ / "u" digits:$(HEXDIG HEXDIG HEXDIG HEXDIG) {
231
+ return String.fromCharCode(parseInt(digits, 16));
232
+ }
233
+ )
234
+ { return sequence; }
235
+
236
+ char_single_quote
237
+ = unescaped_single_quote
238
+ / escape
239
+ sequence:(
240
+ single_quotation_mark
222
241
  / "\\"
223
242
  / "/"
224
243
  / "b" { return "\b"; }
@@ -238,8 +257,14 @@ escape
238
257
  quotation_mark
239
258
  = '"'
240
259
 
241
- unescaped
242
- = [^\0-\x1F\x22\x5C]
260
+ single_quotation_mark
261
+ = "\x27"
262
+
263
+ // End on quote, or special character? BUT, allow \n
264
+ unescaped_double_quote
265
+ = [^\0-\x09\x0B-\x1F\x22\x5C]
266
+ unescaped_single_quote
267
+ = [^\0-\x09\x0B-\x1F\x27\x5C]
243
268
 
244
269
  // ----- Core ABNF Rules -----
245
270
 
@@ -427,13 +427,14 @@ async function generateAndVerifyParser() {
427
427
  var module = { exports: {} };
428
428
  eval(parserSource);
429
429
  const parser = module.exports as any;
430
- function verify(text: string) {
430
+ function verify(text: string, forcedObj?: unknown) {
431
431
  var parsed = parser.parse(text);
432
432
  var result = JSON.stringify(parsed);
433
- let realResult = JSON.stringify(eval("(" + text + ")"));
433
+ let realResult = forcedObj ?? JSON.stringify(eval("(" + text + ")"));
434
434
  if (result !== realResult) {
435
435
  throw new Error(`Failed to parse: ${text} should be ${realResult}, was ${result}`);
436
436
  }
437
+ console.log("Parsed correctly: ", text);
437
438
  }
438
439
 
439
440
  verify(`
@@ -467,5 +468,19 @@ async function generateAndVerifyParser() {
467
468
  // list3: [3],
468
469
  }
469
470
  `);
471
+ // Multiline double quote strings
472
+ verify(`
473
+ {
474
+ value: "a
475
+ b"
476
+ }
477
+ `, JSON.stringify({ value: "a\nb" }));
478
+
479
+ // Single quotes
480
+ verify(`
481
+ {
482
+ value: 'a'
483
+ }
484
+ `);
470
485
  }
471
486
  //generateAndVerifyParser().catch(console.error).finally(() => process.exit());