Esempio n. 1
0
 // in addition to creating the TokenType object, set the accepting state for the regex
 public TokenType(String name, Regex regex, Priority priority = Priority.Default)
 {
     this.name = name;
     this.regex = regex;
     this.tokenPriority = priority;
     regex.DefineTokenClass(this);
 }
Esempio n. 2
0
 // combines the regexes (their internal NFA-like structure)
 public static TokenAutomaton CombinedAutomaton(params TokenType[] ts)
 {
     Regex[] rs = new Regex[ts.Length];
     for (int i = 0; i < ts.Length; i++)
         rs[i] = ts[i].regex;
     Regex combined = Regex.Union(rs);
     return combined.ConstructAutomaton();
 }
Esempio n. 3
0
 public Regex Union(Regex other)
 {
     Node start = new Node();
     Node end = new Node();
     start.epsilonTransitions.Add(this.start);
     start.epsilonTransitions.Add(other.start);
     this.end.epsilonTransitions.Add(end);
     other.end.epsilonTransitions.Add(end);
     return new Regex(start, end);
 }
Esempio n. 4
0
 public Regex Concat(Regex other)
 {
     this.end.epsilonTransitions.Add(other.start);
     return new Regex(this.start, other.end);
 }