Exemplo n.º 1
0
 protected override void HandleToken(LineMatch match)
 {
     var newLine = match.Text.IndexOf("\n");
     string title = (newLine < 0) ? match.Text : match.Text.Substring(0, newLine);
     title = title.TrimEnd(new[] {'\r', ' ', '\t'});
     string narrative = (newLine < 0) ? "" : match.Text.Substring(newLine).TrimStart(new[] {'\n'});
     listener.Feature(match.Token, title, narrative, match.Line);
 }
Exemplo n.º 2
0
 protected override void HandleToken(LineMatch match)
 {
     var tags = match.ParsedLine.Text.Trim()
         .Split(new[] {'@'}, StringSplitOptions.RemoveEmptyEntries)
         .Select(_ => "@" + _.Trim());
     foreach (var tag in tags)
         listener.Tag(tag, match.Line);
 }
Exemplo n.º 3
0
 protected override void HandleToken(LineMatch match)
 {
     StreamReader reader = UriFactory.GetReader(match.Text);
     using (reader)
     {
         while (reader.EndOfStream == false)
         {
             var text = reader.ReadLine().Trim(WhiteSpace);
             if (!string.IsNullOrEmpty(text))
                 base.HandleToken(new LineMatch(match.Token, text, new ParsedLine(text, "\n", match.Line), this));
         }
     }
 }
Exemplo n.º 4
0
        protected override void HandleToken(LineMatch match)
        {
            string text = match.ParsedLine.Text;
            if (IsLanguageComment(text))
            {
                var languageString = ExtractLanguage(text);
                if (Language.HasLanguage(languageString))
                {
                    listener.Language(languageString, match.Line);
                    ChangeLanguage(text);
                }
                else
                    throw new LexerError(string.Format("Line: {1}. Unknown language '{0}'", languageString, match.Line));
            }

            listener.Comment(match.Text, match.Line);
        }
Exemplo n.º 5
0
        protected override void HandleToken(LineMatch match)
        {
            int line = match.Line;
            string text = match.Text;
            int spacesToTrim = match.ParsedLine.Text.IndexOf("\"\"\"", System.StringComparison.Ordinal);

            bool skipNewline = text == string.Empty;
            bool atEnd = text.Trim().Length > 3 && text.Trim().EndsWith(DocString);
            while (!atEnd && LineEnumerator.HasMore)
            {
                LineEnumerator.MoveToNext();
                var lineText = LineEnumerator.Current.Text;
                atEnd = lineText.TrimEnd().EndsWith(DocString);
                if (!atEnd)
                    text += (skipNewline ? TrimSpaces(lineText, spacesToTrim) : LineEnumerator.Current.LineEnd + TrimSpaces(lineText, spacesToTrim));
                skipNewline = false;
            }
            string trimEnd = text.TrimEnd(new[] { DocString[0] });
            listener.DocString(trimEnd, line);
        }
Exemplo n.º 6
0
 protected override void HandleToken(LineMatch match)
 {
     Listener.Scenario(match.Token, match.Text, match.Line);
 }
Exemplo n.º 7
0
 protected override void HandleToken(LineMatch match)
 {
     listener.Background(match.Token, match.Text, match.Line);
 }
Exemplo n.º 8
0
 protected override void HandleToken(LineMatch match)
 {
     var cols = match.ParsedLine.Text.Split(new[] {'|'});
     var l = cols.Skip(1).Take(cols.Length - 2).Select(column => column.Trim()).ToList();
     listener.Row(l, match.Line);
 }
Exemplo n.º 9
0
 protected override void HandleToken(LineMatch match)
 {
     listener.Examples(match.Token, string.Empty, match.Line);
 }
Exemplo n.º 10
0
 protected override void HandleToken(LineMatch match)
 {
     listener.Step(match.Token, match.Text, match.Line);
 }
Exemplo n.º 11
0
 protected override void HandleToken(LineMatch ignore)
 {
 }
Exemplo n.º 12
0
 private void ReadMultiLineStep(Lexer parentLexer, LineMatch lineMatch)
 {
     if (CanSpanMultipleLines
         && NextLineIsStep(parentLexer) == false
         && NextLineIsChildStep(lineMatch) == false)
     {
         string moreTitle = GetStepText();
         lineMatch.Text = (string.IsNullOrEmpty(moreTitle)) ? lineMatch.Text : lineMatch.Text + lineMatch.ParsedLine.LineEnd + moreTitle;
     }
 }
Exemplo n.º 13
0
 private void Parse(LineMatch lineMatch)
 {
     lineMatch.Lexer.HandleToken(lineMatch);
     LineEnumerator.MoveToNext();
     Parse();
 }
Exemplo n.º 14
0
 private bool NextLineIsChildStep(LineMatch lineMatch)
 {
     return NextLineIsStep(lineMatch.Lexer);
 }
Exemplo n.º 15
0
 protected abstract void HandleToken(LineMatch match);