# HG changeset patch # User František Kučera # Date 1410024982 -7200 # Node ID 547f1246fe352c58ad8638cc35a75023435b420a # Parent a4335757acf1a39bba028053c1a6a473c9bc7613 in-ini: quoted/apostrophed values might have comments diff -r a4335757acf1 -r 547f1246fe35 java/alt2xml-in-ini/src/cz/frantovo/alt2xml/in/ini/Reader.java --- a/java/alt2xml-in-ini/src/cz/frantovo/alt2xml/in/ini/Reader.java Sat Sep 06 19:10:52 2014 +0200 +++ b/java/alt2xml-in-ini/src/cz/frantovo/alt2xml/in/ini/Reader.java Sat Sep 06 19:36:22 2014 +0200 @@ -112,6 +112,7 @@ COMMENT("\\s*(;|#)\\s*(.*)") { @Override public void processLine(LineContext lc, FileContext fc) throws SAXException { + // TODO: comment → LexicalHandler log.log(Level.FINER, "Comment: {0}", lc.matcher.group(2)); } @@ -128,7 +129,9 @@ }, ENTRY( "\\s*([^=\\s]+)\\s*=\\s*\"([^\"]+)\"", // quoted value → include spaces - "\\s*([^=\\s]+)\\s*=\\s*'([^']+)'", // apostrophed value → include spaces + "\\s*([^=\\s]+)\\s*=\\s*\"([^\"]+)\"\\s*(;|#)*\\s*(.*)", // quoted value → include spaces | with comment + "\\s*([^=\\s]+)\\s*=\\s*'([^']+)'", // apostrophed value → include spaces | with comment + "\\s*([^=\\s]+)\\s*=\\s*'([^']+)'\\s*(;|#)*\\s*(.*)", // apostrophed value → include spaces "\\s*([^=\\s]+)\\s*=\\s*(.+)" // unquoted value → strip spaces ) { @Override @@ -136,6 +139,12 @@ String key = lc.matcher.group(1); String value = lc.matcher.group(2); + if (lc.matcher.groupCount() == 4) { + String comment = lc.matcher.group(4); + // TODO: comment → LexicalHandler + log.log(Level.WARNING, "Comment for entry „{0}“ is: {1}", new Object[]{key, comment}); + } + fc.contentHandler.indentation(2); fc.contentHandler.textElement(value, null, null, key, null); fc.contentHandler.lineBreak(); @@ -156,6 +165,7 @@ for (Pattern pattern : patterns) { Matcher m = pattern.matcher(currentLine); if (m.matches()) { + log.log(Level.FINEST, "Line „{0}“ matches pattern „{1}“", new Object[]{currentLine, pattern}); processLine(new LineContext(m), fileContext); return true; }