On 8/25/2014 12:25 PM, Jonathan Marler wrote:

The next critique I have of SDL is it doesn't have a solid specification. It DOES NOT include a grammar and when I attempted to write one it was clear that writing it was not a trivial task.

The LL parsing section of my SDL lib is annotated with a grammar
(including lookahead information) for SDL's nonterminals:

https://github.com/Abscissa/SDLang-D/blob/master/src/sdlang_/parser.d

Reproduced here (Ident and Value are terminals handles by the lexer):

<Root> ::= <Tags> (Lookaheads: Anything)

<Tags>

 ::= <Tag> <Tags>  (Lookaheads: Ident Value)
 |   EOL   <Tags>  (Lookaheads: EOL)
 |   {empty}       (Lookaheads: Anything else)

<Tag>

 ::= <IDFull> <Values> <Attributes> <OptChild> <TagTerminator> 

(Lookaheads: Ident)

 |   <Value>  <Values> <Attributes> <OptChild> <TagTerminator> 

(Lookaheads: Value)

<IDFull> ::= Ident <IDSuffix> (Lookaheads: Ident)

<IDSuffix>

 ::= ':' Ident  (Lookaheads: ':')
 ::= {empty}    (Lookaheads: Anything else)

<Values>

 ::= Value <Values>  (Lookaheads: Value)
 |   {empty}         (Lookaheads: Anything else)

<Attributes>

 ::= <Attribute> <Attributes>  (Lookaheads: Ident)
 |   {empty}                   (Lookaheads: Anything else)

<Attribute> ::= <IDFull> '=' Value (Lookaheads: Ident)

<OptChild>

  ::= '{' EOL <Tags> '}'  (Lookaheads: '{')
  |   {empty}             (Lookaheads: Anything else)

<TagTerminator>

 ::= EOL  (Lookahead: EOL)
 |   EOF  (Lookahead: EOF)

Note: That's (sort of) the GOLD Parser Builder syntax (nonterminals are
in angle brackets):

<NonTerminal Token> ::= set of tokens | alternate set | etc...

I'll go through my SDL lexer and post a grammar for its behavior, and
then ask the main SDL guy to check it over.