implement basic comments
This commit is contained in:
parent
7c2616c004
commit
62a1cdc491
2 changed files with 12 additions and 1 deletions
|
@ -59,9 +59,9 @@ dmd -i program.d
|
||||||
- Keys
|
- Keys
|
||||||
- Sections
|
- Sections
|
||||||
- Default section
|
- Default section
|
||||||
|
- Comments
|
||||||
|
|
||||||
### Todo
|
### Todo
|
||||||
|
|
||||||
- Comments
|
|
||||||
- Key referencing
|
- Key referencing
|
||||||
- Testing D:
|
- Testing D:
|
||||||
|
|
11
initial.d
11
initial.d
|
@ -298,6 +298,8 @@ locate(size_t l, size_t c)
|
||||||
+
|
+
|
||||||
+ The following rules apply when parsing:
|
+ The following rules apply when parsing:
|
||||||
+ $(UL
|
+ $(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
|
+ $(LI if a left square bracket character `[` is found at
|
||||||
+ the beginning of a line, the line is considered a
|
+ the beginning of a line, the line is considered a
|
||||||
+ section heading)
|
+ section heading)
|
||||||
|
@ -340,6 +342,7 @@ readINI(ref INIUnit ini, string data)
|
||||||
|
|
||||||
section = ini.defaultSection;
|
section = ini.defaultSection;
|
||||||
|
|
||||||
|
nextline:
|
||||||
foreach (size_t ln, string line; data.splitLines()) {
|
foreach (size_t ln, string line; data.splitLines()) {
|
||||||
line = line.strip();
|
line = line.strip();
|
||||||
if (line.length == 0)
|
if (line.length == 0)
|
||||||
|
@ -349,6 +352,14 @@ readINI(ref INIUnit ini, string data)
|
||||||
text = key = value = "";
|
text = key = value = "";
|
||||||
foreach (size_t cn, char ch; line) {
|
foreach (size_t cn, char ch; line) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
/* comment? */
|
||||||
|
case '#':
|
||||||
|
if (cn == 0)
|
||||||
|
continue nextline;
|
||||||
|
|
||||||
|
text ~= ch;
|
||||||
|
break;
|
||||||
|
|
||||||
/* beginning of a section heading? */
|
/* beginning of a section heading? */
|
||||||
case '[':
|
case '[':
|
||||||
if (cn == 0) /* beginning of line? */
|
if (cn == 0) /* beginning of line? */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue