コード例 #1
0
            protected override bool TryRunImpl(ISourceTextReader reader, out string text)
            {
                int index = 0;

                for (; index < this.Characters.Length; index++)
                {
                    if (reader.Character == this.Characters[index])
                    {
                        if (reader.Move(1))
                        {
                            continue;
                        }
                    }

                    break;
                }

                bool result;

                if (index == this.Characters.Length)
                {
                    text   = this.Characters;
                    result = true;
                }
                else
                {
                    if (index > 0)
                    {
                        if (!reader.Move(-index))
                        {
                            throw new InvalidOperationException();
                        }
                    }

                    text   = null;
                    result = false;
                }

                return(result);
            }
コード例 #2
0
            protected override bool TryRunImpl(ISourceTextReader reader, out string content)
            {
                bool result;
                var  text = reader.GetText();
                var  pos  = reader.GetPosition();

                var match = _regex.Match(text, pos);

                if (match.Success && match.Index == pos)
                {
                    content = match.Value;
                    result  = reader.Move(match.Length);
                }
                else
                {
                    content = null;
                    result  = false;
                }

                return(result);
            }
コード例 #3
0
 protected override bool TryRunImpl(ISourceTextReader reader, out string text)
 {
     text = reader.Character.ToString();
     return(reader.Move(1));
 }