/// <summary> /// run the reader /// </summary> public bool Process() { if (_input != null) { try { otCSVLexer _lexer = new otCSVLexer(_input); _lexer.Delimiter = _delimiter; // wrap a token-stream around the lexer Antlr4.Runtime.CommonTokenStream tokens = new Antlr4.Runtime.CommonTokenStream(_lexer); // create the aParser otCSVParser aParser = new otCSVParser(tokens); aParser.RemoveErrorListeners(); aParser.AddErrorListener(new ErrorListener()); otCSVParser.CsvbufferContext aTree = aParser.csvbuffer(); // walk the parse tree DataBuilder aListener = new DataBuilder(aParser); Antlr4.Runtime.Tree.ParseTreeWalker.Default.Walk(aListener, aTree); // result _header = aListener.Header; _rows = aListener.Rows; return(true); } catch (Exception ex) { return(false); } } return(false); }
/// <summary> /// Enters the Csvbuffer Rule -> new rows /// </summary> /// <param name="ctx"></param> public override void EnterCsvbuffer(otCSVParser.CsvbufferContext ctx) { _rows = new List <String[]>(); }