Esempio n. 1
0
        public RegExpr ParseRegex()
        {
            var re = new RegExpr();
            var follow = new HashSet<TokenType>()
                {TokenType.EOF, TokenType.CLOSEGROUP};
            do
            {
                re.Alternatives.Add(ParseAlternative());
            } while (SkipIf(TokenType.ALTERNATIVE));

            if (!follow.Contains(_ts.Peek().Type))
                throw new ParseException();
            if (_ts.Peek().Type == TokenType.EOF)
                _ts.NextToken();

            return re;
        }
Esempio n. 2
0
        private void InstantiateFromRegex(RegExpr re)
        {
            _startState = NewState();
            _finishState.Add(NewState());
            foreach (var alt in re.Alternatives)
            {
                var altnfa = new NFAGraph(alt);
                CopyInto(altnfa);

                var nsl = new NFALink();
                var nfl = new NFALink();
                nsl.IsEmpty = true;
                nfl.IsEmpty = true;
                nsl.Target = altnfa._startState;
                nfl.Target = _finishState.Single();
                _adjList[_startState].Add(nsl);
                _adjList[altnfa._finishState.Single()].Add(nfl);
            }
        }
Esempio n. 3
0
 public NFAGraph(RegExpr reParseTree)
 {
     InstantiateFromRegex(reParseTree);
 }
Esempio n. 4
0
 public Group(RegExpr innerRegExpr)
 {
     InnerRegExpr = innerRegExpr;
 }