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) {
yes
no
no
<div>
'),
NonTerminal('new name')
),
','
)
)</div>