Package org.jacop.jasat.utils
Class CnfParser
java.lang.Object
org.jacop.jasat.utils.CnfParser
CNF file format (low-level) parser.
- Version:
- 4.10
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classexception occurring during parse -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate booleanprivate IntVecintintprivate MemoryPoolprivate InputStream -
Constructor Summary
ConstructorsConstructorDescriptionCnfParser(MemoryPool pool, InputStream stream) creates an instance of the parser for some input stream -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasNext()iterator()to be called only once!next()private intparseInt()reads an int from the streamprivate voidparses the next clause from the streamprivate voidreads number of clauses and number of varsvoidremove()private voidskips comment lines from the current positionprivate voidskipLine()skip the rest of the line (\n included)private voidskips white spaces and carriage returnsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
numClauses
public int numClauses -
numVars
public int numVars -
stream
-
pool
-
c
private int c -
nextClause
-
hasGivenIterator
private boolean hasGivenIterator
-
-
Constructor Details
-
CnfParser
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 Details
-
parseInt
reads an int from the stream- Returns:
- the parsed int
- Throws:
IOException
-
skipComments
skips comment lines from the current position- Throws:
IOException
-
skipLine
skip the rest of the line (\n included)- Throws:
IOException
-
skipSpaces
skips white spaces and carriage returns- Throws:
IOException
-
readProblemDef
reads number of clauses and number of vars- Throws:
IOException
-
parseNextClause
private void parseNextClause()parses the next clause from the stream -
hasNext
public boolean hasNext() -
next
-
remove
public void remove() -
iterator
to be called only once!
-