Beispiel #1
0
        protected override NodeResultBuilder GetValue()
        {
            var builder = new NodeResultBuilder();

            //check whether nothing is connected to this node.
            if (PreviousNode is null)
            {
                builder.Append("Nothing connected to Output node", this);
                return(builder);
            }
            builder.Append(Previous.Value);

            //Prefix
            switch (InputStartsAt.Value)
            {
            case Mode.StartLine: builder.Prepend("^", this); break;

            case Mode.WordBound: builder.Prepend("\\b", this); break;
            }

            //Suffix
            switch (InputEndsAt.Value)
            {
            case Mode.EndLine: builder.Append("$", this); break;

            case Mode.WordBound: builder.Append("\\b", this); break;
            }

            if (PreviousNode is OrNode)
            {
                builder.StripNonCaptureGroup();
            }
            return(builder);
        }
Beispiel #2
0
        protected override NodeResultBuilder GetValue()
        {
            var builder = new NodeResultBuilder(Input.Value);

            if (Input.ConnectedNode is OrNode ||
                Input.ConnectedNode is IntegerNode
                )
            {
                builder.StripNonCaptureGroup();
            }

            string prefix = InputGroupType.Value switch
            {
                GroupTypes.capturing => "(",
                GroupTypes.nonCapturing => "(?:",
                GroupTypes.named => $"(?<{GroupName.GetValue()}>",
                GroupTypes.atomic => $"(?>",
                GroupTypes.custom => "(" + CustomPrefix.GetValue(),
                _ => "",
            };

            builder.Prepend(prefix, this);
            builder.Append(")", this);
            return(builder);
        }
Beispiel #3
0
        protected override NodeResultBuilder GetValue()
        {
            var builder = new NodeResultBuilder(InputContents.Value);

            //Simplify IntegerNode if needed
            if (InputContents.ConnectedNode is IntegerNode)
            {
                builder.StripNonCaptureGroup();
            }

            string suffix = "";
            string prefix = "";

            //Surround with non-capturing group if necessary
            if (InputContents.ConnectedNode is Node _node &&
                RequiresGroupToQuantify(_node))
            {
                prefix += "(?:";
                suffix += ")";
            }

            //Add quantifier
            suffix += GetSuffix(this);

            //Add modifier
            if (InputCount.Value != Reps.Number)
            {
                if (InputSearchType.Value == SearchMode.Lazy)
                {
                    suffix += "?";
                }
                else if (InputSearchType.Value == SearchMode.Possessive)
                {
                    suffix += ")";
                    prefix  = "(?>" + prefix;
                }
            }

            builder.Prepend(prefix, this);
            builder.Append(suffix, this);
            return(builder);
        }
Beispiel #4
0
        protected override NodeResultBuilder GetValue()
        {
            var builder = new NodeResultBuilder(Input.Value);

            if (Input.ConnectedNode is OrNode)
            {
                builder.StripNonCaptureGroup();
            }

            string prefix = InputGroupType.Value switch
            {
                Types.lookahead => "(?=",
                Types.lookbehind => "(?<=",
                Types.lookaheadNeg => "(?!",
                Types.lookbehindNeg => "(?<!",
                _ => "",
            };

            builder.Prepend(prefix, this);
            builder.Append(")", this);
            return(builder);
        }