Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
why3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
121
Issues
121
List
Boards
Labels
Service Desk
Milestones
Merge Requests
15
Merge Requests
15
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Why3
why3
Commits
7f5cb496
Commit
7f5cb496
authored
Feb 14, 2018
by
François Bobot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factorize the naming convention for prefix infix mixfix
parent
c4928f7d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
94 additions
and
79 deletions
+94
-79
doc/api.tex
doc/api.tex
+3
-3
plugins/python/py_main.ml
plugins/python/py_main.ml
+3
-3
plugins/python/py_parser.mly
plugins/python/py_parser.mly
+7
-11
src/core/ident.ml
src/core/ident.ml
+18
-0
src/core/ident.mli
src/core/ident.mli
+16
-0
src/core/pretty.ml
src/core/pretty.ml
+3
-7
src/driver/driver_parser.mly
src/driver/driver_parser.mly
+6
-9
src/mlw/expr.ml
src/mlw/expr.ml
+6
-10
src/parser/parser.mly
src/parser/parser.mly
+32
-36
No files found.
doc/api.tex
View file @
7f5cb496
...
...
@@ -300,7 +300,7 @@ let four : Term.term =
let int
_
theory : Theory.theory =
Env.read
_
theory env ["int"] "Int"
let plus
_
symbol : Term.lsymbol =
Theory.ns
_
find
_
ls int
_
theory.Theory.th
_
export [
"infix
+"]
Theory.ns
_
find
_
ls int
_
theory.Theory.th
_
export [
Ident.infix "
+"]
let two
_
plus
_
two : Term.term =
Term.t
_
app
_
infer plus
_
symbol [two;two]
let fmla3 : Term.term = Term.t
_
equ two
_
plus
_
two four
...
...
@@ -332,9 +332,9 @@ obtain the symbols from \texttt{Int}.
let zero : Term.term =
Term.t
_
const (Number.ConstInt (Number.int
_
const
_
dec "0"))
let mult
_
symbol : Term.lsymbol =
Theory.ns
_
find
_
ls int
_
theory.Theory.th
_
export [
"infix
*"]
Theory.ns
_
find
_
ls int
_
theory.Theory.th
_
export [
Ident.infix "
*"]
let ge
_
symbol : Term.lsymbol =
Theory.ns
_
find
_
ls int
_
theory.Theory.th
_
export [
"infix
>="]
Theory.ns
_
find
_
ls int
_
theory.Theory.th
_
export [
Ident.infix "
>="]
\end{ocamlcode}
The next step is to introduce the variable
$
x
$
with the type int.
\begin{ocamlcode}
...
...
plugins/python/py_main.ml
View file @
7f5cb496
...
...
@@ -22,9 +22,9 @@ let () = Debug.set_flag Dterm.debug_ignore_unused_var
let
mk_id
~
loc
name
=
{
id_str
=
name
;
id_lab
=
[]
;
id_loc
=
loc
}
let
infix
~
loc
s
=
Qident
(
mk_id
~
loc
(
"infix "
^
s
))
let
prefix
~
loc
s
=
Qident
(
mk_id
~
loc
(
"prefix "
^
s
))
let
mixfix
~
loc
s
=
Qident
(
mk_id
~
loc
(
"mixfix "
^
s
))
let
infix
~
loc
s
=
Qident
(
mk_id
~
loc
(
Ident
.
infix
s
))
let
prefix
~
loc
s
=
Qident
(
mk_id
~
loc
(
Ident
.
prefix
s
))
let
mixfix
~
loc
s
=
Qident
(
mk_id
~
loc
(
Ident
.
mixfix
s
))
let
mk_expr
~
loc
d
=
{
expr_desc
=
d
;
expr_loc
=
loc
}
...
...
plugins/python/py_parser.mly
View file @
7f5cb496
...
...
@@ -34,12 +34,8 @@
let
empty_annotation
=
{
loop_invariant
=
[]
;
loop_variant
=
[]
}
let
infix
s
=
"infix "
^
s
let
prefix
s
=
"prefix "
^
s
let
mixfix
s
=
"mixfix "
^
s
let
get_op
s
e
=
Qident
(
mk_id
(
mixfix
"[]"
)
s
e
)
let
set_op
s
e
=
Qident
(
mk_id
(
mixfix
"[<-]"
)
s
e
)
let
get_op
s
e
=
Qident
(
mk_id
(
Ident
.
mixfix
"[]"
)
s
e
)
let
set_op
s
e
=
Qident
(
mk_id
(
Ident
.
mixfix
"[<-]"
)
s
e
)
let
empty_spec
=
{
sp_pre
=
[]
;
sp_post
=
[]
;
sp_xpost
=
[]
;
...
...
@@ -328,9 +324,9 @@ term_sub_:
|
AND
{
Tand
}
%
inline
infix_op
:
|
PLUS
{
mk_id
(
infix
"+"
)
$
startpos
$
endpos
}
|
MINUS
{
mk_id
(
infix
"-"
)
$
startpos
$
endpos
}
|
TIMES
{
mk_id
(
infix
"*"
)
$
startpos
$
endpos
}
|
PLUS
{
mk_id
(
Ident
.
infix
"+"
)
$
startpos
$
endpos
}
|
MINUS
{
mk_id
(
Ident
.
infix
"-"
)
$
startpos
$
endpos
}
|
TIMES
{
mk_id
(
Ident
.
infix
"*"
)
$
startpos
$
endpos
}
|
c
=
CMP
{
let
op
=
match
c
with
|
Beq
->
"="
|
Bneq
->
"<>"
...
...
@@ -339,10 +335,10 @@ term_sub_:
|
Bgt
->
">"
|
Bge
->
">="
|
Badd
|
Bsub
|
Bmul
|
Bdiv
|
Bmod
|
Band
|
Bor
->
assert
false
in
mk_id
(
infix
op
)
$
startpos
$
endpos
}
mk_id
(
Ident
.
infix
op
)
$
startpos
$
endpos
}
%
inline
prefix_op
:
|
MINUS
{
mk_id
(
prefix
"-"
)
$
startpos
$
endpos
}
|
MINUS
{
mk_id
(
Ident
.
prefix
"-"
)
$
startpos
$
endpos
}
%
inline
div_mod_op
:
|
DIV
{
mk_id
"div"
$
startpos
$
endpos
}
...
...
src/core/ident.ml
View file @
7f5cb496
...
...
@@ -99,6 +99,24 @@ let get_model_trace_string ~labels =
|
_
->
""
(** Naming convention *)
let
infix
s
=
"infix "
^
s
let
prefix
s
=
"prefix "
^
s
let
mixfix
s
=
"mixfix "
^
s
let
kind_of_fix
s
=
let
len
=
String
.
length
s
in
if
len
<
7
then
`None
else
let
inf
=
String
.
sub
s
0
6
in
if
inf
=
"infix "
then
`Infix
(
String
.
sub
s
6
(
len
-
6
))
else
let
prf
=
String
.
sub
s
0
7
in
if
prf
=
"prefix "
then
`Prefix
(
String
.
sub
s
7
(
len
-
7
))
else
let
prf
=
String
.
sub
s
0
7
in
if
prf
=
"mixfix "
then
`Mixfix
(
String
.
sub
s
7
(
len
-
7
))
else
`None
(** Identifiers *)
type
ident
=
{
...
...
src/core/ident.mli
View file @
7f5cb496
...
...
@@ -60,6 +60,22 @@ val get_model_trace_label : labels : Slab.t -> Slab.elt
(** Return a label of the form ["model_trace:*"].
Throws [Not_found] if there is no such label. *)
(** {2 Naming convention } *)
val
infix
:
string
->
string
(** Apply the naming convention for infix operator (+) *)
val
prefix
:
string
->
string
(** Apply the naming convention for prefix operator *)
val
mixfix
:
string
->
string
(** Apply the naming convention for mixfix operator *)
val
kind_of_fix
:
string
->
[
`None
|
`Prefix
of
string
|
`Infix
of
string
|
`Mixfix
of
string
]
(** {2 Identifiers} *)
type
ident
=
private
{
...
...
src/core/pretty.ml
View file @
7f5cb496
...
...
@@ -76,13 +76,9 @@ let forget_var vs = forget_id iprinter vs.vs_name
let
extract_op
ls
=
let
s
=
ls
.
ls_name
.
id_string
in
let
len
=
String
.
length
s
in
if
len
<
7
then
None
else
let
inf
=
String
.
sub
s
0
6
in
if
inf
=
"infix "
then
Some
(
String
.
sub
s
6
(
len
-
6
))
else
let
prf
=
String
.
sub
s
0
7
in
if
prf
=
"prefix "
then
Some
(
String
.
sub
s
7
(
len
-
7
))
else
None
match
Ident
.
kind_of_fix
s
with
|
`None
|
`Mixfix
_
->
None
|
`Prefix
s
|
`Infix
s
->
Some
s
let
tight_op
s
=
let
c
=
String
.
sub
s
0
1
in
c
=
"!"
||
c
=
"?"
...
...
src/driver/driver_parser.mly
View file @
7f5cb496
...
...
@@ -12,9 +12,6 @@
%
{
open
Driver_ast
let
infix
s
=
"infix "
^
s
let
prefix
s
=
"prefix "
^
s
let
mixfix
s
=
"mixfix "
^
s
%
}
%
token
<
int
>
INTEGER
...
...
@@ -136,15 +133,15 @@ ident:
ident_rich
:
|
ident
{
$
1
}
|
LEFTPAR_STAR_RIGHTPAR
{
infix
"*"
}
|
LEFTPAR_STAR_RIGHTPAR
{
Ident
.
infix
"*"
}
|
LEFTPAR
operator
RIGHTPAR
{
$
2
}
operator
:
|
OPERATOR
{
infix
$
1
}
|
OPERATOR
UNDERSCORE
{
prefix
$
1
}
|
LEFTSQ
RIGHTSQ
{
mixfix
"[]"
}
|
LEFTSQ
LARROW
RIGHTSQ
{
mixfix
"[<-]"
}
|
LEFTSQ
RIGHTSQ
LARROW
{
mixfix
"[]<-"
}
|
OPERATOR
{
Ident
.
infix
$
1
}
|
OPERATOR
UNDERSCORE
{
Ident
.
prefix
$
1
}
|
LEFTSQ
RIGHTSQ
{
Ident
.
mixfix
"[]"
}
|
LEFTSQ
LARROW
RIGHTSQ
{
Ident
.
mixfix
"[<-]"
}
|
LEFTSQ
RIGHTSQ
LARROW
{
Ident
.
mixfix
"[]<-"
}
(* Types *)
...
...
src/mlw/expr.ml
View file @
7f5cb496
...
...
@@ -866,20 +866,16 @@ let forget_let_defn = function
let
extract_op
s
=
let
s
=
s
.
rs_name
.
id_string
in
let
len
=
String
.
length
s
in
if
len
<
7
then
None
else
let
inf
=
String
.
sub
s
0
6
in
if
inf
=
"infix "
then
Some
(
String
.
sub
s
6
(
len
-
6
))
else
let
prf
=
String
.
sub
s
0
7
in
if
prf
=
"prefix "
then
Some
(
String
.
sub
s
7
(
len
-
7
))
else
None
match
Ident
.
kind_of_fix
s
with
|
`None
|
`Mixfix
_
->
None
|
`Prefix
s
|
`Infix
s
->
Some
s
let
tight_op
s
=
let
c
=
String
.
sub
s
0
1
in
c
=
"!"
||
c
=
"?"
let
print_rs
fmt
s
=
if
s
.
rs_name
.
id_string
=
"mixfix
[]"
then
pp_print_string
fmt
"([])"
else
if
s
.
rs_name
.
id_string
=
"mixfix
[]<-"
then
pp_print_string
fmt
"([]<-)"
else
if
s
.
rs_name
.
id_string
=
"mixfix
[<-]"
then
pp_print_string
fmt
"([<-])"
else
if
s
.
rs_name
.
id_string
=
Ident
.
mixfix
"
[]"
then
pp_print_string
fmt
"([])"
else
if
s
.
rs_name
.
id_string
=
Ident
.
mixfix
"
[]<-"
then
pp_print_string
fmt
"([]<-)"
else
if
s
.
rs_name
.
id_string
=
Ident
.
mixfix
"
[<-]"
then
pp_print_string
fmt
"([<-])"
else
match
extract_op
s
,
s
.
rs_logic
with
|
Some
s
,
_
->
let
s
=
Str
.
replace_first
(
Str
.
regexp
"^
\\
*."
)
"
\\
0"
s
in
...
...
src/parser/parser.mly
View file @
7f5cb496
...
...
@@ -27,10 +27,6 @@ end
open
Ptree
let
infix
s
=
"infix "
^
s
let
prefix
s
=
"prefix "
^
s
let
mixfix
s
=
"mixfix "
^
s
let
qualid_last
=
function
Qident
x
|
Qdot
(
_
,
x
)
->
x
.
id_str
let
floc
s
e
=
Loc
.
extract
(
s
,
e
)
...
...
@@ -90,11 +86,11 @@ end
let
mk_id
id
s
e
=
{
id_str
=
id
;
id_lab
=
[]
;
id_loc
=
floc
s
e
}
let
get_op
s
e
=
Qident
(
mk_id
(
mixfix
"[]"
)
s
e
)
let
set_op
s
e
=
Qident
(
mk_id
(
mixfix
"[<-]"
)
s
e
)
let
sub_op
s
e
=
Qident
(
mk_id
(
mixfix
"[_.._]"
)
s
e
)
let
above_op
s
e
=
Qident
(
mk_id
(
mixfix
"[_..]"
)
s
e
)
let
below_op
s
e
=
Qident
(
mk_id
(
mixfix
"[.._]"
)
s
e
)
let
get_op
s
e
=
Qident
(
mk_id
(
Ident
.
mixfix
"[]"
)
s
e
)
let
set_op
s
e
=
Qident
(
mk_id
(
Ident
.
mixfix
"[<-]"
)
s
e
)
let
sub_op
s
e
=
Qident
(
mk_id
(
Ident
.
mixfix
"[_.._]"
)
s
e
)
let
above_op
s
e
=
Qident
(
mk_id
(
Ident
.
mixfix
"[_..]"
)
s
e
)
let
below_op
s
e
=
Qident
(
mk_id
(
Ident
.
mixfix
"[.._]"
)
s
e
)
let
mk_pat
d
s
e
=
{
pat_desc
=
d
;
pat_loc
=
floc
s
e
}
let
mk_term
d
s
e
=
{
term_desc
=
d
;
term_loc
=
floc
s
e
}
...
...
@@ -729,8 +725,8 @@ expr_:
|
expr
LARROW
expr
{
match
$
1
.
expr_desc
with
|
Eidapp
(
q
,
[
e1
])
->
Eassign
(
e1
,
q
,
$
3
)
|
Eidapp
(
Qident
id
,
[
e1
;
e2
])
when
id
.
id_str
=
mixfix
"[]"
->
Eidapp
(
Qident
{
id
with
id_str
=
mixfix
"[]<-"
}
,
[
e1
;
e2
;
$
3
])
|
Eidapp
(
Qident
id
,
[
e1
;
e2
])
when
id
.
id_str
=
Ident
.
mixfix
"[]"
->
Eidapp
(
Qident
{
id
with
id_str
=
Ident
.
mixfix
"[]<-"
}
,
[
e1
;
e2
;
$
3
])
|
_
->
raise
Error
}
|
LET
top_ghost
pattern
EQUAL
seq_expr
IN
seq_expr
{
match
$
3
.
pat_desc
with
...
...
@@ -993,21 +989,21 @@ lident_op_id:
{
(* parentheses are removed from the location *)
let
s
=
let
s
=
$
startpos
in
{
s
with
Lexing
.
pos_cnum
=
s
.
Lexing
.
pos_cnum
+
1
}
in
let
e
=
let
e
=
$
endpos
in
{
e
with
Lexing
.
pos_cnum
=
e
.
Lexing
.
pos_cnum
-
1
}
in
mk_id
(
infix
"*"
)
s
e
}
mk_id
(
Ident
.
infix
"*"
)
s
e
}
lident_op
:
|
op_symbol
{
infix
$
1
}
|
op_symbol
UNDERSCORE
{
prefix
$
1
}
|
MINUS
UNDERSCORE
{
prefix
"-"
}
|
EQUAL
{
infix
"="
}
|
MINUS
{
infix
"-"
}
|
OPPREF
{
prefix
$
1
}
|
LEFTSQ
RIGHTSQ
{
mixfix
"[]"
}
|
LEFTSQ
LARROW
RIGHTSQ
{
mixfix
"[<-]"
}
|
LEFTSQ
RIGHTSQ
LARROW
{
mixfix
"[]<-"
}
|
LEFTSQ
UNDERSCORE
DOTDOT
UNDERSCORE
RIGHTSQ
{
mixfix
"[_.._]"
}
|
LEFTSQ
DOTDOT
UNDERSCORE
RIGHTSQ
{
mixfix
"[.._]"
}
|
LEFTSQ
UNDERSCORE
DOTDOT
RIGHTSQ
{
mixfix
"[_..]"
}
|
op_symbol
{
Ident
.
infix
$
1
}
|
op_symbol
UNDERSCORE
{
Ident
.
prefix
$
1
}
|
MINUS
UNDERSCORE
{
Ident
.
prefix
"-"
}
|
EQUAL
{
Ident
.
infix
"="
}
|
MINUS
{
Ident
.
infix
"-"
}
|
OPPREF
{
Ident
.
prefix
$
1
}
|
LEFTSQ
RIGHTSQ
{
Ident
.
mixfix
"[]"
}
|
LEFTSQ
LARROW
RIGHTSQ
{
Ident
.
mixfix
"[<-]"
}
|
LEFTSQ
RIGHTSQ
LARROW
{
Ident
.
mixfix
"[]<-"
}
|
LEFTSQ
UNDERSCORE
DOTDOT
UNDERSCORE
RIGHTSQ
{
Ident
.
mixfix
"[_.._]"
}
|
LEFTSQ
DOTDOT
UNDERSCORE
RIGHTSQ
{
Ident
.
mixfix
"[.._]"
}
|
LEFTSQ
UNDERSCORE
DOTDOT
RIGHTSQ
{
Ident
.
mixfix
"[_..]"
}
op_symbol
:
|
OP1
{
$
1
}
...
...
@@ -1018,22 +1014,22 @@ op_symbol:
|
GT
{
">"
}
%
inline
oppref
:
|
o
=
OPPREF
{
mk_id
(
prefix
o
)
$
startpos
$
endpos
}
|
o
=
OPPREF
{
mk_id
(
Ident
.
prefix
o
)
$
startpos
$
endpos
}
prefix_op
:
|
op_symbol
{
mk_id
(
prefix
$
1
)
$
startpos
$
endpos
}
|
MINUS
{
mk_id
(
prefix
"-"
)
$
startpos
$
endpos
}
|
op_symbol
{
mk_id
(
Ident
.
prefix
$
1
)
$
startpos
$
endpos
}
|
MINUS
{
mk_id
(
Ident
.
prefix
"-"
)
$
startpos
$
endpos
}
%
inline
infix_op
:
|
o
=
OP1
{
mk_id
(
infix
o
)
$
startpos
$
endpos
}
|
o
=
OP2
{
mk_id
(
infix
o
)
$
startpos
$
endpos
}
|
o
=
OP3
{
mk_id
(
infix
o
)
$
startpos
$
endpos
}
|
o
=
OP4
{
mk_id
(
infix
o
)
$
startpos
$
endpos
}
|
EQUAL
{
mk_id
(
infix
"="
)
$
startpos
$
endpos
}
|
LTGT
{
mk_id
(
infix
"<>"
)
$
startpos
$
endpos
}
|
LT
{
mk_id
(
infix
"<"
)
$
startpos
$
endpos
}
|
GT
{
mk_id
(
infix
">"
)
$
startpos
$
endpos
}
|
MINUS
{
mk_id
(
infix
"-"
)
$
startpos
$
endpos
}
|
o
=
OP1
{
mk_id
(
Ident
.
infix
o
)
$
startpos
$
endpos
}
|
o
=
OP2
{
mk_id
(
Ident
.
infix
o
)
$
startpos
$
endpos
}
|
o
=
OP3
{
mk_id
(
Ident
.
infix
o
)
$
startpos
$
endpos
}
|
o
=
OP4
{
mk_id
(
Ident
.
infix
o
)
$
startpos
$
endpos
}
|
EQUAL
{
mk_id
(
Ident
.
infix
"="
)
$
startpos
$
endpos
}
|
LTGT
{
mk_id
(
Ident
.
infix
"<>"
)
$
startpos
$
endpos
}
|
LT
{
mk_id
(
Ident
.
infix
"<"
)
$
startpos
$
endpos
}
|
GT
{
mk_id
(
Ident
.
infix
">"
)
$
startpos
$
endpos
}
|
MINUS
{
mk_id
(
Ident
.
infix
"-"
)
$
startpos
$
endpos
}
(* Qualified idents *)
...
...
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