all repos — pls @ 8a4f8f6036ef73fdb327ab01a82c261762fca061

A polite but determined task runner.

Added check for duplicated properties and items.
h3rald h3rald@h3rald.com
Fri, 08 Oct 2021 16:58:09 +0200
commit

8a4f8f6036ef73fdb327ab01a82c261762fca061

parent

78bcbbf1888c40b106e4dd69d4da0ad14ac02de5

1 files changed, 4 insertions(+), 0 deletions(-)

jump to
M src/pls.nimsrc/pls.nim

@@ -98,6 +98,8 @@ raise ConfigParseError(msg: "Line $1 - Invalid $2 indentation (not within an item)." % [$count, obj])

let p = parseProperty(line, count) if (section == "actions" and not p.name.match(PEG_DEF)) or (section == "things" and not p.name.match(PEG_ID)): raise ConfigParseError(msg: "Line $1 - Invalid $2 '$3'" % [$count, obj, p.name]) + if DATA[section][itemId].hasKey(p.name): + raise ConfigParseError(msg: "Line $1 - Duplicate property '$2'" % [$count, p.name]) DATA[section][itemId][p.name] = p.value indent = 4 continue

@@ -122,6 +124,8 @@ raise ConfigParseError(msg: "Line $1 - Invalid $2 identifier." % [$count, obj])

itemId = line[0..line.len-2] if not itemId.match(PEG_ID): raise ConfigParseError(msg: "Line $1 - Invalid $2 identifier '$3'." % [$count, obj, itemId]) + if DATA[section].hasKey(itemId): + raise ConfigParseError(msg: "Line $1 - Duplicate item '$2'" % [$count, itemId]) # Start new item DATA[section][itemId] = newTable[string, string]() indent = 2