Ejemplo n.º 1
0
 private bool Expect (MeTokenType token, string ruleString)
 {
     if (this._tokenizer.Token != token) {
         this.SetBrokenRuleString(ruleString);
         return false;
     }
     return true;
 }
 private bool Expect(MeTokenType token, string ruleString)
 {
     if (this._tokenizer.Token != token)
     {
         this.SetBrokenRuleString(ruleString);
         return(false);
     }
     return(true);
 }
Ejemplo n.º 3
0
        public void Read()
        {
            bool isQuotedMarkupExtension = false;
            bool readString = false;

            _tokenText      = string.Empty;
            _tokenXamlType  = null;
            _tokenProperty  = null;
            _tokenNamespace = null;

            Advance();
            AdvanceOverWhitespace();

            if (IsAtEndOfInput)
            {
                _token = MeTokenType.None;
                return;
            }

            switch (CurrentChar)
            {
            case OpenCurlie:
                if (NextChar == CloseCurlie)    // the {} escapes the ME.  return the string.
                {
                    _token     = MeTokenType.String;
                    _state     = StringState.Value;
                    readString = true;          // ReadString() will strip the leading {}
                }
                else
                {
                    _token = MeTokenType.Open;
                    _state = StringState.Type;  // types follow '{'
                }
                break;

            case Quote1:
            case Quote2:
                if (NextChar == OpenCurlie)
                {
                    Advance();                    // read ahead one character
                    if (NextChar != CloseCurlie)  // check for the '}' of a {}
                    {
                        isQuotedMarkupExtension = true;
                    }
                    PushBack();     // put back the read-ahead.
                }
                readString = true;  // read substring"
                break;

            case CloseCurlie:
                _token = MeTokenType.Close;
                _state = StringState.Value;
                break;

            case EqualSign:
                _token = MeTokenType.EqualSign;
                _state = StringState.Value;
                _context.CurrentBracketModeParseParameters.IsConstructorParsingMode = false;
                break;

            case Comma:
                _token = MeTokenType.Comma;
                _state = StringState.Value;
                if (_context.CurrentBracketModeParseParameters.IsConstructorParsingMode)
                {
                    _context.CurrentBracketModeParseParameters.IsConstructorParsingMode =
                        ++_context.CurrentBracketModeParseParameters.CurrentConstructorParam <
                        _context.CurrentBracketModeParseParameters.MaxConstructorParams;
                }
                break;

            default:
                readString = true;
                break;
            }

            if (readString)
            {
                if (_context.CurrentType.IsMarkupExtension &&
                    _context.CurrentBracketModeParseParameters != null &&
                    _context.CurrentBracketModeParseParameters.IsConstructorParsingMode)
                {
                    int currentCtrParam = _context.CurrentBracketModeParseParameters.CurrentConstructorParam;
                    _currentParameterName            = _context.CurrentLongestConstructorOfMarkupExtension[currentCtrParam].Name;
                    _currentSpecialBracketCharacters = GetBracketCharacterForProperty(_currentParameterName);
                }

                string str = ReadString();
                _token = (isQuotedMarkupExtension) ? MeTokenType.QuotedMarkupExtension : MeTokenType.String;

                switch (_state)
                {
                case StringState.Value:
                    break;

                case StringState.Type:
                    _token = MeTokenType.TypeName;
                    ResolveTypeName(str);
                    break;

                case StringState.Property:
                    _token = MeTokenType.PropertyName;
                    ResolvePropertyName(str);
                    break;
                }
                _state     = StringState.Value;
                _tokenText = RemoveEscapes(str);
            }
        }
Ejemplo n.º 4
0
        public void Read ()
        {
            bool flag = false;
            bool flag2 = false;
            this._tokenText = string.Empty;
            this._tokenXamlType = null;
            this._tokenProperty = null;
            this._tokenNamespace = null;
            this.Advance();
            this.AdvanceOverWhitespace();
            if (this.IsAtEndOfInput) {
                this._token = MeTokenType.None;
            }
            else {
                switch (this.CurrentChar) {
                    case '{':
                        if (this.NextChar != '}') {
                            this._token = MeTokenType.Open;
                            this._state = StringState.Type;
                        }
                        else {
                            this._token = MeTokenType.String;
                            this._state = StringState.Value;
                            flag2 = true;
                        }
                        break;

                    case '}':
                        this._token = MeTokenType.Close;
                        this._state = StringState.Value;
                        break;

                    case '=':
                        this._token = MeTokenType.EqualSign;
                        this._state = StringState.Value;
                        break;

                    case ',':
                        this._token = MeTokenType.Comma;
                        this._state = StringState.Value;
                        break;

                    case '"':
                    case '\'':
                        if (this.NextChar == '{') {
                            this.Advance();
                            if (this.NextChar != '}') {
                                flag = true;
                            }
                            this.PushBack();
                        }
                        flag2 = true;
                        break;

                    default:
                        flag2 = true;
                        break;
                }
                if (flag2) {
                    string longName = this.ReadString();
                    this._token = flag ? MeTokenType.QuotedMarkupExtension : MeTokenType.String;
                    switch (this._state) {
                        case StringState.Type:
                            this._token = MeTokenType.TypeName;
                            this.ResolveTypeName(longName);
                            break;

                        case StringState.Property:
                            this._token = MeTokenType.PropertyName;
                            this.ResolvePropertyName(longName);
                            break;
                    }
                    this._state = StringState.Value;
                    this._tokenText = RemoveEscapes(longName);
                }
            }
        }
        public void Read()
        {
            bool flag  = false;
            bool flag2 = false;

            this._tokenText      = string.Empty;
            this._tokenXamlType  = null;
            this._tokenProperty  = null;
            this._tokenNamespace = null;
            this.Advance();
            this.AdvanceOverWhitespace();
            if (this.IsAtEndOfInput)
            {
                this._token = MeTokenType.None;
            }
            else
            {
                switch (this.CurrentChar)
                {
                case '{':
                    this._token = MeTokenType.Open;
                    this._state = StringState.Type;
                    break;

                case '}':
                    this._token = MeTokenType.Close;
                    this._state = StringState.Value;
                    break;

                case '=':
                    this._token = MeTokenType.EqualSign;
                    this._state = StringState.Value;
                    break;

                case ',':
                    this._token = MeTokenType.Comma;
                    this._state = StringState.Value;
                    break;

                case '"':
                case '\'':
                    if (this.NextChar == '{')
                    {
                        flag = true;
                    }
                    flag2 = true;
                    break;

                default:
                    flag2 = true;
                    break;
                }
                if (flag2)
                {
                    string longName = this.ReadString();
                    this._token = flag ? MeTokenType.QuotedMarkupExtension : MeTokenType.String;
                    switch (this._state)
                    {
                    case StringState.Type:
                        this._token = MeTokenType.TypeName;
                        this.ResolveTypeName(longName);
                        break;

                    case StringState.Property:
                        this._token = MeTokenType.PropertyName;
                        this.ResolvePropertyName(longName);
                        break;
                    }
                    this._state     = StringState.Value;
                    this._tokenText = RemoveEscapes(longName);
                }
            }
        }