@@ -47,7 +47,6 @@ public abstract class BaseRuntimeTest {
47
47
final static Set <String > sections = new HashSet <>(Arrays .asList (
48
48
"notes" , "type" , "grammar" , "slaveGrammar" , "start" , "input" , "output" , "errors" , "flags" , "skip"
49
49
));
50
- final static Pattern linePattern = Pattern .compile ("([^\\ r\\ n]*)(\r ?\n )" );
51
50
52
51
@ BeforeClass
53
52
public static void startHeartbeatToAvoidTimeout () {
@@ -367,6 +366,12 @@ public static RuntimeTestDescriptor[] getRuntimeTestDescriptors(String group, St
367
366
System .err .println ("Can't read descriptor file " +fname );
368
367
}
369
368
}
369
+
370
+ if (group .equals ("LexerExec" )) {
371
+ descriptors .add (ExtraTests .getLineSeparatorLfTest (targetName ));
372
+ descriptors .add (ExtraTests .getLineSeparatorCrLfTest (targetName ));
373
+ }
374
+
370
375
return descriptors .toArray (new RuntimeTestDescriptor [0 ]);
371
376
}
372
377
@@ -424,13 +429,9 @@ public static UniversalRuntimeTestDescriptor readDescriptor(String dtext)
424
429
StringBuilder currentValue = new StringBuilder ();
425
430
426
431
List <Pair <String , String >> pairs = new ArrayList <>();
432
+ String [] lines = dtext .split ("\r ?\n " );
427
433
428
- Matcher matcher = linePattern .matcher (dtext );
429
- boolean preserveSeparator = false ;
430
- int lastEnd = 0 ;
431
- while (matcher .find ()) {
432
- String line = matcher .group (1 );
433
- lastEnd = matcher .end ();
434
+ for (String line : lines ) {
434
435
boolean newSection = false ;
435
436
String sectionName = null ;
436
437
if (line .startsWith ("[" ) && line .length () > 2 ) {
@@ -439,19 +440,17 @@ public static UniversalRuntimeTestDescriptor readDescriptor(String dtext)
439
440
}
440
441
441
442
if (newSection ) {
442
- if (currentField != null ) {
443
+ if (currentField != null ) {
443
444
pairs .add (new Pair <>(currentField , currentValue .toString ()));
444
445
}
445
- preserveSeparator = sectionName .equals ("input" );
446
446
currentField = sectionName ;
447
447
currentValue .setLength (0 );
448
448
}
449
449
else {
450
450
currentValue .append (line );
451
- currentValue .append (preserveSeparator ? matcher . group ( 2 ) : "\n " );
451
+ currentValue .append ("\n " );
452
452
}
453
453
}
454
- currentValue .append (dtext .substring (lastEnd ));
455
454
pairs .add (new Pair <>(currentField , currentValue .toString ()));
456
455
457
456
UniversalRuntimeTestDescriptor d = new UniversalRuntimeTestDescriptor ();
0 commit comments