/**
 * @license
 * Copyright 2017 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

package foam.lib.csv;

import foam.lib.parse.*;

public class CSVNewlineParser
  implements Parser
{

  static Parser delegate__ = new Alt(
    new Seq0(Literal.create("\\"), Literal.create("r"), Literal.create("\\"), Literal.create("n")),
    new Seq0(Literal.create("\\"), Literal.create("r")),
    new Seq0(Literal.create("\\"), Literal.create("n"))
  );

  public PStream parse(PStream ps, ParserContext x) {
    if ( ps == null ) return null;

    ps = ps.apply(delegate__, x);
    if ( ps == null ) return null;

    return ps.setValue("\n");
  }
}

@@ -257,33 +257,24 @@
 ew Alt(%0A    
-new Seq0(
 Literal.crea
@@ -283,90 +283,20 @@
 (%22%5C%5C
-%22), Literal.create(%22r%22), Literal.create(%22%5C%5C%22), Literal.create(%22
+r%5C%5C
 n%22)
-)
 ,%0A    
-new Seq0(
 Lite
@@ -313,89 +313,38 @@
 (%22%5C%5C
-%22), Literal.create(%22r%22)),%0A    new Seq0(Literal.create(%22%5C%5C%22), Literal.create(%22
+r%22),%0A    Literal.create(%22%5C%5C
 n%22)
-)
 %0A  )

Simplify and speedup CSVNewlineParser.