Example #1
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();
                }
            }
Example #2
0
        private Expression Prefix(INode node)
        {
            switch (node.Name)
            {
            case "and":
                return(AndExpression.From(node, Suffix(node[0])));

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

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

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

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

            default:
                return(Suffix(node));
            }
        }