diff --git a/README.md b/README.md index 52fe71e..735e392 100644 --- a/README.md +++ b/README.md @@ -59,9 +59,9 @@ dmd -i program.d - Keys - Sections - Default section +- Comments ### Todo -- Comments - Key referencing - Testing D: diff --git a/initial.d b/initial.d index a338af3..7f4a585 100644 --- a/initial.d +++ b/initial.d @@ -298,6 +298,8 @@ locate(size_t l, size_t c) + + The following rules apply when parsing: + $(UL + + $(LI if a hash character `#` is found at the beginning of a line, + + the rest of the line is ignored) + $(LI if a left square bracket character `[` is found at + the beginning of a line, the line is considered a + section heading) @@ -340,6 +342,7 @@ readINI(ref INIUnit ini, string data) section = ini.defaultSection; + nextline: foreach (size_t ln, string line; data.splitLines()) { line = line.strip(); if (line.length == 0) @@ -349,6 +352,14 @@ readINI(ref INIUnit ini, string data) text = key = value = ""; foreach (size_t cn, char ch; line) { switch (ch) { + /* comment? */ + case '#': + if (cn == 0) + continue nextline; + + text ~= ch; + break; + /* beginning of a section heading? */ case '[': if (cn == 0) /* beginning of line? */