comparison src/luan/modules/parsers/Csv.java @ 1333:25746915a241

merge Luan and LuanState
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 12 Feb 2019 22:33:40 -0700
parents f41919741100
children 27efb1fcbcb5
comparison
equal deleted inserted replaced
1332:11b7e11f9ed5 1333:25746915a241
1 package luan.modules.parsers; 1 package luan.modules.parsers;
2 2
3 import luan.LuanState; 3 import luan.Luan;
4 import luan.LuanTable; 4 import luan.LuanTable;
5 import luan.LuanException; 5 import luan.LuanException;
6 import luan.lib.parser.Parser; 6 import luan.lib.parser.Parser;
7 import luan.lib.parser.ParseException; 7 import luan.lib.parser.ParseException;
8 8
9 9
10 public final class Csv { 10 public final class Csv {
11 11
12 public static LuanTable toList(LuanState luan,String line) throws ParseException { 12 public static LuanTable toList(Luan luan,String line) throws ParseException {
13 try { 13 try {
14 return new Csv(line).parse(luan); 14 return new Csv(line).parse(luan);
15 } catch(LuanException e) { 15 } catch(LuanException e) {
16 throw new RuntimeException(e); 16 throw new RuntimeException(e);
17 } 17 }
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(LuanState luan) throws ParseException, LuanException { 30 private LuanTable parse(Luan luan) throws ParseException, LuanException {
31 LuanTable list = new LuanTable(luan); 31 LuanTable list = new LuanTable(luan);
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.put(list.rawLength()+1,field);