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 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
|
;;;-*- Mode:LISP; Package:CHAOS; Base:10; Syntax:Common-lisp -*-
;;;
;;; Copyright (c) 2000-2015, Toshimi Sawada. All rights reserved.
;;;
;;; Redistribution and use in source and binary forms, with or without
;;; modification, are permitted provided that the following conditions
;;; are met:
;;;
;;; * Redistributions of source code must retain the above copyright
;;; notice, this list of conditions and the following disclaimer.
;;;
;;; * Redistributions in binary form must reproduce the above
;;; copyright notice, this list of conditions and the following
;;; disclaimer in the documentation and/or other materials
;;; provided with the distribution.
;;;
;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;;
(in-package :chaos)
#|==============================================================================
System: CHAOS
Module: primitives
File: script.lisp
==============================================================================|#
#-:chaos-debug
(declaim (optimize (speed 3) (safety 0) #-GCL (debug 0)))
#+:chaos-debug
(declaim (optimize (speed 1) (safety 3) #-GCL (debug 3)))
;;; ** DESCRIPTION =============================================================
;;;
;;; Denfinitions of abstract syntax of Chaos script language.
;;; Each evaluator would be found in eval-ast2.lisp
;;;
;;; =============================================================================
;;; SCRIPT : defines the common structure of script language.
;;; -----------------------------------------------------------------------------
;;; ****
;;; EVAL : evaluate given ast.
;;; ****
(defterm eval (%script)
:visible (form)
:eval eval-form)
;;; *****
;;; ERROR : represents error status
;;; *****
(defterm error (%script)
:visible (type ; one of :warn, :error, :fatal?
message) ; string
:eval process-error)
;;; *********
;;; LISP-EVAL : evaluate as lisp form.
;;; *********
(defterm lisp-eval (%script)
:visible (form)
:eval eval-lisp-form)
;;; ************
;;; DYNA-COMMENT : dynamic comment.
;;; ************
(defterm dyna-comment (%script)
:visible (form)
:eval print-dyna-comment)
;;; ******
;;; REDUCE : reduce term.
;;; ******
;;; what is the difference with :eval?
(defterm reduce (%script)
:visible (term &optional (module *current-module*)
(mode :red) return-text)
:eval perform-reduction)
;;; ***********
;;; TEST-REDUCE : test reduction
;;; ***********
(defterm test-reduce (%script)
:visible (term expect &optional (module *current-module*)
(mode :red) return-text)
:eval perform-test-reduction)
;;; *****
;;; PARSE : parse term.
;;; *****
(defterm parse (%script)
:visible (term &optional (module *current-module*)
return-text)
:eval do-parse-term)
;;; *****
;;; INPUT : input Chaos program from file.
;;; *****
(defterm input (%script)
:visible (file-name
&optional (load-path *chaos-libpath*)
(proc 'process-cafeobj-input)
(suffixes '(".bin" ".cafe" ".mod"))
args)
:eval eval-input-file)
;;; *****************
;;; TRACE/TRACE-WHOLE
;;; *****************
(defterm trace (%script)
:visible (flag)
:eval eval-trace)
(defterm trace-whole (%script)
:visible (flag)
:eval eval-trace-whole)
;;; *******
;;; STEPPER
;;; *******
(defterm step (%script)
:visible (flag)
:eval eval-step)
;;; ***************
;;; DESCRIBE-MODULE
;;; ***************
(defterm describe-module (%script)
:visible (&optional (modexp *current-module*))
:eval eval-describe-module)
;;; ***********
;;; OPEN-MODULE
;;; ***********
(defterm open-module (%script)
:visible (&optional (modexp *current-module*))
:eval eval-open-module)
;;; ************
;;; CLOSE-MODULE
;;; ************
(defterm close-module (%script)
:visible (&rest ignore)
:eval eval-close-module)
;;; ****
;;; SAVE
;;; ****
(defterm save (%script)
:visible (file)
:eval eval-save)
;;; *******
;;; RESTORE
;;; *******
(defterm restore (%script)
:visible (file)
:eval eval-restore)
;;; *****
;;; RESET
;;; *****
(defterm reset (%script)
:eval eval-reset-system)
;;; **********
;;; FULL-RESET
;;; **********
(defterm full-reset (%script)
:eval eval-full-reset)
;;; ************
;;; LOAD-PRELUDE
;;; ************
(defterm load-prelude (%script)
:visible (file &optional
(processor 'process-cafeobj-input))
:eval eval-load-prelude)
;;; * Follwing two (start, apply) are defined in
;;; parse-apply.THSTUFF
;;; ---------------------------------------------
#|
;;; *****
;;; START
;;; *****
(defterm start (%script)
:visible (target) ; terget term
:eval eval-start-th
)
;;; *****
;;; APPLY
;;; *****
(defterm apply (%script)
:visible (action ; action to be performed, one-of
; :apply, :reduce, :print, :help.
rule ; rule specifier to be applied.
bindings ; list of variable bindings.
at ; one of :at, :within.
selectors) ; list of selectors.
:eval eval-apply-command)
|#
;;; *******
;;; PROVIDE
;;; *******
(defterm provide (%script)
:visible (feature) ; feature to be provided.
:eval eval-provide-command)
;;; *******
;;; REQUIRE
;;; *******
(defterm require (%script)
:visible (feature ; required feature
&optional
(proc 'process-cafeobj-input) ; process to evaluating fomrs.
file ; filename
)
:eval eval-require-command)
;;; *************
;;; REWRITE-COUNT
;;; *************
(defterm rewrite-count (%script)
:visible (limit) ; limitation
:eval eval-rewrite-count-limit)
;;; *******
;;; STOP-AT
;;; *******
(defterm stop-at (%script)
:visible (pattern)
:eval eval-stop-at)
;;; **************
;;; PROTECT-MODULE
;;; **************
(defterm protect (%script)
:visible (module ; module to be set protect mode
mode ; mode = :set | :unset
)
:eval eval-protect)
;;; *******
;;; DRIBBLE
;;; *******
(defterm dribble (%script)
:visible (file)
:eval eval-dribble)
;;; **********
;;; SAVE-CHAOS
;;; **********
(defterm save-chaos (%script)
:visible (top
file)
:eval eval-save-chaos)
;;; **
;;; LS
;;; **
(defterm ls (%script)
:visible (&optional (dir "."))
:eval eval-ls)
;;; ***
;;; PWD
;;; ***
(defterm pwd (%script)
:eval eval-pwd)
;;; *****
;;; SHELL
;;; *****
(defterm shell (%script)
:visible (command)
:eval eval-shell)
;;; **
;;; CD
;;; **
(defterm cd (%script)
:visible (directory)
:eval eval-cd)
;;; *****
;;; PUSHD
;;; *****
(defterm pushd (%script)
:visible (directory)
:eval eval-pushd)
;;; ****
;;; POPD
;;; ****
(defterm popd (%script)
:visible (&optional num)
:eval eval-popd)
;;; ****
;;; DIRS
;;; ****
(defterm dirs (%script)
:eval eval-dirs)
;;; ****
;;; SHOW
;;; ****
(defterm show (%script)
:visible (args)
:eval eval-show)
;;; ********
;;; DESCRIBE
;;; ********
(defterm describe (%script)
:visible (args)
:eval eval-describe)
;;; ******
;;; SELECT
;;; ******
(defterm select (%script)
:visible (modexp)
:eval eval-select)
;;; ***
;;; SET
;;; ***
(defterm set (%script)
:visible (switch
value)
:eval eval-set)
;;; **********
;;; REGULARIZE
;;; **********
(defterm regularize (%script)
:visible (modexp)
:eval eval-regularize)
;;; *****
;;; CHECK
;;; *****
(defterm check (%script)
:visible (what
args)
:eval eval-check)
;;; *************
;;; TRAM COMPILER
;;; *************
(defterm tram (%script)
:visible (command
modexp
term
debug)
:eval eval-tram)
;;; *********
;;; AUTO LOAD
;;; *********
(defterm autoload (%script)
:visible (mod-name
file)
:eval eval-autoload)
;;; ***********
;;; NO AUTOLOAD
;;; ***********
(defterm no-autoload (%script)
:visible (mod-name)
:eval eval-no-autoload)
;;; ******************************
;;; CIRCULAR COINDUCTIVE REWRITING
;;; ******************************
(defterm cbred (%script)
:visible (module
lhs
rhs)
:eval eval-cbred)
;;; **********************
;;; invoke Chaos Top Level
;;; **********************
(defterm chaos (%script)
:visible (&optional parameters)
:eval eval-chaos-top
)
;;; *****************
;;; continue
;;; for RWL =(_,_)=>
;;; *****************
(defterm continue (%script)
:visible (&optional num)
:eval rwl-cont
)
;;; *******
;;; WHAT IS
;;; *******
(defterm what-is (%script)
:visible (name &optional (module *current-module*))
:eval eval-what-is)
;;; *******
;;; INSPECT
;;; *******
(defterm inspect (%script)
:visible (&optional (modexp *current-module*))
:eval eval-inspect)
;;; *******
;;; LOOK-UP
;;; *******
(defterm look-up (%script)
:visible (name &optional (module *current-module*))
:eval eval-look-up)
;;; *********
;;; DELIMITER
;;; *********
(defterm delimiter (%script)
:visible (operation
char-list)
:eval eval-delimiter)
;;; ****
;;; CASE
;;; case (<Term>) on (<Modexp>) as (<Name>) : <GoalTerm> .
;;; ****
(defterm scase (%script)
:visible (bool-term module name body goal-term)
:eval perform-case-reduction)
;;; ******
;;; GENDOC
;;; gendoc <pathname>
;;; *****
(defterm gendoc (%script)
:visible (file)
:eval eval-gendoc)
;;; EOF
|