Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Why3
why3
Commits
ec173a2e
Commit
ec173a2e
authored
Oct 06, 2015
by
David Hauzar
Browse files
Parsing decimal numbers from CVC4 models.
parent
924c3f18
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/core/model_parser.ml
View file @
ec173a2e
...
...
@@ -29,6 +29,7 @@ let debug = Debug.register_info_flag "model_parser"
type
model_value
=
|
Integer
of
string
|
Decimal
of
(
string
*
string
)
|
Array
of
model_array
|
Bitvector
of
int
|
Unparsed
of
string
...
...
@@ -80,6 +81,10 @@ print_model_value_sanit sanit_print fmt value =
(* Prints model value. *)
match
value
with
|
Integer
s
->
sanit_print
fmt
s
|
Decimal
(
int_part
,
fract_part
)
->
sanit_print
fmt
int_part
;
sanit_print
fmt
"."
;
sanit_print
fmt
fract_part
;
|
Unparsed
s
->
sanit_print
fmt
s
|
Array
a
->
print_array
str_formatter
a
;
...
...
src/core/model_parser.mli
View file @
ec173a2e
...
...
@@ -16,6 +16,7 @@
*)
type
model_value
=
|
Integer
of
string
|
Decimal
of
(
string
*
string
)
|
Array
of
model_array
|
Bitvector
of
int
|
Unparsed
of
string
...
...
@@ -171,13 +172,16 @@ val print_model_json :
(** Prints counter-example model to json format.
@param me_name_trans see print_model
@param vc_line_trans the transformation of the line corresponding to the term
that triggers VC to the name of JSON field storing counterexample information
related to this term.
It can be used to store the counterexample information related to this term
in dedicated JSON field in cases where the exact line of this term cannot be
computed - this can happen when VC is splitted.
By default, string_of_int
@param vc_line_trans the transformation from the line number corresponding
to the term that triggers VC before splitting VC to the name of JSON field
storing counterexample information related to this term. By default, this
information is stored in JSON field corresponding to this line, i.e.,
the transformation is string_of_int.
Note that the exact line of the construct that triggers VC may not be
known. This can happen if the term that triggers VC spans multiple lines
and it is splitted.
This transformation can be used to store the counterexample information
related to this term in dedicated JSON field.
@model the counter-example model to print.
The format is the following:
...
...
src/driver/parse_smtv2_model_lexer.mll
View file @
ec173a2e
...
...
@@ -6,6 +6,7 @@
let
atom
=
[
^
'
(
''
)
''
'
'\t''\n'
]
let
space
=
[
'
'
'\t''\n'
]
let
num
=
[
'
0
'
-
'
9
'
]
+
let
dec_num
=
num
"."
num
rule
token
=
parse
|
'\n'
...
...
@@ -19,10 +20,14 @@ rule token = parse
{
LPAREN
}
|
'
)
'
{
RPAREN
}
|
"(_ bv"
(
num
as
bv_value
)
" "
num
")"
{
BITVECTOR_VALUE
(
int_of_string
bv_value
)
}
|
num
as
integer
{
INT_STR
(
integer
)
}
|
"(_ bv"
(
num
as
bv_value
)
" "
num
")"
{
BITVECTOR_VALUE
(
int_of_string
bv_value
)
}
|
'
-
'
space
*
([
'
0
'
-
'
9
'
]
+
as
integer
)
{
MINUS_INT_STR
(
"-"
^
integer
)
}
|
'
-
'
space
*
(
num
as
integer
)
{
MINUS_INT_STR
(
"-"
^
integer
)
}
|
(
num
as
int_part
)
"."
(
num
as
fract_part
)
{
DEC_STR
(
int_part
,
fract_part
)
}
|
'
-
'
space
*
(
num
as
int_part
)
"."
(
num
as
fract_part
)
{
MINUS_DEC_STR
((
"-"
^
int_part
)
,
fract_part
)}
|
atom
+
as
at
{
ATOM
(
at
)
}
|
eof
{
EOF
}
...
...
src/driver/parse_smtv2_model_parser.mly
View file @
ec173a2e
...
...
@@ -7,9 +7,11 @@
%
token
STORE
%
token
CONST
%
token
AS
%
token
<
string
>
INT_STR
%
token
<
int
>
BITVECTOR_VALUE
%
token
<
string
>
INT_STR
%
token
<
string
>
MINUS_INT_STR
%
token
<
string
*
string
>
DEC_STR
%
token
<
string
*
string
>
MINUS_DEC_STR
%
token
LPAREN
RPAREN
%
token
EOF
%%
...
...
@@ -52,6 +54,7 @@ text_without_int:
value
:
|
integer
{
$
1
}
|
decimal
{
$
1
}
|
other_val_str
{
Model_parser
.
Unparsed
$
1
}
|
array
{
Model_parser
.
Array
$
1
}
|
bitvector
{
Model_parser
.
Bitvector
$
1
}
...
...
@@ -61,6 +64,11 @@ integer:
|
LPAREN
possible_space
MINUS_INT_STR
possible_space
RPAREN
{
Model_parser
.
Integer
$
3
}
decimal
:
|
DEC_STR
{
Model_parser
.
Decimal
$
1
}
|
LPAREN
possible_space
MINUS_DEC_STR
possible_space
RPAREN
{
Model_parser
.
Decimal
(
$
3
)
}
(* Everything that cannot be integer (positive and negative) and array. *)
other_val_str
:
|
text_without_int
{
$
1
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment