Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function renderTok(tok) {
// ctx translated to correct position already
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);
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'))
)
),
','
),
),
'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'))
)
),
','
),
),
Terminal('FROM', '#sql-from'),
OneOrMore(
Choice(
0,
Sequence(
NonTerminal('table_name'),
comma or semicolon.
The <i>QUALIFIER</i> is optional. Also the <i>COLUMN_TYPE</i> can be omitted if the type is well
defined by the values of that column. The first non null value of a column defines its type.
<br>True and false (case insensitive without quotes) are reserved for a boolean type. They can
be used as a simple string but they do not define the type of the column as string.
<br>The <i>COLUMN_TYPE</i> can be one of the following
<ul>
<li>string</li>
<li>number</li>
<li>date</li>
<li>boolean</li>
</ul>
<div>
</div>
0,
'UNION',
'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'
),
'skip',
),
alternative syntax
join<br>inner join
<div>join condition
<div>
</div>
</div>
<p>
Special case:<br>
The name of a single boolean column (like <code>R join a S</code>) can not be used directly
as a join condition due to ambiguities in the relational algebra syntax.<br>
The column must either be specified with its qualifier (<code>R join R.a S</code>) or wrapped in
parentheses (<code>R join (a) S</code>).<br></p>