Commit e8a8118d authored by David Hauzar's avatar David Hauzar

Counterexamples for bitvectors.

Parsing bitvectors in the counterexample returned by the prover.
parent c5d3d0f4
...@@ -30,6 +30,7 @@ let debug = Debug.register_info_flag "model_parser" ...@@ -30,6 +30,7 @@ let debug = Debug.register_info_flag "model_parser"
type model_value = type model_value =
| Integer of string | Integer of string
| Array of model_array | Array of model_array
| Bitvector of int
| Unparsed of string | Unparsed of string
and arr_index = { and arr_index = {
arr_index_key : int; arr_index_key : int;
...@@ -82,6 +83,7 @@ print_model_value_sanit sanit_print fmt value = ...@@ -82,6 +83,7 @@ print_model_value_sanit sanit_print fmt value =
| Integer s -> sanit_print fmt s | Integer s -> sanit_print fmt s
| Unparsed s -> sanit_print fmt s | Unparsed s -> sanit_print fmt s
| Array a -> print_array sanit_print fmt a | Array a -> print_array sanit_print fmt a
| Bitvector v -> sanit_print fmt (string_of_int v)
let print_model_value fmt value = let print_model_value fmt value =
print_model_value_sanit (fun fmt s -> fprintf fmt "%s" s) fmt value print_model_value_sanit (fun fmt s -> fprintf fmt "%s" s) fmt value
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
type model_value = type model_value =
| Integer of string | Integer of string
| Array of model_array | Array of model_array
| Bitvector of int
| Unparsed of string | Unparsed of string
and arr_index = { and arr_index = {
arr_index_key : int; arr_index_key : int;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
let atom = [^'('')'' ''\t''\n'] let atom = [^'('')'' ''\t''\n']
let space = [' ''\t''\n'] let space = [' ''\t''\n']
let num = ['0'-'9']+
rule token = parse rule token = parse
| '\n' | '\n'
...@@ -18,8 +19,9 @@ rule token = parse ...@@ -18,8 +19,9 @@ rule token = parse
{ LPAREN } { LPAREN }
| ')' | ')'
{ RPAREN } { RPAREN }
| ['0'-'9']+ as integer | num as integer
{ INT_STR (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*(['0'-'9']+ as integer) { MINUS_INT_STR ("-"^integer) }
| atom+ as at { ATOM (at) } | atom+ as at { ATOM (at) }
| eof | eof
...@@ -27,4 +29,3 @@ rule token = parse ...@@ -27,4 +29,3 @@ rule token = parse
(* | space { SPACE } *) (* | space { SPACE } *)
| _ | _
{ raise SyntaxError } { raise SyntaxError }
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
%} %}
%start <Model_parser.model_element list> output %start <Model_parser.model_element list> output
%token <string> SPACE %token <string> SPACE
%token <string> ATOM %token <string> ATOM
%token STORE %token STORE
%token CONST %token CONST
%token AS %token AS
%token <string> INT_STR %token <string> INT_STR
%token <int> BITVECTOR_VALUE
%token <string> MINUS_INT_STR %token <string> MINUS_INT_STR
%token LPAREN RPAREN %token LPAREN RPAREN
%token EOF %token EOF
...@@ -54,6 +54,7 @@ value: ...@@ -54,6 +54,7 @@ value:
| integer { $1 } | integer { $1 }
| other_val_str { Model_parser.Unparsed $1 } | other_val_str { Model_parser.Unparsed $1 }
| array { Model_parser.Array $1 } | array { Model_parser.Array $1 }
| bitvector { Model_parser.Bitvector $1 }
integer: integer:
| INT_STR { Model_parser.Integer $1 } | INT_STR { Model_parser.Integer $1 }
...@@ -101,5 +102,11 @@ array: ...@@ -101,5 +102,11 @@ array:
RPAREN RPAREN
{ Model_parser.array_add_element ~array:$5 ~index:$7 ~value:$9 } { Model_parser.array_add_element ~array:$5 ~index:$7 ~value:$9 }
(* Example:
(_ bv2048 16) *)
bitvector:
| BITVECTOR_VALUE
{ $1 }
array_skipped_part: array_skipped_part:
| LPAREN term_list RPAREN {} | LPAREN term_list RPAREN {}
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