comparison src/luan/modules/parsers/Css.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
6 import goodjava.parser.Parser; 6 import goodjava.parser.Parser;
7 7
8 8
9 public final class Css { 9 public final class Css {
10 10
11 public static LuanTable style(Luan luan,String text) { 11 public static LuanTable style(String text) {
12 try { 12 try {
13 return new Css(luan,text).parseStyle(); 13 return new Css(text).parseStyle();
14 } catch(LuanException e) { 14 } catch(LuanException e) {
15 throw new RuntimeException(e); 15 throw new RuntimeException(e);
16 } 16 }
17 } 17 }
18 18
19 private final Luan luan;
20 private final Parser parser; 19 private final Parser parser;
21 20
22 private Css(Luan luan,String text) { 21 private Css(String text) {
23 this.luan = luan;
24 this.parser = new Parser(text); 22 this.parser = new Parser(text);
25 } 23 }
26 24
27 private LuanTable parseStyle() throws LuanException { 25 private LuanTable parseStyle() throws LuanException {
28 LuanTable tbl = new LuanTable(luan); 26 LuanTable tbl = new LuanTable();
29 while( matchSpace() ); 27 while( matchSpace() );
30 while( !parser.endOfInput() ) { 28 while( !parser.endOfInput() ) {
31 int start = parser.currentIndex(); 29 int start = parser.currentIndex();
32 if( !matchPropertyChar() ) 30 if( !matchPropertyChar() )
33 return null; 31 return null;
40 38
41 start = parser.currentIndex(); 39 start = parser.currentIndex();
42 while( !parser.endOfInput() && parser.noneOf(";") ); 40 while( !parser.endOfInput() && parser.noneOf(";") );
43 String val = parser.textFrom(start).trim(); 41 String val = parser.textFrom(start).trim();
44 42
45 tbl.put(prop,val); 43 tbl.rawPut(prop,val);
46 parser.match(';'); 44 parser.match(';');
47 while( matchSpace() ); 45 while( matchSpace() );
48 } 46 }
49 return tbl; 47 return tbl;
50 } 48 }