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
85f4a24e
Commit
85f4a24e
authored
Oct 05, 2007
by
Pietro Abate
Browse files
[r2003-05-31 21:38:01 by cvscast] include is relative to the current script's directory
Original author: cvscast Date: 2003-05-31 21:38:01+00:00
parent
28985ea2
Changes
4
Hide whitespace changes
Inline
Side-by-side
parser/location.ml
View file @
85f4a24e
...
...
@@ -16,6 +16,11 @@ let pop_source () =
|
[]
->
assert
false
|
s
::
rem
->
source_stack
:=
rem
;
source
:=
s
let
current_dir
()
=
match
!
source
with
|
`File
s
->
Filename
.
dirname
s
|
_
->
""
let
warning_ppf
=
ref
Format
.
std_formatter
exception
Location
of
loc
*
exn
...
...
parser/location.mli
View file @
85f4a24e
...
...
@@ -17,6 +17,8 @@ val raise_loc_generic: loc -> string -> 'a
val
push_source
:
source
->
unit
val
pop_source
:
unit
->
unit
val
current_dir
:
unit
->
string
val
warning_ppf
:
Format
.
formatter
ref
type
viewport
=
[
`Html
|
`Text
]
...
...
parser/parser.ml
View file @
85f4a24e
...
...
@@ -132,8 +132,14 @@ EXTEND
|
DIRECTIVE
"#env"
->
[
mk
loc
(
Directive
`Env
)
]
|
"include"
;
s
=
STRING2
->
let
s
=
get_string
s
in
let
s
=
if
Filename
.
is_relative
s
then
Filename
.
concat
(
Location
.
current_dir
()
)
s
else
s
in
protect_op
"File inclusion"
;
(* avoid looping; should issue an error ? *)
(* it is possible to have looping with x/../x/../x/.. ....
Need to canonicalize filename *)
if
List
.
mem
s
!
include_stack
then
[]
else
(
include_stack
:=
s
::
!
include_stack
;
...
...
@@ -141,10 +147,11 @@ EXTEND
protect_exn
(
fun
()
->
let
chan
=
open_in
s
in
let
input
=
Stream
.
of_channel
chan
in
let
l
=
Grammar
.
Entry
.
parse
prog
input
in
close_in
chan
;
l
)
protect_exn
(
fun
()
->
let
input
=
Stream
.
of_channel
chan
in
Grammar
.
Entry
.
parse
prog
input
)
(
fun
()
->
close_in
chan
))
(
fun
()
->
Location
.
pop_source
()
;
include_stack
:=
List
.
tl
!
include_stack
)
...
...
web/manual/interpreter.xml
View file @
85f4a24e
...
...
@@ -89,6 +89,8 @@ debug compile %%t%% %%p%%1 ... %%pn%% {{ compilation of pattern matching }}
<li>
Textual inclusion
<code>
include "%%other_cduce_script.cd%%"
</code>
;
note that cycle of inclusion are detected and automatically broken.
Filename are relative to the directory of the current file
(or the current directory in the toplevel).
</li>
</ul>
...
...
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