private void ParseDirectives(RootCommandNode parent) { while (More()) { var token = CurrentToken; if (token.Type != TokenType.Directive) { return; } var withoutBrackets = token.Value.Substring(1, token.Value.Length - 2); var keyAndValue = withoutBrackets.Split(new[] { ':' }, 2); var key = keyAndValue[0]; var value = keyAndValue.Length == 2 ? keyAndValue[1] : null; var directiveNode = new DirectiveNode(token, parent, key, value); parent.AddChildNode(directiveNode); Advance(); } }
protected override void VisitRootCommandNode(RootCommandNode rootCommandNode) { _rootCommandResult = new RootCommandResult( rootCommandNode.Command, rootCommandNode.Token); _rootCommandResult.ValidationMessages = _parser.Configuration.ValidationMessages; _innermostCommandResult = _rootCommandResult; }
private RootCommandNode ParseRootCommand() { var rootCommandNode = new RootCommandNode(CurrentToken, _configuration.RootCommand); Advance(); ParseDirectives(rootCommandNode); ParseCommandChildren(rootCommandNode); ParseRemainingTokens(); return(rootCommandNode); }