예제 #1
0
        string[]  parse(string text)
        {
            AntlrInputStream  inputStream       = new AntlrInputStream(text);
            CSVLexer          lexer             = new CSVLexer(inputStream);
            CommonTokenStream commonTokenStream = new CommonTokenStream(lexer);
            CSVParser         parser            = new CSVParser(commonTokenStream);

            CSVParser.CsvFileContext csvCtx = parser.csvFile();
            CsvFileVisitor           v      = new CsvFileVisitor();

            return(v.getValues(csvCtx));
        }
예제 #2
0
            public string[] getValues(CSVParser.CsvFileContext context)
            {
                CSVParser.RowContext[] rowContexts = context.row();

                string[] result = null;

                if (rowContexts.Length > 0)
                {
                    CSVParser.FieldContext[] fca = rowContexts[0].field();
                    result = new string[fca.Length];
                    int i = 0;
                    foreach (CSVParser.FieldContext fc in fca)
                    {
                        result[i++] = fc.GetText();
                    }
                }

                return(result);
            }
예제 #3
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="CSVParser.csvFile"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitCsvFile([NotNull] CSVParser.CsvFileContext context)
 {
 }