comparison src/luan/modules/parsers/Csv.java @ 1562:b89212fd04b5

remove table.luan
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 08 Nov 2020 16:50:59 -0700
parents 27efb1fcbcb5
children
comparison
equal deleted inserted replaced
1561:e1a13e707bf3 1562:b89212fd04b5
7 import goodjava.parser.ParseException; 7 import goodjava.parser.ParseException;
8 8
9 9
10 public final class Csv { 10 public final class Csv {
11 11
12 public static LuanTable toList(Luan luan,String line) throws ParseException { 12 public static LuanTable toList(String line) throws ParseException {
13 try { 13 try {
14 return new Csv(line).parse(luan); 14 return new Csv(line).parse();
15 } catch(LuanException e) { 15 } catch(LuanException e) {
16 throw new RuntimeException(e); 16 throw new RuntimeException(e);
17 } 17 }
18 } 18 }
19 19
25 25
26 private ParseException exception(String msg) { 26 private ParseException exception(String msg) {
27 return new ParseException(parser,msg); 27 return new ParseException(parser,msg);
28 } 28 }
29 29
30 private LuanTable parse(Luan luan) throws ParseException, LuanException { 30 private LuanTable parse() throws ParseException, LuanException {
31 LuanTable list = new LuanTable(luan); 31 LuanTable list = new LuanTable();
32 while(true) { 32 while(true) {
33 Spaces(); 33 Spaces();
34 String field = parseField(); 34 String field = parseField();
35 list.put(list.rawLength()+1,field); 35 list.rawPut(list.rawLength()+1,field);
36 Spaces(); 36 Spaces();
37 if( parser.endOfInput() ) 37 if( parser.endOfInput() )
38 return list; 38 return list;
39 if( !parser.match(',') ) 39 if( !parser.match(',') )
40 throw exception("unexpected char"); 40 throw exception("unexpected char");