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
POTTIER Francois
menhir
Commits
4c046071
Commit
4c046071
authored
Jun 12, 2020
by
POTTIER Francois
Browse files
Add the constructor [PVarLocated] to the IL.
parent
c5a75a59
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/IL.ml
View file @
4c046071
...
...
@@ -11,6 +11,8 @@
(* *)
(******************************************************************************)
open
Positions
(* Abstract syntax of the language used for code production. *)
type
interface
=
...
...
@@ -219,6 +221,8 @@ and pattern =
(* Variable. *)
|
PVar
of
string
|
PVarLocated
of
string
located
(* The positions must not be dummies. Use [pvarlocated]. *)
(* Data deconstruction. Tuples of length 1 are considered nonexistent,
that is, [PTuple [p]] is considered the same pattern as [p]. *)
...
...
src/codeBits.ml
View file @
4c046071
...
...
@@ -16,6 +16,17 @@
open
IL
(* A smart constructor for [PVarLocated]. *)
let
pvarlocated
id
=
let
x
,
pos
=
Positions
.
decompose
id
in
let
pos1
=
Positions
.
start_of_position
pos
and
pos2
=
Positions
.
end_of_position
pos
in
if
pos1
==
Lexing
.
dummy_pos
||
pos2
==
Lexing
.
dummy_pos
then
PVar
x
else
PVarLocated
id
(* Tuples. *)
let
etuple
=
function
...
...
src/codeBits.mli
View file @
4c046071
...
...
@@ -14,8 +14,13 @@
(* This module provides a number of tiny functions that help produce
[IL] code. *)
open
Positions
open
IL
(* A smart constructor for [PVarLocated]. *)
val
pvarlocated
:
string
located
->
pattern
(* Tuples. *)
val
etuple
:
expr
list
->
expr
...
...
src/printer.ml
View file @
4c046071
...
...
@@ -468,6 +468,9 @@ and pat0 f = function
fprintf
f
"_"
|
PVar
x
->
var
f
x
|
PVarLocated
x
->
(* Turn [x] on the fly into a stretch and print that. *)
stretch
true
f
(
Lexer
.
stretch_of_id
x
)
|
PData
(
d
,
[]
)
->
var
f
d
|
PTuple
[]
->
...
...
src/rawPrinter.ml
View file @
4c046071
...
...
@@ -181,6 +181,9 @@ and pat = function
node
"pwildcard"
[]
|
PVar
x
->
node
"pvar"
[
string
x
]
|
PVarLocated
x
->
let
x
=
Positions
.
value
x
in
node
"pvar"
[
string
x
]
|
PTuple
ps
->
node
"ptuple"
(
pats
ps
)
|
PAnnot
(
p
,
t
)
->
...
...
src/traverse.ml
View file @
4c046071
...
...
@@ -47,6 +47,9 @@ class virtual ['env] env = object(self)
env
|
PVar
id
->
self
#
pvar
env
id
|
PVarLocated
id
->
let
id
=
Positions
.
value
id
in
self
#
pvar
env
id
|
PTuple
ps
|
POr
ps
|
PData
(
_
,
ps
)
->
...
...
@@ -546,4 +549,3 @@ class virtual ['env, 'a] fold = object (self)
List
.
fold_left
(
self
#
valdef
env
)
accu
defs
end
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