Mercurial Hosting > luan
comparison src/luan/modules/parsers/Csv.java @ 1267:9fa8b8389578
add LuanTable.luan;
support metatable __gc();
add luan.sql;
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 12 Nov 2018 02:10:41 -0700 |
parents | 88b5b81cad4a |
children | f41919741100 |
comparison
equal
deleted
inserted
replaced
1266:05934fbf635a | 1267:9fa8b8389578 |
---|---|
1 package luan.modules.parsers; | 1 package luan.modules.parsers; |
2 | 2 |
3 import luan.LuanState; | |
3 import luan.LuanTable; | 4 import luan.LuanTable; |
4 import luan.lib.parser.Parser; | 5 import luan.lib.parser.Parser; |
5 import luan.lib.parser.ParseException; | 6 import luan.lib.parser.ParseException; |
6 | 7 |
7 | 8 |
8 public final class Csv { | 9 public final class Csv { |
9 | 10 |
10 public static LuanTable toList(String line) throws ParseException { | 11 public static LuanTable toList(LuanState luan,String line) throws ParseException { |
11 return new Csv(line).parse(); | 12 return new Csv(line).parse(luan); |
12 } | 13 } |
13 | 14 |
14 private final Parser parser; | 15 private final Parser parser; |
15 | 16 |
16 private Csv(String line) { | 17 private Csv(String line) { |
19 | 20 |
20 private ParseException exception(String msg) { | 21 private ParseException exception(String msg) { |
21 return new ParseException(parser,msg); | 22 return new ParseException(parser,msg); |
22 } | 23 } |
23 | 24 |
24 private LuanTable parse() throws ParseException { | 25 private LuanTable parse(LuanState luan) throws ParseException { |
25 LuanTable list = new LuanTable(); | 26 LuanTable list = new LuanTable(luan); |
26 while(true) { | 27 while(true) { |
27 Spaces(); | 28 Spaces(); |
28 String field = parseField(); | 29 String field = parseField(); |
29 list.rawPut(list.rawLength()+1,field); | 30 list.rawPut(list.rawLength()+1,field); |
30 Spaces(); | 31 Spaces(); |