IronRuby.Builtins.RegexpTransformer.Parse C# (CSharp) Method

Parse() private method

private Parse ( bool isSubexpression ) : void
isSubexpression bool
return void
        private void Parse(bool isSubexpression) {
            int lastEntityIndex = 0;
            int c;
            while (true) {
                switch (c = Read()) {
                    case -1:
                        if (isSubexpression) {
                            throw MakeError("end pattern in group");
                        }
                        return;
                    
                    case '\\':
                        lastEntityIndex = _sb.Length;
                        ParseEscape();
                        break;

                    case '?':
                    case '*':
                    case '+':
                        Append((char)c);
                        ParsePostQuantifier(lastEntityIndex, true);
                        break;

                    case '{':
                        if (ParseConstrainedQuantifier()) {
                            ParsePostQuantifier(lastEntityIndex, false);
                        } else {
                            goto default;
                        }
                        break;

                    case '(':
                        lastEntityIndex = _sb.Length;
                        ParseGroup();
                        break;

                    case ')':
                        if (isSubexpression) {
                            return;
                        } else {
                            throw MakeError("unmatched close parenthesis");
                        }
                    
                    case '[':
                        lastEntityIndex = _sb.Length;
                        ParseCharacterGroup(false).AppendTo(_sb, true);
                        break;

                    case '|':
                        Append('|');
                        lastEntityIndex = _sb.Length;
                        break;

                    default:
                        lastEntityIndex = _sb.Length;
                        Append((char)c);
                        break;
                }
            }
        }