X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;ds=sidebyside;f=mudsync%2Fcommand.scm;h=a79f50d3e7f878ae24b9a1b6d8d5d98ebaeb0086;hb=4d4af0656b0402e630eea9393420197152945e5b;hp=31687389cf9a17af83e2f02e318d2f28b377100b;hpb=f1a3d508745069bceecb02cb475c0104020dce16;p=mudsync.git diff --git a/mudsync/command.scm b/mudsync/command.scm index 3168738..a79f50d 100644 --- a/mudsync/command.scm +++ b/mudsync/command.scm @@ -18,7 +18,8 @@ (define-module (mudsync command) #:use-module (mudsync parser) - #:use-module (8sync systems actors) + #:use-module (8sync actors) + #:use-module (8sync rmeta-slot) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (ice-9 control) @@ -31,10 +32,13 @@ command-action command-priority + build-commands + direct-command - indir-command + prep-indir-command + prep-direct-command loose-direct-command - loose-indir-command + loose-prep-command empty-command direct-greedy-command greedy-command @@ -68,6 +72,26 @@ (action command-action) (priority command-priority)) +(define-syntax %build-command + (syntax-rules () + ((_ (verb ...) ((cmd-proc action-sym args ...) ...)) + (list (cons verb + (list (cmd-proc (list verb ...) + (quote action-sym) + args ...) + ...)) + ...)) + ((_ verb ((cmd-proc action-sym args ...) ...)) + (list (cons verb + (list (cmd-proc (list verb) + (quote action-sym) + args ...) + ...)))))) + +(define-syntax-rule (build-commands (verb-or-verbs cmd-defs ...) ...) + (wrap-rmeta-slot + (append (%build-command verb-or-verbs cmd-defs ...) ...))) + (define (direct-command verbs action) (make-command verbs @@ -89,7 +113,7 @@ %default-priority)) -(define* (indir-command verbs action #:optional prepositions) +(define* (prep-indir-command verbs action #:optional prepositions) (make-command verbs cmatch-indir-obj (lambda* (goes-by #:key direct-obj indir-obj preposition) @@ -101,7 +125,19 @@ action %high-priority)) -(define* (loose-indir-command verbs action #:optional prepositions) +(define* (prep-direct-command verbs action #:optional prepositions) + (make-command verbs + cmatch-indir-obj + (lambda* (goes-by #:key direct-obj indir-obj preposition) + (if prepositions + (and + (member direct-obj goes-by) + (member preposition prepositions)) + (member direct-obj goes-by))) + action + %high-priority)) + +(define* (loose-prep-command verbs action #:optional prepositions) (make-command verbs cmatch-indir-obj (const #t)