ABC: A System for Sequential Synthesis and Verification
Loading...
Searching...
No Matches
parse.hpp
Go to the documentation of this file.
1
#ifndef _parse_hpp_INCLUDED
2
#define _parse_hpp_INCLUDED
3
4
#include "
global.h
"
5
6
#include <cassert>
7
#include <vector>
8
9
ABC_NAMESPACE_CXX_HEADER_START
10
11
namespace
CaDiCaL
{
12
13
// Factors out common functions for parsing of DIMACS and solution files.
14
15
class
File
;
16
struct
External
;
17
struct
Internal
;
18
19
class
Parser
{
20
21
Solver
*solver;
22
Internal
*internal;
23
External
*external;
24
File
*file;
25
26
void
perr (
const
char
*fmt, ...)
CADICAL_ATTRIBUTE_FORMAT
(2, 3);
27
int
parse_char ();
28
29
enum
{
30
FORCED = 0,
// Force reading even if header is broken.
31
RELAXED = 1,
// Relaxed white space treatment in header.
32
STRICT = 2,
// Strict white space and header compliance.
33
};
34
35
const
char
*parse_string (
const
char
*str,
char
prev);
36
const
char
*parse_positive_int (
int
&ch,
int
&res,
const
char
*
name
);
37
const
char
*parse_lit (
int
&ch,
int
&
lit
,
int
&vars,
int
strict);
38
const
char
*parse_dimacs_non_profiled (
int
&vars,
int
strict);
39
const
char
*parse_solution_non_profiled ();
40
41
bool
*parse_inccnf_too;
42
vector<int>
*cubes;
43
44
public
:
45
// Parse a DIMACS CNF or ICNF file.
46
//
47
// Return zero if successful. Otherwise parse error.
48
Parser
(
Solver
*s,
File
*f,
bool
*i,
vector<int>
*c)
49
: solver (s), internal (s->internal), external (s->external),
50
file (f), parse_inccnf_too (i), cubes (c) {}
51
52
// Parse a DIMACS file. Return zero if successful. Otherwise a parse
53
// error is return. The parsed clauses are added to the solver and the
54
// maximum variable index found is returned in the 'vars' argument. The
55
// 'strict' argument can be '0' in which case the numbers in the header
56
// can be arbitrary, e.g., 'p cnf 0 0' all the time, without producing a
57
// parse error. Only for this setting the parsed literals are not checked
58
// to overflow the maximum variable index of the header. The strictest
59
// form of parsing is enforced for the value '2' of 'strict', in which
60
// case the header can not have additional white space, while a value of
61
// '1' exactly relaxes this, e.g., 'p cnf \t 1 3 \r\n' becomes legal.
62
//
63
const
char
*
parse_dimacs
(
int
&vars,
int
strict);
64
65
// Parse a solution file as used in the SAT competition, e.g., with
66
// comment lines 'c ...', a status line 's ...' and value lines 'v ...'.
67
// Returns zero if successful. Otherwise a string is returned describing
68
// the parse error. The parsed solution is saved in 'solution' and can be
69
// accessed with 'sol (int lit)'. We use it for checking learned clauses.
70
//
71
const
char
*
parse_solution
();
72
};
73
74
}
// namespace CaDiCaL
75
76
ABC_NAMESPACE_CXX_HEADER_END
77
78
#endif
ABC_NAMESPACE_CXX_HEADER_START
#define ABC_NAMESPACE_CXX_HEADER_START
Definition
abc_namespaces.h:52
ABC_NAMESPACE_CXX_HEADER_END
#define ABC_NAMESPACE_CXX_HEADER_END
Definition
abc_namespaces.h:53
global.h
CADICAL_ATTRIBUTE_FORMAT
#define CADICAL_ATTRIBUTE_FORMAT(FORMAT_POSITION, VARIADIC_ARGUMENT_POSITION)
Definition
cadical.hpp:1105
CaDiCaL::File
Definition
file.hpp:42
CaDiCaL::Parser::parse_dimacs
const char * parse_dimacs(int &vars, int strict)
Definition
cadical_parse.cpp:425
CaDiCaL::Parser::parse_solution
const char * parse_solution()
Definition
cadical_parse.cpp:433
CaDiCaL::Parser::Parser
Parser(Solver *s, File *f, bool *i, vector< int > *c)
Definition
parse.hpp:48
CaDiCaL::Solver
Definition
cadical.hpp:230
name
char * name
Definition
main.h:24
CaDiCaL
Definition
arena.hpp:8
lit
int lit
Definition
satVec.h:130
CaDiCaL::External
Definition
external.hpp:57
CaDiCaL::Internal
Definition
internal.hpp:136
vector
Definition
vector.h:32
src
sat
cadical
parse.hpp
Generated by Doxygen 1.13.2 © 2025 EPTansuo. All rights reserved.
鲁ICP备2021046540号