Package org.jacop.jasat.utils
Class CnfParser
- java.lang.Object
-
- org.jacop.jasat.utils.CnfParser
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCnfParser.ParseExceptionexception occurring during parse
-
Field Summary
Fields Modifier and Type Field Description private intcprivate booleanhasGivenIteratorprivate IntVecnextClauseintnumClausesintnumVarsprivate MemoryPoolpoolprivate java.io.InputStreamstream
-
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 booleanhasNext()java.util.Iterator<IntVec>iterator()to be called only once!IntVecnext()private intparseInt()reads an int from the streamprivate voidparseNextClause()parses the next clause from the streamprivate voidreadProblemDef()reads number of clauses and number of varsvoidremove()private voidskipComments()skips comment lines from the current positionprivate voidskipLine()skip the rest of the line (\n included)private voidskipSpaces()skips white spaces and carriage returns
-
-
-
Field Detail
-
numClauses
public int numClauses
-
numVars
public int numVars
-
stream
private java.io.InputStream stream
-
pool
private MemoryPool pool
-
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 usestream- the stream from which to read clauses- Throws:
CnfParser.ParseException- excpetion when parsing fails
-
-
Method Detail
-
parseInt
private int parseInt() throws java.io.IOExceptionreads an int from the stream- Returns:
- the parsed int
- Throws:
java.io.IOException
-
skipComments
private void skipComments() throws java.io.IOExceptionskips comment lines from the current position- Throws:
java.io.IOException
-
skipLine
private void skipLine() throws java.io.IOExceptionskip the rest of the line (\n included)- Throws:
java.io.IOException
-
skipSpaces
private void skipSpaces() throws java.io.IOExceptionskips white spaces and carriage returns- Throws:
java.io.IOException
-
readProblemDef
private void readProblemDef() throws java.io.IOExceptionreads 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:
hasNextin interfacejava.util.Iterator<IntVec>
-
remove
public void remove()
- Specified by:
removein interfacejava.util.Iterator<IntVec>
-
-