Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
grew
libcaml-grew
Commits
c91fbd08
Commit
c91fbd08
authored
Aug 17, 2017
by
Bruno Guillaume
Browse files
remove aborted strategy definition
parent
2e4bfc9d
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/grew_grs.ml
View file @
c91fbd08
...
...
@@ -350,57 +350,7 @@ module Grs = struct
|
Ast
.
Sequence
module_list
->
loop
inst
(
new_style
grs
module_list
)
in
loop
inst
strat
let
simple_rewrite
grs
strat_desc
graph
=
let
rec
loop
inst
=
function
(* name can refer to another strategy def or to a module *)
|
Ast
.
Ref
name
->
begin
try
let
sub_strat
=
List
.
find
(
fun
s
->
s
.
Ast
.
strat_name
=
name
)
grs
.
strategies
in
loop
inst
sub_strat
.
Ast
.
strat_def
with
Not_found
->
let
modul
=
try
List
.
find
(
fun
m
->
m
.
Modul
.
name
=
name
)
grs
.
modules
with
Not_found
->
Error
.
build
"No module or strategy named '%s'"
name
in
Rule
.
one_step
?
domain
:
grs
.
domain
inst
modul
.
Modul
.
rules
end
(* Union of strategies *)
|
Ast
.
Plus
strat_list
->
List
.
fold_left
(
fun
acc
strat
->
Instance_set
.
union
acc
(
loop
inst
strat
))
Instance_set
.
empty
strat_list
(* Sequence of strategies *)
|
Ast
.
Seq
[]
->
Log
.
fcritical
"Empty sequence in strategy definition"
|
Ast
.
Seq
[
one
]
->
loop
inst
one
|
Ast
.
Seq
(
head
::
tail
)
->
let
after_first_mod
=
loop
inst
head
in
Instance_set
.
fold
(
fun
new_inst
acc
->
Instance_set
.
union
acc
(
loop
new_inst
(
Ast
.
Seq
tail
)))
after_first_mod
Instance_set
.
empty
(* Interation of a strategy *)
|
Ast
.
Star
sub_strat
->
let
one_iter
=
loop
inst
sub_strat
in
if
Instance_set
.
is_empty
one_iter
then
Instance_set
.
singleton
inst
else
Instance_set
.
fold
(
fun
new_inst
acc
->
Instance_set
.
union
acc
(
loop
new_inst
(
Ast
.
Star
sub_strat
)))
one_iter
Instance_set
.
empty
(* Pick *)
|
Ast
.
Pick
sub_strat
->
begin
match
one_rewrite
grs
sub_strat
inst
with
|
Some
new_inst
->
Instance_set
.
singleton
new_inst
|
None
->
Instance_set
.
empty
end
(* Try *)
|
Ast
.
Try
sub_strat
->
begin
match
one_rewrite
grs
sub_strat
inst
with
|
Some
new_inst
->
Instance_set
.
singleton
new_inst
|
None
->
Instance_set
.
singleton
inst
end
(* Bang *)
|
Ast
.
Bang
sub_strat
->
loop
inst
(
Ast
.
Pick
(
Ast
.
Star
sub_strat
))
(* Old style seq definition *)
|
Ast
.
Sequence
module_list
->
loop
inst
(
new_style
grs
module_list
)
in
List
.
map
(
fun
inst
->
inst
.
Instance
.
graph
)
(
Instance_set
.
elements
(
loop
(
Instance
.
from_graph
graph
)
(
Parser
.
strat_def
strat_desc
)))
let
simple_rewrite
grs
strat_desc
graph
=
failwith
"OBSOLETE [Grs.simple_rewrite]"
(* ---------------------------------------------------------------------------------------------------- *)
(* construction of the rew_display *)
...
...
@@ -571,7 +521,6 @@ module Grs = struct
(
fun
modul
->
List
.
iter
(
fun
rule
->
fct
modul
.
Modul
.
name
rule
)
modul
.
Modul
.
rules
)
grs
.
modules
end
(* module Grs *)
...
...
src/grew_loader.ml
View file @
c91fbd08
...
...
@@ -243,15 +243,6 @@ module Parser = struct
pattern
with
Sys_error
msg
->
Error
.
parse
"[Grew_loader.Parser.pattern] %s"
msg
(* ------------------------------------------------------------------------------------------*)
let
strat_def
desc
=
try
Global
.
new_string
()
;
let
lexbuf
=
Lexing
.
from_string
desc
in
let
strategy
=
parse_handle
(
Grew_parser
.
strat_def
Grew_lexer
.
global
)
lexbuf
in
strategy
with
Sys_error
msg
->
Error
.
parse
"[Grew_loader.Parser.strategy] %s"
msg
(* ------------------------------------------------------------------------------------------*)
let
strategy
desc
=
try
...
...
src/grew_loader.mli
View file @
c91fbd08
...
...
@@ -34,7 +34,5 @@ module Parser : sig
val
pattern
:
string
->
Ast
.
pattern
val
strat_def
:
string
->
Ast
.
strat_def
val
strategy
:
string
->
New_ast
.
strat
end
src/grew_parser.mly
View file @
c91fbd08
...
...
@@ -126,7 +126,6 @@ let localize t = (t,get_loc ())
%
start
<
Grew_ast
.
Ast
.
module_or_include
list
>
included
%
start
<
Grew_ast
.
Ast
.
pattern
>
pattern
%
start
<
Grew_ast
.
Ast
.
domain
>
domain
%
start
<
Grew_ast
.
Ast
.
strat_def
>
strat_def
%
start
<
Grew_ast
.
New_ast
.
grs
>
new_grs
%
start
<
Grew_ast
.
New_ast
.
strat
>
strat_desc
...
...
@@ -135,13 +134,8 @@ let localize t = (t,get_loc ())
/*
EX
:
"( (SENT (NP (NC Amélioration) (PP (P de) (NP (DET la) (NC sécurité))))))"
*/
%
start
<
Grew_ast
.
Ast
.
pst
>
phrase_structure_tree
%
left
SEMIC
%
left
PLUS
%
nonassoc
STAR
%
nonassoc
BANG
%%
%
public
separated_list_final_opt
(
separator
,
X
)
:
|
{
[]
}
|
x
=
X
{
[
x
]
}
...
...
@@ -697,29 +691,6 @@ sequence:
strat_loc
;
}
}
/*
strat
=
<>
(
M1
+
M2
)
*
*/
|
doc
=
option
(
COMMENT
)
id_loc
=
simple_id_with_loc
EQUAL
strat_def
=
strat_def_rec
{
let
(
strat_name
,
strat_loc
)
=
id_loc
in
{
Ast
.
strat_name
;
strat_def
;
strat_doc
=
begin
match
doc
with
Some
d
->
d
|
None
->
[]
end
;
strat_loc
;
}
}
strat_def_rec
:
|
m
=
simple_id
{
Ast
.
Ref
m
}
|
LPAREN
s
=
strat_def_rec
RPAREN
{
s
}
|
s
=
strat_def_rec
STAR
{
Ast
.
Star
(
s
)
}
|
s
=
strat_def_rec
BANG
{
Ast
.
Bang
(
s
)
}
|
s1
=
strat_def_rec
PLUS
s2
=
strat_def_rec
{
Ast
.
Plus
[
s1
;
s2
]
}
|
s1
=
strat_def_rec
SEMIC
s2
=
strat_def_rec
{
Ast
.
Seq
[
s1
;
s2
]
}
|
PICK
LPAREN
s
=
strat_def_rec
RPAREN
{
Ast
.
Pick
s
}
|
TRY
LPAREN
s
=
strat_def_rec
RPAREN
{
Ast
.
Try
s
}
strat_def
:
s
=
strat_def_rec
EOF
{
s
}
/*=============================================================================================*/
/*
ISOLATED
PATTERN
(
grep
mode
)
*/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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