Commit ec173a2e authored by David Hauzar's avatar David Hauzar

Parsing decimal numbers from CVC4 models.

parent 924c3f18
......@@ -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;
......
......@@ -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:
......
......@@ -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 }
......
......@@ -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 }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment