Skip to content
This repository
tree: 4ea614c31c
Fetching contributors…

Cannot retrieve contributors at this time

file 268 lines (221 sloc) 4.635 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
(*
Copyright © 2011 MLstate

This file is part of OPA.

OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.

OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.

You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)

(**
OpaTop directives.
@author Mathieu Barbin
*)

(**
Directive are used for switching properties of the interpreter.
CF documentation of directive handling in [ConsoleParser.Directive]
*)

(**
The list of thing to do for adding a new directive:
- add the documentation in this file
- add the implementation in the ml
- add the corresponding help note in the help directive
- add the directive to the list [all_directives]
*)

type env = OpaTopEnv.env
type directive_action = env ConsoleParser.Directive.action
type directive = env ConsoleParser.Directive.directive

(**
GUIDELINES:
all directives should be documented :
- precise the syntax of the directive
- the role of its eventual arguments
- its semantic, and some example of utilisation.
- directive are defined in alphabetic order in this module (except for help).
- the directive documentation should be added to the help directive.
- the directive should be added to the directive handler at the end of the module.
*)

(** {6 Directives} *)

(**
Syntax:
{[
#assert on / off ;;
]}

Toggle assertion mode. Default is [on].
{[
#assert off ;;
]}
is like [--no-assert] of the compiler. Assertions are ignored.
*)
val assert_ : directive

(**
Syntax:
{[
#bypass ;;
]}

Dump all available external primitives.
*)
val bypass : directive

(**
Syntax:
{[
#dbgen on / off ;;
]}

Toggle DbGen mode. Default is [on].
*)
(* val dbgen : directive *)

(**
Syntax:
{[
#dddbgen on / off ;;
]}

Toggle DbGen Debug Dump mode. Default is [off].
*)
val dddbgen : directive

(**
Syntax:
{[
#env ;;
]}

Dump the current environment.
*)
val env : directive

(**
Syntax:
{[
#envgrep <regexp> ;;
]}

Dump the current environment combined with a grep filter.
Example:
{[
#envgrep int -> int ;;
]}
*)
val envgrep : directive

(**
Syntax:
{[
#eval on / off ;;
]}

Toggle the evaluation mode.
*)
(* val eval : directive *)

(**
Syntax:
{[
#import-db <file> ;;
]}
Example:
{[
#import-db "file.opa" ;;
#import-db "complete/path/to/myfile.opa" ;;
]}

Try to import an existing database with its definitions.
*)
val import_db : directive

(**
Syntax:
{[
#load <file> ;;
]}
Example:
{[
#load "file.opa" ;;
#load "complete/path/to/myfile.opa" ;;
]}

Load a file:
- parse it
- type it
- evaluate it
*)
val load : directive

(**
Syntax:
{[
#lookup <ident> ;;
]}
Example
{[
#lookup x ;;
]}

Lookup for an identifier in the environment.
If found, print its type and its value, otherwise print ["Not-found"].
*)
val lookup : directive

(**
Syntax:
{[
#quit ;;
]}

Quit the interpreter.
*)
val quit : directive

(**
Syntax:
{[
#reset ;;
]}

Reset the environment of the interpreter.
Restart the loop with an empty environment.
*)
val reset : directive

(**
Syntax:
{[
#restricted-bypass on / off ;;
]}

Toggle the checking about restricted bypass.
*)
val restricted_bypass : directive

(**
Syntax:
{[
#schema <file.dot> ;;
]}
Example :
{[
#schema "myfile.dot" ;;
]}

Print the current db-schema in a dot file,
and run display for seing it.
*)
val schema : directive

(**
Syntax:
{[
#typer on / off ;;
]}

Toggle the typeruation mode.
*)
(* val typer : directive *)

(**
Syntax :
{[
#types ;;
]}

Dump the types declarations of the current environment.
*)
(* val typers : directive *)

(** {9 Help} *)

(**
Syntax:
{[
#help ;;
]}
Print the help menu for all directives.
*)
val help : directive

(** {6 The handler} *)

(**
The list of all directives defined in the previous section.
Any new directive should be added to this list.
*)
val all_directives : directive list

(**
The handler of all directives.
*)
val handler : env ConsoleParser.Directive.handler
Something went wrong with that request. Please try again.