Help identifying the components making this pattern?

Oct 19, 2015 at 2:00 PM
Edited Oct 20, 2015 at 7:20 AM
Hi

I am struggling to work out the component parts (non-terminals) required to generate the grammar for the following:
a) string 
b) (string JOIN string ON (x=y))
c) ((string JOIN string ON (x=y))
            JOIN string ON (x=y))
d) (((string JOIN string ON (x=y))
             JOIN string ON (x=y))
             JOIN string ON (x=y)))
e) etc
I can see that there will be an equality non-terminal to represent the
 (x=y)
and a further non-terminal to represent
JOIN string ON (x=y)
Beyond that, I am struggling to put it all together. As you can see, the number of brackets at the start increase relative to the number of JOINS, so I'm guessing there must be a recursive structure involved, but can't quite see it. Alternatively, I wasn't sure whether I could implement it using a MakePlusRule but couldn't see how to increase correctly the no of brackets at the start of the expression using that method - hence recursion seems right.

Many thx in advance once again.
Oct 20, 2015 at 8:16 AM
Edited Oct 21, 2015 at 10:02 AM
OK. So I found this link and line 1204 and following.

Here's the bit from my grammar
  joinSourceExpression.Rule =
        csvExpression Or
        [LPAREN] + joinSourceExpression + joinChainExpression + [RPAREN]

  joinChainExpression.Rule =
        joinExpression + joinChainExpression Or
        Empty

  joinExpression.Rule =
        [INNER] + [JOIN] + joinSourceExpression + [ON] + expression Or
        [LEFT] + [JOIN] + joinSourceExpression + [ON] + expression Or
        [RIGHT] + [JOIN] + joinSourceExpression + [ON] + expression Or
        [LEFT] + [OUTER] + [JOIN] + joinSourceExpression + [ON] + expression Or
        [RIGHT] + [OUTER] + [JOIN] + joinSourceExpression + [ON] + expression

  fromClause.Rule =
        [FROM] + joinSourceExpression + joinChainExpression Or
        Empty
(where &#43 = plus symbol)