Class CnfParser

  • All Implemented Interfaces:
    java.lang.Iterable<IntVec>, java.util.Iterator<IntVec>

    public final class CnfParser
    extends java.lang.Object
    implements java.lang.Iterable<IntVec>, java.util.Iterator<IntVec>
    CNF file format (low-level) parser.
    Version:
    4.8
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  CnfParser.ParseException
      exception occurring during parse
    • Constructor Summary

      Constructors 
      Constructor Description
      CnfParser​(MemoryPool pool, java.io.InputStream stream)
      creates an instance of the parser for some input stream
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()  
      java.util.Iterator<IntVec> iterator()
      to be called only once!
      IntVec next()  
      private int parseInt()
      reads an int from the stream
      private void parseNextClause()
      parses the next clause from the stream
      private void readProblemDef()
      reads number of clauses and number of vars
      void remove()  
      private void skipComments()
      skips comment lines from the current position
      private void skipLine()
      skip the rest of the line (\n included)
      private void skipSpaces()
      skips white spaces and carriage returns
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Field Detail

      • numClauses

        public int numClauses
      • numVars

        public int numVars
      • stream

        private java.io.InputStream stream
      • c

        private int c
      • nextClause

        private IntVec nextClause
      • hasGivenIterator

        private boolean hasGivenIterator
    • Constructor Detail

      • CnfParser

        public CnfParser​(MemoryPool pool,
                         java.io.InputStream stream)
                  throws CnfParser.ParseException
        creates an instance of the parser for some input stream
        Parameters:
        pool - the memory pool to use
        stream - the stream from which to read clauses
        Throws:
        CnfParser.ParseException - excpetion when parsing fails
    • Method Detail

      • parseInt

        private int parseInt()
                      throws java.io.IOException
        reads an int from the stream
        Returns:
        the parsed int
        Throws:
        java.io.IOException
      • skipComments

        private void skipComments()
                           throws java.io.IOException
        skips comment lines from the current position
        Throws:
        java.io.IOException
      • skipLine

        private void skipLine()
                       throws java.io.IOException
        skip the rest of the line (\n included)
        Throws:
        java.io.IOException
      • skipSpaces

        private void skipSpaces()
                         throws java.io.IOException
        skips white spaces and carriage returns
        Throws:
        java.io.IOException
      • readProblemDef

        private void readProblemDef()
                             throws java.io.IOException
        reads number of clauses and number of vars
        Throws:
        java.io.IOException
      • parseNextClause

        private void parseNextClause()
        parses the next clause from the stream
      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<IntVec>
      • next

        public IntVec next()
        Specified by:
        next in interface java.util.Iterator<IntVec>
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<IntVec>
      • iterator

        public java.util.Iterator<IntVec> iterator()
        to be called only once!
        Specified by:
        iterator in interface java.lang.Iterable<IntVec>