Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
),
),
),
Sequence(
Optional(
Sequence(
Terminal('WHERE', '#sql-where'),
NonTerminal('condition')
),
'skip',
),
Optional(
Sequence(
Terminal('GROUP BY', '#sql-groupby'),
NonTerminal('expression', '#sql-valueexpr')
),
'skip',
),
Optional(
Sequence(
Terminal('HAVING', '#sql-having'),
NonTerminal('condition')
),
'skip',
),
),
Sequence(
Optional(
Sequence(
if (tok.subexpression) {
return new rr.Choice(0, tok.subexpression.map(renderTok));
} else if (tok.ebnf) {
switch (tok.modifier) {
case ":+":
return new rr.OneOrMore(renderTok(tok.ebnf));
break;
case ":*":
return new rr.ZeroOrMore(renderTok(tok.ebnf));
break;
case ":?":
return new rr.Optional(renderTok(tok.ebnf));
break;
}
} else if (tok.literal) {
return new rr.Terminal(JSON.stringify(tok.literal));
} else if (tok.mixin) {
return new rr.Comment("Pas implementé.");
} else if (tok.macrocall) {
return new rr.Comment("Pas implementé.");
} else if (tok.tokens) {
return new rr.Sequence(tok.tokens.map(renderTok));
} else if (typeof(tok) === 'string') {
return new rr.NonTerminal(tok);
} else if (tok.constructor === RegExp) {
return new rr.Terminal(tok.toString());
} else if (tok.token) {
return new rr.Terminal(tok.token);
} else {
return new rr.Comment("[Unimplemented]");
}
}
const productionToDiagram = (production, options) => {
if (production.identifier) {
return production.complex
? ComplexDiagram(productionToDiagram(production.definition, options))
: Diagram(productionToDiagram(production.definition, options));
}
if (production.terminal) {
return Terminal(production.terminal);
}
if (production.nonTerminal) {
return NonTerminal(production.nonTerminal, {
href: `#${dasherize(production.nonTerminal)}`
});
}
if (production.skip) {
return Skip();
}
if (production.specialSequence) {
const sequence = NonTerminal(" " + production.specialSequence + " ", {});
sequence.attrs.class = "special-sequence";
return sequence;
}
if (production.choice) {
const makeChoice = items => new Choice(0, items);
Terminal('WITH', '#sql-with'),
OneOrMore(
Sequence(
NonTerminal('name'),
'AS',
'(',
NonTerminal('select', '#sql-select'),
')'
),
','
),
),
'skip',
),
Sequence(
Terminal('SELECT', '#sql-select'),
Optional('DISTINCT', 'skip'),
Choice(
0,
'*',
OneOrMore(
Choice(
0,
Sequence(
NonTerminal('column'),
Optional(Sequence('AS', NonTerminal('output_name')))
),
Sequence(
NonTerminal('expression', '#sql-valueexpr'),
Sequence('AS', NonTerminal('output_name'))
)
),
'INTERSECT',
'EXCEPT'
),
Choice(
0,
Skip(),
'DISTINCT',
'ALL'
),
NonTerminal('select')
),
'skip',
),
Optional(
Sequence(
Terminal('ORDER BY', '#sql-orderby'),
OneOrMore(
Sequence(
NonTerminal('expression', '#sql-valueexpr'),
Choice(
0,
'ASC',
'DESC'
)
),
','
)
),
'skip',
),
),
),
Sequence(
Optional(
Sequence(
Terminal('LIMIT', '#sql-limit'),
Choice(0,
NonTerminal('count'),
'ALL'
)
),
'skip',
),
Optional(
Sequence(
Terminal('OFFSET', '#sql-limit'),
NonTerminal('start'),
Optional('ROWS')
),
'skip',
),
),
Sequence(
Optional(
Sequence(
Terminal('FETCH FIRST', '#sql-limit'),
NonTerminal('count'),
Optional('ROWS'),
'ONLY'
),
break;
}
} else if (tok.literal) {
return new rr.Terminal(JSON.stringify(tok.literal));
} else if (tok.mixin) {
return new rr.Comment("Pas implementé.");
} else if (tok.macrocall) {
return new rr.Comment("Pas implementé.");
} else if (tok.tokens) {
return new rr.Sequence(tok.tokens.map(renderTok));
} else if (typeof(tok) === 'string') {
return new rr.NonTerminal(tok);
} else if (tok.constructor === RegExp) {
return new rr.Terminal(tok.toString());
} else if (tok.token) {
return new rr.Terminal(tok.token);
} else {
return new rr.Comment("[Unimplemented]");
}
}
),
Optional(
Sequence(
Terminal('OFFSET', '#sql-limit'),
NonTerminal('start'),
Optional('ROWS')
),
'skip',
),
),
Sequence(
Optional(
Sequence(
Terminal('FETCH FIRST', '#sql-limit'),
NonTerminal('count'),
Optional('ROWS'),
'ONLY'
),
'skip',
),
),
),
)} />
<h3 id="sql-translation">Semantic and Translation to relational algebra</h3>
<h4 id="sql-translation-sequence">Sequence of execution</h4>
Sequence(
Terminal('WHERE', '#sql-where'),
NonTerminal('condition')
),
'skip',
),
Optional(
Sequence(
Terminal('GROUP BY', '#sql-groupby'),
NonTerminal('expression', '#sql-valueexpr')
),
'skip',
),
Optional(
Sequence(
Terminal('HAVING', '#sql-having'),
NonTerminal('condition')
),
'skip',
),
),
Sequence(
Optional(
Sequence(
Choice(
0,
'UNION',
'INTERSECT',
'EXCEPT'
),
Choice(