Esempio n. 1
0
		public EntryAndPagePair(Entry entry, string pageNumberOverride = null)
		{
			this.entry = entry;

			// Ensure page number override is trimmed and, if empty, reset to null
			if (pageNumberOverride != null)
			{
				pageNumberOverride = pageNumberOverride.Trim();

				if (pageNumberOverride.Length == 0) pageNumberOverride = null;
			}

			this.pageNumberOverride = pageNumberOverride;

			id = this.pageNumberOverride == null
			     	? entry.Name
			     	: entry.Name + "#" + pageNumberOverride;

			authors = entry["author", TagEntry.Empty].Display.Trim();
		}
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
        Entry ParseEntry(BibTexDatabase database, string entryType)
        {
            var entryName = Consume(TokenType.Text).Data;
            var entry = new Entry(entryType, entryName, Helper.GetClassificationForType(entryType));

            while(true)
            {
                var token = Consume();

                switch (token.TokenType)
                {
                    case TokenType.EOF:
                        return entry;

                    case TokenType.ClosingBrace:
                        return entry;

                    case TokenType.Equals:
                        break;

                    case TokenType.Comma:
                        break;

                    case TokenType.Text:
                        ParseTag(database, entry, token.Data);
                        break;

                    case TokenType.OpeningBrace:
                        break;

                    default:
                        throw new TemplateParseException("Unexpected token: " + token.TokenType.ToString() , currentToken.Line, currentToken.Column);
                }
            }
        }
Esempio n. 4
0
            public Converter(JSRawCitationItem item, Entry entry)
            {
                this.item = item;

                tags = entry.GetTagDictionary();
            }
Esempio n. 5
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));
		}