Пример #1
0
        private SyntaxVisitorResult <IN, OUT> Visit(OptionSyntaxNode <IN> node)
        {
            var child = node.Children != null && node.Children.Any() ? node.Children[0] : null;

            if (child == null || node.IsEmpty)
            {
                return(SyntaxVisitorResult <IN, OUT> .NewOptionNone());
            }
            else
            {
                SyntaxVisitorResult <IN, OUT> innerResult = Visit(child);
                if (child is SyntaxLeaf <IN> leaf)
                {
                    return(SyntaxVisitorResult <IN, OUT> .NewToken(leaf.Token));
                }
                else if (child is GroupSyntaxNode <IN> group)
                {
                    return(SyntaxVisitorResult <IN, OUT> .NewOptionGroupSome(innerResult.GroupResult));
                }
                else
                {
                    return(SyntaxVisitorResult <IN, OUT> .NewOptionSome(innerResult.ValueResult));
                }
            }
        }
Пример #2
0
 private SyntaxVisitorResult <IN, OUT> Visit(SyntaxLeaf <IN> leaf)
 {
     return(SyntaxVisitorResult <IN, OUT> .NewToken(leaf.Token));
 }