@@ -211,6 +211,93 @@ func TestLexer_Scan(t *testing.T) {
211
211
columnEnd : 11 ,
212
212
},
213
213
}},
214
+ }, {
215
+ name : "newline before unquoted is skipped" ,
216
+ input : "\n hello" ,
217
+ expected : []token {{
218
+ kind : tokenUnquoted ,
219
+ value : "hello" ,
220
+ position : position {
221
+ offsetStart : 1 ,
222
+ offsetEnd : 6 ,
223
+ columnStart : 1 ,
224
+ columnEnd : 6 ,
225
+ },
226
+ }},
227
+ }, {
228
+ name : "newline after unquoted is skipped" ,
229
+ input : "hello\n " ,
230
+ expected : []token {{
231
+ kind : tokenUnquoted ,
232
+ value : "hello" ,
233
+ position : position {
234
+ offsetStart : 0 ,
235
+ offsetEnd : 5 ,
236
+ columnStart : 0 ,
237
+ columnEnd : 5 ,
238
+ },
239
+ }},
240
+ }, {
241
+ name : "carriage return before unquoted is skipped" ,
242
+ input : "\r hello" ,
243
+ expected : []token {{
244
+ kind : tokenUnquoted ,
245
+ value : "hello" ,
246
+ position : position {
247
+ offsetStart : 1 ,
248
+ offsetEnd : 6 ,
249
+ columnStart : 1 ,
250
+ columnEnd : 6 ,
251
+ },
252
+ }},
253
+ }, {
254
+ name : "space before unquoted is skipped" ,
255
+ input : " hello" ,
256
+ expected : []token {{
257
+ kind : tokenUnquoted ,
258
+ value : "hello" ,
259
+ position : position {
260
+ offsetStart : 1 ,
261
+ offsetEnd : 6 ,
262
+ columnStart : 1 ,
263
+ columnEnd : 6 ,
264
+ },
265
+ }},
266
+ }, {
267
+ name : "space after unquoted is skipped" ,
268
+ input : "hello " ,
269
+ expected : []token {{
270
+ kind : tokenUnquoted ,
271
+ value : "hello" ,
272
+ position : position {
273
+ offsetStart : 0 ,
274
+ offsetEnd : 5 ,
275
+ columnStart : 0 ,
276
+ columnEnd : 5 ,
277
+ },
278
+ }},
279
+ }, {
280
+ name : "newline between two unquoted is skipped" ,
281
+ input : "hello\n world" ,
282
+ expected : []token {{
283
+ kind : tokenUnquoted ,
284
+ value : "hello" ,
285
+ position : position {
286
+ offsetStart : 0 ,
287
+ offsetEnd : 5 ,
288
+ columnStart : 0 ,
289
+ columnEnd : 5 ,
290
+ },
291
+ }, {
292
+ kind : tokenUnquoted ,
293
+ value : "world" ,
294
+ position : position {
295
+ offsetStart : 6 ,
296
+ offsetEnd : 11 ,
297
+ columnStart : 6 ,
298
+ columnEnd : 11 ,
299
+ },
300
+ }},
214
301
}, {
215
302
name : "unquoted $" ,
216
303
input : "$" ,
@@ -424,6 +511,19 @@ func TestLexer_Scan(t *testing.T) {
424
511
columnEnd : 15 ,
425
512
},
426
513
}},
514
+ }, {
515
+ name : "quoted escape sequence" ,
516
+ input : "\" \\ n\" " ,
517
+ expected : []token {{
518
+ kind : tokenQuoted ,
519
+ value : "\" \\ n\" " ,
520
+ position : position {
521
+ offsetStart : 0 ,
522
+ offsetEnd : 4 ,
523
+ columnStart : 0 ,
524
+ columnEnd : 4 ,
525
+ },
526
+ }},
427
527
}, {
428
528
name : "equals operator" ,
429
529
input : "=" ,
@@ -484,20 +584,6 @@ func TestLexer_Scan(t *testing.T) {
484
584
name : "another invalid operator" ,
485
585
input : "~" ,
486
586
err : "0:1: ~: invalid input" ,
487
- }, {
488
- name : "unexpected ! after unquoted" ,
489
- input : "hello!" ,
490
- expected : []token {{
491
- kind : tokenUnquoted ,
492
- value : "hello" ,
493
- position : position {
494
- offsetStart : 0 ,
495
- offsetEnd : 5 ,
496
- columnStart : 0 ,
497
- columnEnd : 5 ,
498
- },
499
- }},
500
- err : "5:6: unexpected end of input, expected one of '=~'" ,
501
587
}, {
502
588
name : "unexpected ! after operator" ,
503
589
input : "=!" ,
@@ -526,6 +612,56 @@ func TestLexer_Scan(t *testing.T) {
526
612
},
527
613
}},
528
614
err : "2:3: !: expected one of '=~'" ,
615
+ }, {
616
+ name : "unexpected ! after unquoted" ,
617
+ input : "hello!" ,
618
+ expected : []token {{
619
+ kind : tokenUnquoted ,
620
+ value : "hello" ,
621
+ position : position {
622
+ offsetStart : 0 ,
623
+ offsetEnd : 5 ,
624
+ columnStart : 0 ,
625
+ columnEnd : 5 ,
626
+ },
627
+ }},
628
+ err : "5:6: unexpected end of input, expected one of '=~'" ,
629
+ }, {
630
+ name : "invalid escape sequence" ,
631
+ input : "\\ n" ,
632
+ err : "0:1: \\ : invalid input" ,
633
+ }, {
634
+ name : "invalid escape sequence before unquoted" ,
635
+ input : "\\ nhello" ,
636
+ err : "0:1: \\ : invalid input" ,
637
+ }, {
638
+ name : "invalid escape sequence after unquoted" ,
639
+ input : "hello\\ n" ,
640
+ expected : []token {{
641
+ kind : tokenUnquoted ,
642
+ value : "hello" ,
643
+ position : position {
644
+ offsetStart : 0 ,
645
+ offsetEnd : 5 ,
646
+ columnStart : 0 ,
647
+ columnEnd : 5 ,
648
+ },
649
+ }},
650
+ err : "5:6: \\ : invalid input" ,
651
+ }, {
652
+ name : "another invalid escape sequence after unquoted" ,
653
+ input : "hello\\ r" ,
654
+ expected : []token {{
655
+ kind : tokenUnquoted ,
656
+ value : "hello" ,
657
+ position : position {
658
+ offsetStart : 0 ,
659
+ offsetEnd : 5 ,
660
+ columnStart : 0 ,
661
+ columnEnd : 5 ,
662
+ },
663
+ }},
664
+ err : "5:6: \\ : invalid input" ,
529
665
}, {
530
666
name : "unterminated quoted" ,
531
667
input : "\" hello" ,
0 commit comments