Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
f9278c8
Moving test files into a tests/ subdirectory.
Pauan Apr 24, 2011
86bd0ea
Merge remote branch 'upstream/master'
Pauan Apr 30, 2011
0e76489
Providing ar-tag from ar.ss
Pauan May 9, 2011
0d6c921
Merging with upstream.
Pauan May 9, 2011
9d1c256
Adding in a `racket` macro that works better than the one defined in …
Pauan May 10, 2011
3649de1
Fixing a bug with the `racket` macro.
Pauan May 10, 2011
e798238
Creating a core.arc file that contains super basic stuff that is used…
Pauan May 10, 2011
349d439
Adding `with` and `let` to core.arc
Pauan May 10, 2011
6273d47
Changes ar-apply so it coerces to 'fn. This allows Arc code to define…
Pauan May 11, 2011
ee48880
Adding in a Python style doctest library. Also adding in tests for (c…
Pauan May 11, 2011
df9105e
Fixing a couple things with the test framework.
Pauan May 11, 2011
3b56672
Changing fn so it's a macro that expands into a gensym. This makes it…
Pauan May 12, 2011
c695d1d
Moving some functions from ar.ss into ac.ss. This not only fixes a bu…
Pauan May 12, 2011
23f02cc
(coerce nil 'cons) now returns nil
Pauan May 12, 2011
b26e08d
Creating a "base.arc" file and moving some stuff into it
Pauan May 13, 2011
770da81
Moving a bunch of stuff into base.arc
Pauan May 14, 2011
ee6e64f
All special forms in ac.ss are now hardcoded to use gensyms, rather than
Pauan May 14, 2011
8a85390
Merge remote branch 'upstream/master'
Pauan May 15, 2011
8bbeb5a
Changing the --no-repl flag to --repl
Pauan May 15, 2011
576b48c
Changing re.arc to use Racket's re library. Now, all the tests
Pauan May 18, 2011
7358506
Merge remote branch 'upstream/master'
Pauan May 18, 2011
bc51686
Porting the remaining Arc tests over to my tester library.
Pauan May 18, 2011
4396a69
`tostring` now captures `stderr` in addition to `stdout`
Pauan May 18, 2011
06eb67e
Moving some more stuff into base.arc; just enough to get repl.arc
Pauan May 19, 2011
11c3c82
tostring no longer captures stderr; this reverts the previous change
Pauan May 19, 2011
6761354
Tweaking the output of `warn`
Pauan May 20, 2011
6589e98
The "arc" file now only loads the first file, rather than all of
Pauan May 20, 2011
65a8840
Renaming srcdir* to srcdir
Pauan May 20, 2011
547a4dd
`last` now works on strings (and anything else that allows indexing)
Pauan May 20, 2011
9d2af36
Tweaking the unit test framework
Pauan May 20, 2011
e79c67f
Adding in a simple command line argument parser
Pauan May 20, 2011
2a26984
Moving some stuff around a bit
Pauan May 21, 2011
f61a101
Changing curdir and script-args to use racket-make-derived-parameter
Pauan May 21, 2011
e021ea1
Adding in expandpath, splitext, and len-
Pauan May 22, 2011
484183f
Adding in 1+ and 1- which add and subtract (respectively) 1 from
Pauan May 22, 2011
17211ca
Adding in `none` which just returns logical NOT of `some`
Pauan May 22, 2011
ab99346
Adding in readlines, pipe-from, and collect
Pauan May 22, 2011
382987a
Adding in racket-#f, catcherr, and load-curdir
Pauan May 23, 2011
cf03cb3
Adding in xml-encode
Pauan May 23, 2011
8cab0ca
Fixing a bug with sread not using Arc's reader table
Pauan May 23, 2011
5621104
Changing srcdir to be dynamic, and adding in a custom w/srcdir macro
Pauan May 23, 2011
4e92773
Adding in dir, dirall, and hidden-file
Pauan May 23, 2011
168ed6b
Fixing a bug with union
Pauan May 25, 2011
5c315a1
Merge remote branch 'upstream/master'
Pauan May 25, 2011
ae47536
Changing racket/ to scheme/ for backwards-compatibility with PLT Scheme;
Pauan May 25, 2011
5d53c0d
Fixing some tests
Pauan May 25, 2011
5dcf3cb
Fixing the "arc" file
Pauan May 25, 2011
f03cea5
cadr and cddr are now defined in ac.ss, so I'm removing them from cor…
Pauan May 25, 2011
f441b28
Moving extend into base.arc
Pauan May 25, 2011
2b2428d
Fixing up some small things
Pauan May 25, 2011
696a621
Removing arc-script and moving some files into lib/
Pauan May 25, 2011
ca1e953
Adding a todo about dir
Pauan May 25, 2011
4decfb8
Adding in lib/object.arc
Pauan May 25, 2011
8f288d6
Objects now call print normally when they have a type attribute
Pauan May 25, 2011
6ea1169
Adding in a w/object macro that lets you refer to the object
Pauan May 27, 2011
301c10d
Adding in <- ssyntax for get-attribute
Pauan May 28, 2011
d1888d1
objects now have an implicit self variable
Pauan May 28, 2011
4243628
Adding in an `is` attribute to objects, which also lets me fix multi-…
Pauan May 28, 2011
3c3f0dd
Adding in a "lib/slices.arc" file, which allows slice notation with l…
Pauan May 29, 2011
639b611
Adding in some more del stuff to "lib/object.arc"
Pauan May 29, 2011
1fb8466
Cleaning up "lib/slices.arc"
Pauan May 29, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 94 additions & 42 deletions ac.ss
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
(define (make-arc-racket-namespace)
(let ((ns (make-base-empty-namespace)))
(parameterize ((current-namespace ns))
(namespace-require '(only racket/base #%app #%datum #%top))
(namespace-require '(prefix racket- racket/base))
(namespace-require '(prefix racket- racket/mpair))
(namespace-require '(prefix racket- racket/tcp)))
(namespace-require '(only scheme/base #%app #%datum #%top))
(namespace-require '(prefix racket- scheme/base))
(namespace-require '(prefix racket- scheme/mpair))
(namespace-require '(prefix racket- scheme/tcp)))
ns))

(define (new-arc (options (make-hash)))
Expand All @@ -79,11 +79,23 @@
(else x)))


;; toracket

(define (toracket x)
(cond ((mpair? x)
(cons (toracket (mcar x))
(toracket (mcdr x))))
((eq? x 'nil)
'())
((string? x)
(string-copy x))
(else x)))


;; racket-eval

(define (racket-eval arc form)
(parameterize ((current-readtable (get-default arc 'arc-readtable* (lambda () #f)))
(compile-allow-set!-undefined #t))
(parameterize ((compile-allow-set!-undefined #t))
(eval form (hash-ref arc 'racket-namespace*))))


Expand Down Expand Up @@ -146,6 +158,16 @@
'(ar-def ,name)))


;; ac-mac

(defmacro ac-mac (name args . body)
`(add-ac-build-step
(lambda (arc)
(ac-def-fn arc ',name ',args ((g annotate) 'mac
(lambda ,args (toarc ,@body)))))
'(ac-mac ,name)))


;; primitives

(add-ac-build-step
Expand Down Expand Up @@ -221,6 +243,14 @@
'(ar-toarc))


;; ar-toracket

(add-ac-build-step
(lambda (arc)
(ac-def-fn arc 'ar-toracket '(x) toracket))
'(ar-toracket))


;; ar-deep-fromarc

; todo I think we just need some better way of representing a Racket
Expand Down Expand Up @@ -399,6 +429,8 @@
(racket-if n
(ar-iround n)
(err "Can't coerce" x totype))))
((fn) (racket-lambda (k)
(racket-string-ref x k)))
(racket-else (err "Can't coerce" x totype))))
((racket-mpair? x)
(racket-case totype
Expand All @@ -407,6 +439,8 @@
(map1 (racket-lambda (y)
(coerce y (racket-quote string)))
x))))
((fn) (racket-lambda (k)
(racket-mlist-ref x k)))
(racket-else (err "Can't coerce" x totype))))
((racket-eq? x (racket-quote nil))
(racket-case totype
Expand All @@ -417,6 +451,11 @@
(racket-case totype
((string) (racket-symbol->string x))
(racket-else (err "Can't coerce" x type))))
((racket-hash? x)
(racket-case totype
((fn) (racket-case-lambda
((k) (racket-hash-ref x k nil))
((k d) (racket-hash-ref x k d))))))
(racket-else x))))


Expand All @@ -440,7 +479,7 @@
(racket-quote nil)))
(ar-pairwise pred (racket-cdr lst)))
(racket-else (racket-quote nil)))))

(ar-def is2 (a b)
(racket-define (is2 a b)
(ar-tnil
Expand Down Expand Up @@ -580,36 +619,13 @@

;; ar-apply

(ar-def ar-apply-cons (fn . racket-arg-list)
(racket-define (ar-apply-cons fn . racket-arg-list)
(racket-mlist-ref fn (racket-car racket-arg-list))))

(ar-def ar-apply-string (fn . racket-arg-list)
(racket-define (ar-apply-string fn . racket-arg-list)
(racket-string-ref fn (racket-car racket-arg-list))))

(ar-def ar-apply-hash (fn . racket-arg-list)
(racket-define (ar-apply-hash fn . racket-arg-list)
(racket-hash-ref fn
(racket-car racket-arg-list)
(racket-let ((default (racket-if (racket-pair? (racket-cdr racket-arg-list))
(racket-car (racket-cdr racket-arg-list))
(racket-quote nil))))
(racket-lambda () default)))))

(ar-def ar-apply (fn . racket-arg-list)
(racket-define (ar-apply fn . racket-arg-list)
(racket-cond
((racket-procedure? fn)
(racket-apply fn racket-arg-list))
((racket-mpair? fn)
(racket-apply ar-apply-cons fn racket-arg-list))
((racket-string? fn)
(racket-apply ar-apply-string fn racket-arg-list))
((racket-hash? fn)
(racket-apply ar-apply-hash fn racket-arg-list))
(racket-else
(err "Function call on inappropriate object" fn racket-arg-list)))))
(racket-apply (coerce fn (racket-quote fn)) racket-arg-list)))))


;; ar-funcall
Expand Down Expand Up @@ -749,7 +765,15 @@
;; if we're about to call a literal fn such as ((fn (a b) ...) 1 2)
;; then we know we can just call it in Racket and we don't
;; have to use ar-apply
((and (mpair? f) (eq? (mcar f) 'fn))
((and (mpair? f) (eq? (mcar f) %%internal-fn)) ; not sure whether this
; should be %%internal-fn
; or 'fn
;
; maybe this should be
; removed, since fn is a
; macro, so doesn't it
; bypass this section of
; code?
(mcons ((g ac) f env)
((g ac-args) ((g cadr) f) args env)))

Expand All @@ -769,13 +793,45 @@
((g ac-call) ((g car) s) ((g cdr) s) env))


;; use gensyms for special forms to allow shadowing/overwriting

(define %%internal-assign (gensym))
(define %%internal-fn (gensym))
(define %%internal-if (gensym))
(define %%internal-quasiquote (gensym))
(define %%internal-quote (gensym))

(add-ac-build-step
(lambda (arc)
(set arc '%%internal-assign %%internal-assign)
(set arc '%%internal-fn %%internal-fn)
(set arc '%%internal-if %%internal-if)
(set arc '%%internal-quasiquote %%internal-quasiquote)
(set arc '%%internal-quote %%internal-quote)))

(ac-mac assign (n v)
`(,%%internal-assign ,n ,v))

(ac-mac fn (parms . body)
`(,%%internal-fn ,parms ,@body))

(ac-mac if args
`(,%%internal-if ,@args))

(ac-mac quasiquote (x)
`(,%%internal-quasiquote ,x))

(ac-mac quote (x)
`(,%%internal-quote ,x))


;; quote

; The goal here is to get the quoted value tunneled through Racket's
; compiler unscathed. This trick uses rocketnia's method: Racket
; doesn't copy function values.

(extend ac (s env) ((g caris) s 'quote)
(extend ac (s env) ((g caris) s %%internal-quote)
(let ((v ((g cadr) s)))
((g list) ((g list) 'racket-quote (lambda () v)))))

Expand Down Expand Up @@ -820,16 +876,15 @@
(mcons (arc-list 'racket-list args)
((g ac-body*x) args body env)))))

(extend ac (s env)
((g caris) s 'fn)
(extend ac (s env) ((g caris) s %%internal-fn)
((g ac-fn) ((g cadr) s) ((g cddr) s) env))


;; eval

(define (arc-eval arc form)
(racket-eval arc ((g ar-deep-fromarc) ((get arc 'ac) form 'nil))))


(ac-def eval (form (other-arc 'nil))
(arc-eval (if ((g ar-true) other-arc) other-arc arc) form))
Expand Down Expand Up @@ -878,8 +933,7 @@
(else
(arc-list 'quote (list x)))))

(extend ac (s env)
((g caris) s 'quasiquote)
(extend ac (s env) ((g caris) s %%internal-quasiquote)
(let ((expansion ((g qq-expand) ((g cadr) s))))
((g ac) expansion env)))

Expand All @@ -897,8 +951,7 @@
((g ac) ((g cadr) args) env)
((g ac-if) ((g cddr) args) env)))))

(extend ac (s env)
((g caris) s 'if)
(extend ac (s env) ((g caris) s %%internal-if)
((g ac-if) ((g cdr) s) env))


Expand Down Expand Up @@ -929,8 +982,7 @@
(mcons 'racket-begin
((g ac-assignn) x env)))

(extend ac (s env)
((g caris) s 'assign)
(extend ac (s env) ((g caris) s %%internal-assign)
((g ac-assign) ((g cdr) s) env))


Expand Down
60 changes: 43 additions & 17 deletions arc
Original file line number Diff line number Diff line change
@@ -1,35 +1,61 @@
#!/usr/bin/env racket
#lang racket/load
#!/usr/bin/env mzscheme
#lang scheme/load

(require racket/cmdline)
(require scheme/cmdline)

(define run-repl #t)
(define run-repl #f)
(define exec-all #f)
(define files-to-load '())

(command-line
#:once-each
(("--no-repl")
"do not run the REPL"
(set! run-repl #f))
(("--repl")
"run the REPL even when specifying files"
(set! run-repl #t))
(("-a" "--all")
"execute all files, rather than only the first"
(set! exec-all #t))

#:args files
(set! files-to-load files))

(define arcdir*
(define srcdir
(path->string
(let-values (((base _2 _3)
(split-path (normalize-path
(find-system-path 'run-file)))))
base)))

(namespace-require `(file ,(string-append arcdir* "ac.ss")))
(namespace-require `(file ,(string-append srcdir "ac.ss")))

(let ((arc (new-arc)))
(set arc 'arcdir* arcdir*)
((get arc 'ar-load) (string-append arcdir* "arc.arc"))
((get arc 'load) (string-append arcdir* "arc3.1/strings.arc"))
(for-each (get arc 'load) files-to-load)
(when run-repl
((get arc 'load) (string-append arcdir* "repl.arc"))
((get arc 'repl)))
(void))
(set arc 'srcdir srcdir)

(parameterize ((current-command-line-arguments
(list->vector files-to-load)))

(when exec-all
(current-command-line-arguments #()))

(parameterize ((current-directory (g srcdir)))
((g ar-load) "core.arc"
"base.arc"
"arc.arc"))

(let ((load (g load))
(load-curdir (g load-curdir)))

(parameterize ((current-directory (g srcdir)))
(load "arc3.1/backcompat.arc")
(load "arc3.1/strings.arc"))

(cond (exec-all
(for-each load files-to-load))
((pair? files-to-load)
(load-curdir (car files-to-load))))

(when (or run-repl (null? files-to-load))
(parameterize ((current-directory (g srcdir)))
(load "repl.arc")
((g repl)))
(void)))))
43 changes: 0 additions & 43 deletions arc-script

This file was deleted.

6 changes: 0 additions & 6 deletions arc-test.ss

This file was deleted.

Loading