Inheritance: RegExTree
Exemplo n.º 1
0
            // Primary : (LitString | "(" Term ")" | Primitive) ["*" | "+" | Repetitions] ;
            internal RegExTree Primary() {
                RegExTree tmp;
                Unary pls;
                if (!esc && chr == '"')
                    tmp = LitString();
                else if (!esc && chr == '(') {
                    scan();
                    tmp = Term();
                    checkAndScan( ')' );
                }
                else
                    tmp = Primitive();

                if (!esc && chr == '*') {
                    scan();
                    tmp = new Unary( RegOp.closure, tmp );
                }
                else if (!esc && chr == '+') {
                    pls = new Unary( RegOp.closure, tmp );
                    pls.minRep = 1;
                    scan();
                    tmp = pls;
                }
                else if (!esc && chr == '?') {
                    pls = new Unary( RegOp.finiteRep, tmp );
                    pls.minRep = 0;
                    pls.maxRep = 1;
                    scan();
                    tmp = pls;
                }
                else if (!esc && chr == '{' && Char.IsDigit( peek() )) {
                    pls = new Unary( RegOp.finiteRep, tmp );
                    GetRepetitions( pls );
                    tmp = pls;
                }
                return tmp;
            }
Exemplo n.º 2
0
 // Repetitions : "{" IntLiteral ["," [IntLiteral] ] "}" ;
 internal void GetRepetitions( Unary tree ) {
     scan();          // read past '{'
     tree.minRep = GetInt();
     if (!esc && chr == ',') {
         scan();
         if (Char.IsDigit( chr ))
             tree.maxRep = GetInt();
         else
             tree.op = RegOp.closure;
     }
     else
         tree.maxRep = tree.minRep;
     checkAndScan( '}' );
 }
Exemplo n.º 3
0
 // Expr : ["^"] SimpleExpr ["$"] ;
 internal RegExTree Expr() {
     RegExTree tmp;
     if (!esc && chr == '^') {
         scan();
         tmp = new Unary( RegOp.leftAnchor, Simple() );
     }
     else
         tmp = Simple();
     if (!esc && chr == '$') {
         scan();
         tmp = new Unary( RegOp.rightAnchor, tmp );
     }
     return tmp;
 }