From: Frank Duncan Date: Sat, 23 Apr 2016 21:43:00 +0000 (-0500) Subject: Improve parser - generate prims from procedures X-Git-Tag: v0.1.0~51 X-Git-Url: https://code.consxy.com/gitweb/gitweb.cgi?a=commitdiff_plain;h=c9cf0d199bfaa751722aab688d22f43e4d70ae34;p=clnl Improve parser - generate prims from procedures --- diff --git a/src/main/code-parse.lisp b/src/main/code-parse.lisp index 7cdf2b5..644ef13 100644 --- a/src/main/code-parse.lisp +++ b/src/main/code-parse.lisp @@ -32,9 +32,19 @@ DESCRIPTION: in the CLNL-CODE-PARSER package to tease out necessary information. Some of those things will involve code blocks that can then be transpiled." (let - ((*dynamic-prims* (mapcar #'global->prim external-globals))) + ((*dynamic-prims* + (append + (mapcar #'global->prim external-globals) + (procedures->prims lexed-ast)))) (parse-internal lexed-ast))) +(defun procedures->prims (lexed-ast) + (cond + ((not lexed-ast) nil) + ; We'll need argument handling here sometime :) + ((eql :to (car lexed-ast)) (cons (list :name (cadr lexed-ast)) (procedures-to-prims (cdr lexed-ast)))) + (t (procedures-to-prims (cdr lexed-ast))))) + (defun parse-internal (lexed-ast) (cond ((not lexed-ast) nil) diff --git a/src/main/parse.lisp b/src/main/parse.lisp index 5c4c233..ad9f746 100644 --- a/src/main/parse.lisp +++ b/src/main/parse.lisp @@ -274,19 +274,6 @@ DESCRIPTION: ; Placeholder prims that should be populated in dynamic prims -; Generated by procedures -(defprim :move ()) -(defprim :eat-grass ()) -(defprim :reproduce-sheep ()) -(defprim :reproduce-wolves ()) -(defprim :catch-sheep ()) -(defprim :death ()) -(defprim :grow-grass ()) -(defprim :display-labels ()) - -; Generated by a let -;(defprim :prey ()) - ; Generated by breeds (defprim :sheep ()) (defprim :wolves ())