Exemple #1
0
 private AlternativeNode ParseAlternativeRest()
 {
     switch (CurToken.Type)
     {
         case TokenType.ALTERNATIVE:
             AdvanceInput();
             var mFactors = ParseMatchFactorList();
             var af = new AlternativeNode(mFactors);
             af.Next = ParseAlternativeRest();
             return af;
         case TokenType.CLOSEGROUP:
         case TokenType.ENDANCHOR:
         case TokenType.EOF:
             return null;
         default:
             throw new ParseException("Invalid input lookahead");
     }
 }
Exemple #2
0
 public RegexNode(AlternativeNode firstAlternative = null, bool startAnchor = false, bool endAnchor = false)
 {
     StartAnchor = startAnchor;
     EndAnchor = endAnchor;
     FirstAlternative = firstAlternative;
 }
Exemple #3
0
 private RegexNode ParseRegexBody()
 {
     switch (CurToken.Type)
     {
         case TokenType.OPENCLASS:
         case TokenType.OPENCLASSNEGATE:
         case TokenType.CHAR:
         case TokenType.OPENGROUP:
         case TokenType.OPENGROUPNOCAP:
         case TokenType.ANY:
         case TokenType.ALTERNATIVE: //will result in null from ParseMatchFactorList()
             var mf = ParseMatchFactorList();
             var af = new AlternativeNode(mf);
             af.Next = ParseAlternativeRest();
             return new RegexNode(firstAlternative: af);
         default:
             throw new ParseException("Invalid input lookahead (I think I need to be more generous here?)");
     }
 }
 public AlternativeNode(MatchFactorNode firstFactor = null, AlternativeNode next = null)
 {
     Next = next;
     FirstFactor = firstFactor;
 }