Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
0073da0b
Commit
0073da0b
authored
Oct 05, 2007
by
Pietro Abate
Browse files
[r2003-07-02 09:24:27 by cvscast] reinit_ns directive
Original author: cvscast Date: 2003-07-02 09:24:28+00:00
parent
1b67f651
Changes
8
Hide whitespace changes
Inline
Side-by-side
driver/cduce.ml
View file @
0073da0b
...
...
@@ -33,9 +33,9 @@ let print_value ppf v =
Location
.
protect
ppf
(
fun
ppf
->
Value
.
print
ppf
v
)
let
dump_env
ppf
=
Format
.
fprintf
ppf
"Types:%t
.
@."
Typer
.
dump_global_types
;
Format
.
fprintf
ppf
"Types:%t@."
Typer
.
dump_global_types
;
Format
.
fprintf
ppf
"Namespace prefixes:@
\n
%t"
Typer
.
dump_global_ns
;
Format
.
fprintf
ppf
"Namespace prefixes used for pretty-printing:
%t
@."
Format
.
fprintf
ppf
"Namespace prefixes used for pretty-printing:@.
%t
"
Ns
.
InternalPrinter
.
dump
;
Format
.
fprintf
ppf
"Values:@
\n
"
;
Env
.
iter
...
...
@@ -201,6 +201,9 @@ let rec phrases ppf phs = match phs with
|
{
descr
=
Ast
.
Directive
`Env
}
::
rest
->
dump_env
ppf
;
phrases
ppf
rest
|
{
descr
=
Ast
.
Directive
`Reinit_ns
}
::
rest
->
Typer
.
set_ns_table_for_printer
()
;
phrases
ppf
rest
|
[]
->
()
let
run
rule
ppf
ppf_err
input
=
...
...
misc/ns.ml
View file @
0073da0b
...
...
@@ -129,7 +129,6 @@ module Printer = struct
let
s
=
U
.
mk
(
Printf
.
sprintf
"ns%i"
p
.
counter
)
in
if
(
is_really_free
p
s
)
then
s
else
fresh_prefix
p
let
gen
=
ref
0
let
find_good_prefix
p
ns
hint
=
try
List
.
find
(
is_prefix_free
p
)
hint
with
Not_found
->
...
...
@@ -175,7 +174,7 @@ end
module
InternalPrinter
=
struct
let
p
=
ref
(
Printer
.
printer
empty_table
)
let
p
=
State
.
ref
"Ns.InternalPrinter"
(
Printer
.
printer
empty_table
)
let
set_table
t
=
p
:=
Printer
.
printer
t
...
...
parser/ast.ml
View file @
0073da0b
...
...
@@ -27,6 +27,7 @@ and debug_directive =
and
toplevel_directive
=
[
`Quit
|
`Env
|
`Reinit_ns
]
...
...
parser/parser.ml
View file @
0073da0b
...
...
@@ -118,6 +118,7 @@ EXTEND
|
"debug"
;
d
=
debug_directive
->
[
mk
loc
(
Debug
d
)
]
|
DIRECTIVE
"#quit"
->
[
mk
loc
(
Directive
`Quit
)
]
|
DIRECTIVE
"#env"
->
[
mk
loc
(
Directive
`Env
)
]
|
DIRECTIVE
"#reinit_ns"
->
[
mk
loc
(
Directive
`Reinit_ns
)
]
|
"include"
;
s
=
STRING2
->
let
s
=
if
Filename
.
is_relative
s
...
...
parser/wlexer.ml
View file @
0073da0b
...
...
@@ -127,9 +127,9 @@ let lex_tables = {
"
\000\000\023\000\011\000\015\000\254\255\042\000\046\000\255\255
\
\250\255\249\255\255\255\041\000\253\255\019\000\252\255\252\255
\
\251\255\000\000\002\000\253\255\246\255\245\255\010\000\054\000
\
\018\000\0
26
\000\0
4
2\000\05
3
\000\250\255\0
18
\000\0
5
6\000\0
25
\000
\
\0
49
\000\0
69
\000\02
6
\000\0
41
\000\0
58
\000\054\000\248\255\250\255
\
\247\255\07
4
\000\063\000\0
78
\000\
090
\000\0
7
9\000\1
04
\000\0
82
\000
\
\018\000\0
59
\000\02
1
\000\05
9
\000\250\255\0
26
\000\06
4
\000\0
36
\000
\
\0
67
\000\0
70
\000\02
4
\000\0
27
\000\0
47
\000\054\000\248\255\250\255
\
\247\255\07
3
\000\063\000\0
93
\000\
103
\000\09
8
\000\1
39
\000\0
79
\000
\
"
;
Lexing
.
lex_backtrk
=
"
\255\255\255\255\255\255\255\255\255\255\001\000\255\255\255\255
\
...
...
@@ -151,42 +151,50 @@ let lex_tables = {
"
\020\000\021\000\021\000\022\000\023\000\023\000\024\000\025\000
\
\023\000\026\000\027\000\008\000\029\000\047\000\030\000\031\000
\
\032\000\033\000\034\000\005\000\007\000\005\000\035\000\015\000
\
\041\000\013\000\036\000\004\000\037\000\034\000\0
4
3\000\038\000
\
\0
42
\000\038\000\014\000\023\000\023\000\021\000\021\000\021\000
\
\0
39
\000\017\000\010\000\011\000\010\000\012\000\006\000\013\000
\
\041\000\013\000\036\000\004\000\037\000\034\000\03
9
\000\038\000
\
\0
39
\000\038\000\014\000\023\000\023\000\021\000\021\000\021\000
\
\0
42
\000\017\000\010\000\011\000\010\000\012\000\006\000\013\000
\
\006\000\018\000\006\000\039\000\006\000\039\000\019\000\039\000
\
\019\000\007\000\044\000\044\000\044\000\007\000\044\000\039\000
\
\039\000\039\000\044\000\039\000\045\000\039\000\039\000\044\000
\
\004\000\004\000\004\000\041\000\040\000\039\000\039\000\039\000
\
\041\000\014\000\043\000\046\000\046\000\047\000\039\000\046\000
\
\000\000\044\000\044\000\044\000\044\000\044\000\044\000\044\000
\
\044\000\012\000\044\000\000\000\000\000\000\000\044\000\000\000
\
\045\000\000\000\000\000\044\000\046\000\046\000\046\000\000\000
\
\046\000\000\000\046\000\046\000\046\000\000\000\000\000\000\000
\
\000\000\046\000\000\000\000\000\000\000\044\000\044\000\044\000
\
\044\000\044\000\000\000\000\000\000\000\000\000\000\000\000\000
\
\000\000\000\000\000\000\046\000\046\000\046\000\046\000\046\000
\
"
;
\019\000\007\000\044\000\044\000\044\000\007\000\044\000\043\000
\
\043\000\040\000\044\000\043\000\045\000\039\000\039\000\044\000
\
\004\000\004\000\004\000\039\000\041\000\039\000\039\000\041\000
\
\039\000\014\000\047\000\039\000\000\000\000\000\000\000\039\000
\
\000\000\044\000\044\000\044\000\044\000\044\000\043\000\043\000
\
\039\000\043\000\043\000\043\000\000\000\043\000\046\000\046\000
\
\000\000\043\000\046\000\044\000\044\000\044\000\043\000\044\000
\
\000\000\000\000\000\000\044\000\012\000\045\000\000\000\000\000
\
\044\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
\
\043\000\043\000\043\000\043\000\043\000\046\000\046\000\000\000
\
\000\000\000\000\044\000\044\000\044\000\044\000\044\000\046\000
\
\046\000\046\000\000\000\046\000\000\000\000\000\000\000\046\000
\
\000\000\000\000\000\000\000\000\046\000\000\000\000\000\000\000
\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
\
\000\000\000\000\000\000\000\000\000\000\000\000\046\000\046\000
\
\046\000\046\000\046\000
"
;
Lexing
.
lex_check
=
"
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
\
\000\000\000\000\000\000\002\000\000\000\022\000\000\000\000\000
\
\000\000\000\000\000\000\003\000\018\000\003\000\000\000\001\000
\
\024\000\013\000\000\000\017\000\000\000\000\000\025\000\000\000
\
\029\000\000\000\013\000\000\000\000\000\000\000\000\000\000\000
\
\031\000\001\000\002\000\002\000\002\000\011\000\005\000\011\000
\
\005\000\001\000\006\000\026\000\006\000\026\000\001\000\034\000
\
\001\000\005\000\023\000\023\000\023\000\006\000\023\000\027\000
\
\027\000\032\000\023\000\030\000\023\000\035\000\030\000\023\000
\
\011\000\011\000\011\000\033\000\036\000\037\000\032\000\033\000
\
\041\000\042\000\043\000\045\000\045\000\047\000\033\000\045\000
\
\255\255\023\000\023\000\023\000\023\000\023\000\044\000\044\000
\
\044\000\045\000\044\000\255\255\255\255\255\255\044\000\255\255
\
\044\000\255\255\255\255\044\000\046\000\046\000\046\000\255\255
\
\046\000\255\255\045\000\045\000\046\000\255\255\255\255\255\255
\
\255\255\046\000\255\255\255\255\255\255\044\000\044\000\044\000
\
\044\000\044\000\255\255\255\255\255\255\255\255\255\255\255\255
\
\255\255\255\255\255\255\046\000\046\000\046\000\046\000\046\000
\
"
\024\000\013\000\000\000\017\000\000\000\000\000\026\000\000\000
\
\026\000\000\000\013\000\000\000\000\000\000\000\000\000\000\000
\
\029\000\001\000\002\000\002\000\002\000\011\000\005\000\011\000
\
\005\000\001\000\006\000\031\000\006\000\034\000\001\000\035\000
\
\001\000\005\000\023\000\023\000\023\000\006\000\023\000\025\000
\
\025\000\036\000\023\000\025\000\023\000\027\000\027\000\023\000
\
\011\000\011\000\011\000\030\000\033\000\037\000\030\000\041\000
\
\033\000\042\000\047\000\032\000\255\255\255\255\255\255\033\000
\
\255\255\023\000\023\000\023\000\023\000\023\000\025\000\025\000
\
\032\000\043\000\043\000\043\000\255\255\043\000\045\000\045\000
\
\255\255\043\000\045\000\044\000\044\000\044\000\043\000\044\000
\
\255\255\255\255\255\255\044\000\045\000\044\000\255\255\255\255
\
\044\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255
\
\043\000\043\000\043\000\043\000\043\000\045\000\045\000\255\255
\
\255\255\255\255\044\000\044\000\044\000\044\000\044\000\046\000
\
\046\000\046\000\255\255\046\000\255\255\255\255\255\255\046\000
\
\255\255\255\255\255\255\255\255\046\000\255\255\255\255\255\255
\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255
\
\255\255\255\255\255\255\255\255\255\255\255\255\046\000\046\000
\
\046\000\046\000\046\000
"
}
let
rec
token
engine
lexbuf
=
...
...
@@ -220,7 +228,7 @@ let rec token engine lexbuf =
""
,
Lexing
.
lexeme
lexbuf
)
|
6
->
(
#
100
"parser/wlexer.mll"
"DIRECTIVE"
,
Lexing
.
lexeme
lexbuf
)
"DIRECTIVE"
,
Lexing
.
lexeme
lexbuf
)
|
7
->
(
#
102
"parser/wlexer.mll"
let
string_start
=
Lexing
.
lexeme_start
lexbuf
in
...
...
parser/wlexer.mll
View file @
0073da0b
...
...
@@ -97,7 +97,7 @@ rule token = parse
|
"{|"
|
"|}"
|
"<="
|
">="
|
"<<"
|
">>"
|
[
"?+*"
]
"?"
|
"#"
{
""
,
Lexing
.
lexeme
lexbuf
}
|
"#"
lowercase
+
{
"DIRECTIVE"
,
Lexing
.
lexeme
lexbuf
}
|
"#"
ncname
{
"DIRECTIVE"
,
Lexing
.
lexeme
lexbuf
}
|
'
"' | "
'
"
{ let string_start = Lexing.lexeme_start lexbuf in
string_start_pos := string_start;
...
...
typing/typer.ml
View file @
0073da0b
...
...
@@ -799,6 +799,8 @@ let dump_global_types ppf = dump_types ppf !glb
let
register_global_ns
p
ns
=
glb
:=
register_ns
!
glb
p
ns
let
dump_global_ns
ppf
=
dump_ns
ppf
!
glb
let
set_ns_table_for_printer
()
=
Ns
.
InternalPrinter
.
set_table
!
glb
.
tenv_nspref
(* III. Type-checks *)
type
env
=
Types
.
descr
Env
.
t
...
...
typing/typer.mli
View file @
0073da0b
...
...
@@ -18,6 +18,8 @@ val register_global_ns : U.t -> Ns.t -> unit
val
dump_global_types
:
Format
.
formatter
->
unit
val
dump_global_ns
:
Format
.
formatter
->
unit
val
set_ns_table_for_printer
:
unit
->
unit
val
typ
:
Ast
.
ppat
->
Typed
.
ttyp
val
pat
:
Ast
.
ppat
->
Typed
.
tpat
val
expr
:
Ast
.
pexpr
->
fv
*
Typed
.
texpr
...
...
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