Added check for duplicated properties and items.
h3rald h3rald@h3rald.com
Fri, 08 Oct 2021 16:58:09 +0200
1 files changed,
4 insertions(+),
0 deletions(-)
jump to
M
src/pls.nim
→
src/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