Ejemplo n.º 1
0
        public List <TokenXRefEntry> IndirectObjectsToXRef()
        {
            List <TokenXRefEntry> entries = new List <TokenXRefEntry>();

            // Start scanning from beginning of the source
            Tokenizer.IgnoreComments = false;
            Tokenizer.Position       = 0;

            long lastTrailer = -1;

            do
            {
                long        t1Position = Tokenizer.Position;
                TokenObject t1         = Tokenizer.GetToken();
                if (t1 is TokenInteger)
                {
                    TokenInteger t2 = Tokenizer.GetToken() as TokenInteger;
                    if (t2 != null)
                    {
                        TokenKeyword t3 = Tokenizer.GetToken() as TokenKeyword;
                        if ((t3 != null) && (t3.Value == ParseKeyword.Obj))
                        {
                            TokenInteger id = (TokenInteger)t1;
                            entries.Add(new TokenXRefEntry(id.Value, t2.Value, t1Position, true));
                        }
                    }
                }
                else if ((t1 is TokenKeyword) && ((TokenKeyword)t1).Value == ParseKeyword.Trailer)
                {
                    lastTrailer = t1Position;
                }
            } while (Tokenizer.GotoNextLine());

            // Leave with the position on the last 'trailer' as caller will then parse it
            if (lastTrailer >= 0)
            {
                Tokenizer.Position = lastTrailer;
            }

            return(entries);
        }
Ejemplo n.º 2
0
        public void ParseXRefSections(List <TokenXRefEntry> entries)
        {
            while (true)
            {
                TokenObject t = Tokenizer.GetToken();
                ThrowOnError(t);

                // Cross-reference table ends when we find a 'trailer' keyword instead of another section
                if ((t is TokenKeyword) && (((TokenKeyword)t).Value == ParseKeyword.Trailer))
                {
                    Tokenizer.PushToken(t);
                    return;
                }

                // Section starts with an integer object number
                TokenInteger start = t as TokenInteger;
                if (start == null)
                {
                    throw new ApplicationException($"Cross-reference section number must be an integer.");
                }

                t = Tokenizer.GetToken();
                ThrowOnError(t);

                // Section then has an integer length number
                TokenInteger length = t as TokenInteger;
                if (length == null)
                {
                    throw new ApplicationException($"Cross-reference section length must be an integer.");
                }

                // Load each line in the section
                for (int i = 0, id = start.Value; i < length.Value; i++, id++)
                {
                    TokenObject entry = Tokenizer.GetXRefEntry(id);
                    ThrowOnError(entry);
                    entries.Add((TokenXRefEntry)entry);
                }
            }
        }
Ejemplo n.º 3
0
 public ParseInteger(TokenInteger token)
 {
     Value = token.Value;
 }
Ejemplo n.º 4
0
 public ParseIndirectObject(TokenInteger id, TokenInteger gen, ParseObjectBase obj)
 {
     Id     = id.Value;
     Gen    = gen.Value;
     Object = obj;
 }
Ejemplo n.º 5
0
 public ParseObjectReference(TokenInteger id, TokenInteger gen)
 {
     Id  = id.Value;
     Gen = gen.Value;
 }