wip! Port the back end to Mes.
See also <https://git.ngyro.com/mes/log/?h=wip-gash>. * gash/pattern.scm (<pattern>): Use 'define-record-type' instead of 'define-immutable-record-type'. * mes/gash.mes: Add a bunch of shims; run 'guile --version'.
This commit is contained in:
parent
d18e721a78
commit
0f52c91f64
|
@ -20,7 +20,7 @@
|
|||
#:use-module (ice-9 match)
|
||||
#:use-module (ice-9 receive)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (srfi srfi-9 gnu)
|
||||
#:use-module (srfi srfi-9)
|
||||
#:use-module (srfi srfi-26)
|
||||
#:use-module (gash compat srfi-43)
|
||||
#:export (parse-pattern
|
||||
|
@ -31,7 +31,7 @@
|
|||
pattern-drop
|
||||
pattern-drop-right))
|
||||
|
||||
(define-immutable-record-type <pattern>
|
||||
(define-record-type <pattern>
|
||||
(make-pattern parts)
|
||||
pattern?
|
||||
(parts pattern-parts))
|
||||
|
|
78
mes/gash.mes
78
mes/gash.mes
|
@ -8,10 +8,6 @@
|
|||
(mes-use-module (srfi srfi-14))
|
||||
(mes-use-module (srfi srfi-26))
|
||||
|
||||
|
||||
|
||||
;; Stuff for the lexer.
|
||||
|
||||
|
||||
;; SRFI 14 extras
|
||||
|
||||
|
@ -113,29 +109,95 @@
|
|||
(define (string-every pred str)
|
||||
(every pred (string->list str)))
|
||||
|
||||
|
||||
;; Prompts
|
||||
|
||||
(define* (make-prompt-tag #:optional (stem "prompt"))
|
||||
(list stem))
|
||||
|
||||
|
||||
;; Misc. fixes
|
||||
|
||||
(define-syntax-rule (define-inlinable stuff ...)
|
||||
(define stuff ...))
|
||||
|
||||
|
||||
|
||||
;; Stuff for the parser
|
||||
|
||||
(define the-eof-object (integer->char -1))
|
||||
|
||||
(define (noop . args) #f)
|
||||
|
||||
(define (alist->hash-table alist)
|
||||
(define ht (make-hash-table 100))
|
||||
(fold-right (lambda (kvp acc)
|
||||
(hash-set! ht (car kvp) (cdr kvp)))
|
||||
#f
|
||||
alist)
|
||||
ht)
|
||||
|
||||
;; FIXME: Actually do somrething here.
|
||||
(define (canonicalize-path path) path)
|
||||
|
||||
;; Shadow these so that optional arguments work.
|
||||
(define mes-make-hash-table make-hash-table)
|
||||
(define mes-hash-ref hash-ref)
|
||||
(define* (make-hash-table #:optional (size 0))
|
||||
(mes-make-hash-table size))
|
||||
(define* (hash-ref table key #:optional dflt)
|
||||
(mes-hash-ref table key dflt))
|
||||
|
||||
(define X_OK 1)
|
||||
|
||||
(define program-arguments command-line)
|
||||
|
||||
(define (hash-fold proc init table)
|
||||
(define (proc* kvp acc)
|
||||
(proc (car kvp) (cdr kvp) acc))
|
||||
(define buckets (struct-ref table 4))
|
||||
(let loop ((k 0) (acc init))
|
||||
(if (>= k (vector-length buckets))
|
||||
acc
|
||||
(let ((bucket (vector-ref buckets k)))
|
||||
(loop (1+ k)
|
||||
(if (pair? bucket)
|
||||
(fold proc* acc bucket)
|
||||
acc))))))
|
||||
|
||||
(define delete-duplicates! delete-duplicates)
|
||||
|
||||
;; Mes does not have port buffers.
|
||||
(define flush-all-ports noop)
|
||||
|
||||
;; Mes uses raw file descriptors for file ports.
|
||||
(define file-port? number?)
|
||||
|
||||
;; This is probably OK....
|
||||
(define (input-port? port) #f)
|
||||
(define (output-port? port) #f)
|
||||
|
||||
;; More interface adjustments.
|
||||
(define mes-dup dup)
|
||||
(define* (dup fd #:optional new)
|
||||
(if new (dup2 fd new) (dup fd)))
|
||||
|
||||
|
||||
;; Main show
|
||||
|
||||
(include-from-path "gash/lexer.scm")
|
||||
(include-from-path "gash/parser.scm")
|
||||
(include-from-path "gash/environment.scm")
|
||||
(include-from-path "gash/pattern.scm")
|
||||
|
||||
;; These should come from (gash built-ins), but that whole system needs
|
||||
;; to be reworked.
|
||||
(define (search-built-ins name) #f)
|
||||
(define (search-special-built-ins name) #f)
|
||||
|
||||
(include-from-path "gash/shell.scm")
|
||||
|
||||
;; XXX: Mes module loading seems to bork reading from stdin.
|
||||
(set-current-input-port
|
||||
(open-input-file "/home/samplet/code/gash/mes/test.sh"))
|
||||
|
||||
(sh:exec "guile" "--version")
|
||||
|
||||
(write (read-sh-all))
|
||||
(newline)
|
||||
|
|
Loading…
Reference in New Issue