How to use the railroad-diagrams.Optional function in railroad-diagrams

To help you get started, we’ve selected a few railroad-diagrams examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kach / nearley / bin / nearley-railroad.js View on Github external
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);
github dbis-uibk / relax / calc2 / views / help.tsx View on Github external
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'))
																					)
																			),
																			','
github dbis-uibk / relax / calc2 / views / help.tsx View on Github external
),
															),
															'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'),
github dbis-uibk / relax / calc2 / views / help.tsx View on Github external
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>
github dbis-uibk / relax / calc2 / views / help.tsx View on Github external
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',
															),
github dbis-uibk / relax / calc2 / views / help.tsx View on Github external
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',
															),
github dbis-uibk / relax / calc2 / views / help.tsx View on Github external
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>