dlang-community / SDLang-D

An SDLang (Simple Declarative Language) library for D
http://sdlang.org
Other
120 stars 21 forks source link

Incorrectly accepts "anon tag without a value" when the tag has children #12

Closed Abscissa closed 10 years ago

Abscissa commented 10 years ago

This is dedicated ticket for "case 1" in Issue #9:

If brace appears on it's own line, SDLang-D silently ignores everything inside the curly-braces and does not throw an error:

parent
{
  child1
  child2
}

It should throw an error (like the Java implementation does) because anonymous tags are supposed to require at least one value. Quoting the language guide:

Note: Anonymous tags must have at least one value Anonymous tags must have one or more values. They cannot contain only attributes. This design decision was taken to avoid confusion between a tag with a single value and an anonymous tag containing only one attribute.

Not allowed: An anonymous tag with a single attribute (and no values)...

size=5

...because it could easily be confused with a tag having a single value

size 5

Abscissa commented 10 years ago

Fixed via fab64ea and 1888146

Abscissa commented 10 years ago

@marler8997: You may want to know: The fix for this involved a slight change to the grammar in the parser's comments. Specifically, to the <Root> and <TagTerminator> nonterminals.

marler8997 commented 10 years ago

Thanks for letting me know and thanks for fixing these issues so quickly. Daniel was on vacation last week so hopefully he gets back to me today. I have a few pending emails to him about some of the cases from issue 9 (and the whitespace issues for namespaces and attributes). I'll let you know what I find out.