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
e5e479a7
Commit
e5e479a7
authored
Jun 25, 2015
by
Andrei Paskevich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parser: type declarations
parent
d96fd1c7
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
238 additions
and
232 deletions
+238
-232
src/mlw/pdecl.ml
src/mlw/pdecl.ml
+7
-3
src/parser/parser.mly
src/parser/parser.mly
+3
-3
src/parser/ptree.ml
src/parser/ptree.ml
+1
-1
src/parser/typing.ml
src/parser/typing.ml
+227
-225
No files found.
src/mlw/pdecl.ml
View file @
e5e479a7
...
...
@@ -71,6 +71,7 @@ let create_semi_constructor id s fl pjl invl =
create_rsymbol
id
c
let
create_flat_record_decl
id
args
priv
mut
fldl
invl
=
(* TODO: replace Invalid_argument by well-located error messages *)
let
exn
=
Invalid_argument
"Mdecl.create_flat_record_decl"
in
let
cid
=
id_fresh
?
loc
:
id
.
pre_loc
(
"mk "
^
id
.
pre_name
)
in
let
add_fd
fs
(
fm
,
fd
)
=
Mpv
.
add_new
exn
fd
fm
fs
in
...
...
@@ -117,6 +118,7 @@ let create_rec_record_decl s fldl =
mk_itd
s
pjl
[
cs
]
[]
let
create_variant_decl
get_its
cl
=
(* TODO: replace Invalid_argument by well-located error messages *)
let
exn
=
Invalid_argument
"Mdecl.create_variant_decl"
in
let
pjl
,
fds
=
match
cl
with
|
cs
::
cl
->
...
...
@@ -302,7 +304,9 @@ let create_type_decl dl =
|
fl
,
([{
rs_logic
=
RLnone
}]
|
[]
)
->
let
get_ld
s
ldd
=
match
s
.
rs_logic
with
|
RLls
s
->
create_param_decl
s
::
ldd
|
_
->
assert
false
in
create_ty_decl
s
.
its_ts
::
abst
,
defn
,
List
.
fold_right
get_ld
fl
proj
(* TODO: add axioms for the invariants *)
let
proj
=
List
.
fold_right
get_ld
fl
proj
in
create_ty_decl
s
.
its_ts
::
abst
,
defn
,
proj
|
fl
,
cl
->
let
add
s
f
=
Mpv
.
add
(
Opt
.
get
f
.
rs_field
)
f
s
in
let
mf
=
List
.
fold_left
add
Mpv
.
empty
fl
in
...
...
@@ -420,7 +424,7 @@ let print_its_defn fst fmt itd =
|
Some
f
->
fprintf
fmt
"@ (%a)"
print_field
f
|
_
when
f
.
pv_ghost
->
fprintf
fmt
"@ (ghost %a)"
print_ity
f
.
pv_ity
|
_
->
fprintf
fmt
"@ %a"
print_ity
f
.
pv_ity
in
let
print_constr
mf
fmt
c
=
fprintf
fmt
"@
\n
@[<hov 4
}
| %a%a%a@]"
let
print_constr
mf
fmt
c
=
fprintf
fmt
"@
\n
@[<hov 4
>
| %a%a%a@]"
print_rs
c
Pretty
.
print_id_labels
c
.
rs_name
(
Pp
.
print_list
Pp
.
nothing
(
print_proj
mf
))
c
.
rs_cty
.
cty_args
in
let
print_defn
fmt
()
=
...
...
@@ -437,7 +441,7 @@ let print_its_defn fst fmt itd =
|
_
,
fl
,
cl
->
let
add
s
f
=
Mpv
.
add
(
Opt
.
get
f
.
rs_field
)
f
s
in
let
mf
=
List
.
fold_left
add
Mpv
.
empty
fl
in
Pp
.
print_list
Pp
.
nothing
(
print_constr
mf
)
fmt
cl
in
fprintf
fmt
" =%a"
(
Pp
.
print_list
Pp
.
nothing
(
print_constr
mf
))
cl
in
let
print_inv
fmt
f
=
fprintf
fmt
"@
\n
@ invariant { %a }"
Pretty
.
print_term
f
in
fprintf
fmt
"@[<hov 2>%s %a%a%a%a%a%a@]"
...
...
src/parser/parser.mly
View file @
e5e479a7
...
...
@@ -195,11 +195,11 @@ use_clone:
use
:
|
boption
(
IMPORT
)
tqualid
{
{
use_
theory
=
$
2
;
use_import
=
Some
(
$
1
,
qualid_last
$
2
)
}
}
{
{
use_
module
=
$
2
;
use_import
=
Some
(
$
1
,
qualid_last
$
2
)
}
}
|
boption
(
IMPORT
)
tqualid
AS
uident
{
{
use_
theory
=
$
2
;
use_import
=
Some
(
$
1
,
$
4
.
id_str
)
}
}
{
{
use_
module
=
$
2
;
use_import
=
Some
(
$
1
,
$
4
.
id_str
)
}
}
|
EXPORT
tqualid
{
{
use_
theory
=
$
2
;
use_import
=
None
}
}
{
{
use_
module
=
$
2
;
use_import
=
None
}
}
clone_subst
:
|
NAMESPACE
ns
EQUAL
ns
{
CSns
(
floc
$
startpos
$
endpos
,
$
2
,$
4
)
}
...
...
src/parser/ptree.ml
View file @
e5e479a7
...
...
@@ -98,7 +98,7 @@ and term_desc =
(*s Declarations. *)
type
use
=
{
use_
theory
:
qualid
;
use_
module
:
qualid
;
use_import
:
(
bool
(* import *)
*
string
(* as *)
)
option
;
}
...
...
src/parser/typing.ml
View file @
e5e479a7
This diff is collapsed.
Click to expand it.
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