Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} 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]");
}
}
} 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]");
}
}
if (production.repetition && production.amount !== undefined) {
return OneOrMore(
productionToDiagram(production.repetition, options),
Comment(`${production.amount} ×`, {})
);
}
if (production.optional) {
return Choice(1, Skip(), productionToDiagram(production.optional, options));
}
if (production.comment) {
return production.group
? Sequence(
productionToDiagram(production.group, options),
Comment(production.comment, {})
)
: Comment(production.comment, {});
}
if (production.group) {
return productionToDiagram(production.group, options);
}
if (production.exceptNonTerminal) {
return NonTerminal(
`${production.include} - ${production.exceptNonTerminal}`,
{}
);
}
if (production.exceptTerminal) {
return NonTerminal(
`${production.include} - ${production.exceptTerminal}`,
{}
);
}
'(', NonTerminal('select'), ')',
Sequence('AS', NonTerminal('alias'))
)
),
',',
),
),
OneOrMore(
Choice(
0,
Skip(),
Sequence(
Choice(
0,
Sequence(',', Comment('old syntax for cross join')),
Sequence(Choice(0, 'CROSS', 'NATURAL'), 'JOIN'),
Sequence(
Choice(
0,
Sequence(Optional('INNER'), 'JOIN'),
Sequence(Choice(0, 'LEFT', 'RIGHT', 'FULL'), Optional('OUTER'), 'JOIN')
),
Choice(
0,
Sequence('ON', NonTerminal('condition')),
Sequence('USING', '(', OneOrMore(NonTerminal('join_column'), ','), ')'),
Sequence('NATURAL')
)
)
),
Choice(
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]");
}
}