Skip to content

Instantly share code, notes, and snippets.

(defun make-stat-env (params &optional env)
(append
(loop
for var in params
for j = 1 then (+ j 1)
for num-env = (if (or (eq (first env) '&optional)
(eq (first env) '&rest)) nil (+ (or (second (first env)) -1) 1))
collect (list var num-env j)
)
env))
(defun readfile (name)
(let ((fd (open name)))
(loop
with line (read fd nil 'eof)
while (not (eq line 'eof))
do line)))
(defun readfile (name)
(let ((fd (open name)))
(loop
for line = (read fd nil 'eof)
when (not (eq line 'eof))
do (print line)
else return (close fd)
)))
(defun make-stat-env-optional (params env position num-env)
(cond ((endp params)
env)
((consp (car params))
(print params)
`((,(caar params) ,num-env ,position)
(,(intern (format nil "~a-P" (caar params))) ,num-env ,(+ 1 position))
. ,(make-stat-env-optional (cdr params) env (+ 2 position) num-env)))
((eq '&rest (car params))
(make-stat-env (cdr params) env position num-env))
(defun map-meval (list env)
(mapcar (lambda (x) (meval x env)) list))
(defun meval-progn (list env)
(let ((res (map-meval list env)))
(nth (- (list-length res) 1) res)))
(defun meval (expr &optional env)
"Interprète le langage intermédiaire passé en paramètre."
(cond
> MEVAL MAKE-ENV
[FAILURE] Test : (MAKE-ENV 2 '(1 2) #())
got : #(NIL 1 2)
expected : #(NIL 1 2)
comparison : #<SYSTEM-FUNCTION EQUAL>
[FAILURE] Test : (MAKE-ENV 2 '(7 8) #(#(NIL 7 8) 1 2))
got : #(#(NIL 7 8) 1 2)
expected : #(#(NIL 7 8) 1 2)
comparison : #<SYSTEM-FUNCTION EQUAL>
((eq 'defmacro (car expr))
`(:mcall set-defmacro (:const . ,(second expr))
,(lisp2li `(lambda ,(third expr) ,@(cdddr expr)) env)))
Étape 1/3 : Téléchargement
--2011-02-12 15:53:54-- http://www.lirmm.fr/~lafourcade/JDM-LEXICALNET-FR/?C=M;O=D
Résolution de www.lirmm.fr (www.lirmm.fr)... 193.49.104.249
Connexion vers www.lirmm.fr (www.lirmm.fr)|193.49.104.249|:80...connecté.
requête HTTP transmise, en attente de la réponse...200 OK
Longueur: 6900 (6,7K) [text/html]
Sauvegarde en : «STDOUT»
100%[====================================================================================================================================================================================================================================>] 6.900 --.-K/s ds 0,05s
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning,snakes,calc,chains,arrows}
\begin{document}
\begin{figure}[h!]
\begin{tikzpicture}[
state/.style={draw,circle,scale=1.5,fill=green!40},