AddTag() private method

private AddTag ( Docear4Word.BibTex.TagEntry tagEntry ) : void
tagEntry Docear4Word.BibTex.TagEntry
return void
Esempio n. 1
0
        void ParseTag(BibTexDatabase database, Entry entry, string tagName)
        {
            Consume(TokenType.Equals);

            string value = null;
            Token  LastToken;

            while (true)
            {
                LastToken = Current;

                switch (Current.TokenType)
                {
                case TokenType.QuotedString:
                    value += Consume().Data;
                    break;

                case TokenType.BracedString:
                    value += Consume().Data;
                    break;

                case TokenType.Text:
                    var token = Consume().Data;
                    value += database.GetAbbreviation(token, token);

                    break;

                case TokenType.Hash:
                    break;

                default:
                    throw new NotImplementedException();
                }
                // [Allen] Check the invalid token like:
                // *************************
                // owner = {Norman}   # LastToken.TokenType == TokenType.BracedString
                // timestamp = {2012-07-19} # Current.TokenType == TokenType.Text
                // *************************
                if (LastToken.TokenType == TokenType.BracedString &&
                    Current.TokenType == TokenType.Text)
                {
                    throw new TemplateParseException("Unexpected token: " + LastToken.TokenType + ". Was expecting: '" + LastToken.Data + ",'", LastToken.Line, LastToken.Column);
                }

                if (Current.TokenType != TokenType.Hash)
                {
                    break;
                }

                Consume();
            }

            entry.AddTag(new TagEntry(tagName, value));
        }
Esempio n. 2
0
        void ParseTag(BibTexDatabase database, Entry entry, string tagName)
        {
            Consume(TokenType.Equals);

            string value = null;

            while (true)
            {
                switch (Current.TokenType)
                {
                case TokenType.QuotedString:
                    value += Consume().Data;
                    break;

                case TokenType.BracedString:
                    value += Consume().Data;
                    break;

                case TokenType.Text:
                    var token = Consume().Data;
                    value += database.GetAbbreviation(token, token);

                    break;

                case TokenType.Hash:
                    break;

                default:
                    throw new NotImplementedException();
                }

                if (Current.TokenType != TokenType.Hash)
                {
                    break;
                }
                Consume();
            }

            entry.AddTag(new TagEntry(tagName, value));
        }
Esempio n. 3
0
        void ParseTag(BibTexDatabase database, Entry entry, string tagName)
        {
            Consume(TokenType.Equals);

            string value = null;

            while(true)
            {
                switch (Current.TokenType)
                {
                    case TokenType.QuotedString:
                        value += Consume().Data;
                        break;

                    case TokenType.BracedString:
                        value += Consume().Data;
                        break;

                    case TokenType.Text:
                        var token = Consume().Data;
                        value += database.GetAbbreviation(token, token);

                        break;

                    case TokenType.Hash:
                        break;

                    default:
                        throw new NotImplementedException();
                }

                if (Current.TokenType != TokenType.Hash) break;
                Consume();
            }

            entry.AddTag(new TagEntry(tagName, value));
        }
Esempio n. 4
0
		void ParseTag(BibTexDatabase database, Entry entry, string tagName)
		{
			Consume(TokenType.Equals);

			string value = null;
            Token LastToken;
			while(true)
			{
                LastToken = Current;

				switch (Current.TokenType)
				{
					case TokenType.QuotedString:
						value += Consume().Data;
						break;

					case TokenType.BracedString:
						value += Consume().Data;
						break;

					case TokenType.Text:
						var token = Consume().Data;
						value += database.GetAbbreviation(token, token);

						break;

					case TokenType.Hash:
						break;

					default:
						throw new NotImplementedException();
				}
                // [Allen] Check the invalid token like:
                // *************************
                // owner = {Norman}   # LastToken.TokenType == TokenType.BracedString
                // timestamp = {2012-07-19} # Current.TokenType == TokenType.Text
                // *************************
                if (LastToken.TokenType == TokenType.BracedString &&
                    Current.TokenType == TokenType.Text )
                {
                    throw new TemplateParseException("Unexpected token: " + LastToken.TokenType + ". Was expecting: '" + LastToken.Data + ",'", LastToken.Line, LastToken.Column);
                }

				if (Current.TokenType != TokenType.Hash) break;

				Consume();
			} 

			entry.AddTag(new TagEntry(tagName, value));
		}