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 class
CnfParser.ParseException
exception occurring during parse
-
Field Summary
Fields Modifier and Type Field Description private int
c
private boolean
hasGivenIterator
private IntVec
nextClause
int
numClauses
int
numVars
private MemoryPool
pool
private java.io.InputStream
stream
-
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 streamprivate void
parseNextClause()
parses the next clause from the streamprivate void
readProblemDef()
reads number of clauses and number of varsvoid
remove()
private void
skipComments()
skips comment lines from the current positionprivate void
skipLine()
skip the rest of the line (\n included)private void
skipSpaces()
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.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 interfacejava.util.Iterator<IntVec>
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<IntVec>
-
-