Пример #1
0
        private Expression Primary(INode node)
        {
            switch (node.Name)
            {
            case "identifier":
                return(NameExpression.From(node, Identifier(node)));

            case "singleString":
            case "doubleString":
                return(StringLiteral(node));

            case ".":
                return(AnyExpression.From(node));

            case "choice":
                return(Expression(node));

            case "class":
                return(Class(node));

            case "ε":
                return(EpsilonExpression.From(node));

            case "inline":
                return(InlineExpression.From(node, Rule(node[0])));

            default:
                throw new NotImplementedException();
            }
        }
Пример #2
0
            private static Expression Expression(INode node)
            {
                switch (node.Name)
                {
                case "sequence": return(Sequence(node));

                case "choice": return(Choice(node));

                case "prefix.drop": return(DropExpression.From(node[0], Expression(node[0])));

                case "prefix.lift": return(LiftExpression.From(node[0], Expression(node[0])));

                case "prefix.fuse": return(FuseExpression.From(node[0], Expression(node[0])));

                case "prefix.not": return(NotExpression.From(node[0], Expression(node[0])));

                case "suffix.zero-or-more": return(StarExpression.From(node[0], Expression(node[0])));

                case "suffix.one-or-more": return(PlusExpression.From(node[0], Expression(node[0])));

                case "suffix.zero-or-one": return(OptionalExpression.From(node[0], Expression(node[0])));

                case "inline": return(InlineExpression.From(node[0], Tree.Rule.From(Identifier(node[0]), Expression(node[1]))));

                case "identifier": return(NameExpression.From(node, Identifier(node)));

                case "any": return(AnyExpression.From(node));

                case "verbatim-string": return(StringLiteralExpression.From(node, ((ILeaf)node).Value));

                case "character-class": return(Class(node));

                case "string": return(String(node));

                default:
                    throw new NotImplementedException();
                }
            }