2 using System.Collections.Generic;
9 public const char NoEscape =
'\0';
10 public char EscapeChar = NoEscape;
11 private char[] _stopChars;
14 this.Priority = Terminal.LowestPriority;
18 base.Init(grammarData);
20 foreach(var term
in grammarData.Terminals) {
21 var firsts = term.GetFirsts();
22 if (firsts == null)
continue;
23 foreach (var first
in firsts)
24 if (!
string.IsNullOrEmpty(first))
25 stopCharSet.Add(first[0]);
27 if (EscapeChar != NoEscape)
28 stopCharSet.Add(EscapeChar);
29 _stopChars = stopCharSet.ToArray();
38 bool isEscape = source.PreviewChar == EscapeChar && EscapeChar != NoEscape;
41 var value = source.NextPreviewChar.ToString();
42 source.PreviewPosition += 2;
43 return source.CreateToken(this.OutputTerminal, value);
45 var stopIndex = source.Text.IndexOfAny(_stopChars, source.Location.Position + 1);
47 if (stopIndex < 0) stopIndex = source.Text.Length;
48 source.PreviewPosition = stopIndex;
49 return source.CreateToken(this.OutputTerminal);
override IList< string > GetFirsts()
Interface for Terminals to access the source stream and produce tokens.
WikiTextTerminal(string name)
SourceLocation Location
Current start location (position, row, column) of the new token
Tokens are produced by scanner and fed to parser, optionally passing through Token filters in between...
override void Init(GrammarData grammarData)
override Token TryMatch(ParsingContext context, ISourceStream source)