Farm v. 4.2.5 par Julien REICHERT et Vivien MAISONNEUVE juillet 2008 La liste des instructions comprend pour le moment : - les 8 instructions de base du brainfuck : "ouah", "waf", "wau", "bark", "arf", "woof" ou "ouaf" pour incrémenter l'octet pointé (s'il vaut 255 il passe à 0) "miaou", "meow", "miau", "miauw", "mew" ou "miaow" pour le décrémenter (s'il vaut 0 il passe à 255) "meuh" ou "moo" pour incrémenter le pointeur (double le tableau s'il est tout à droite) "coin", "quack" ou "couac" pour le décrémenter (retourne une erreur s'il est tout à gauche) "gloup", "gloups" ou "bloup" pour remplacer l'octet pointé par le caractère suivant de la file d'entrée (éventuellement saut_de_ligne ou fin_de_fichier, erreur si le fichier est fini) "groink" ou "grunt" pour imprimer sur la sortie l'octet pointé "sss" ou "hiss" pour sauter à l'instruction après le "blater" ou "blat" correspondant si l'octet pointé est à 0 (continuer sinon) "blater" ou "blat" pour revenir au "sss" ou "hiss" correspondant (attention aux boucles infinies) - les instructions de démarrage et fin de programme "cocorico" ou "cock a doodle doo" avant de démarrer un programme "houuu" ou "howl" pour le terminer - des instructions-outils pour l'écriture de texte : "cui", "piu", "chirp", "tchip", "twiet" ou "tweet" pour mettre l'octet pointé à 97 (valeur de 'a') "squick", "squeak" ou "squeal" pour le mettre à 122 (valeur de 'z') "groar" ou "roar" pour le mettre à 65 (valeur de 'A') "bzz" ou "buzz" pour le mettre à 90 (valeur de 'Z') "hihan", "heehaw" ou "hee-haw" pour le mettre à 48 (valeur de '0') "bee" ou "bleat" pour le mettre à 57 (valeur de '9') "cot" ou "cluck" pour le mettre à 32 (valeur de ' ') - de nouvelles instructions de mise en mémoire "rouuu" pour échanger l'octet mis en mémoire (initialement à 0) avec l'octet pointé "leo" pour remplacer l'octet pointé par l'octet mis en mémoire (n'écrase pas la mémoire) "coucou" pour commencer la mise en mémoire d'une liste d'instructions (écrase la mémoire précédente) "glouglou" ou "gobble" pour terminer cette mise en mémoire, toutes les instructions mises en mémoire n'étant PAS effectuées "hihihi" pour effectuer toutes les instructions de la liste - des commentaires : "%" pour ignorer tout le reste de la ligne n'importe quel caractère sauf une lettre majuscule ou minuscule étant quoi qu'il arrive ignoré (sauf dans "hee-haw") /!\ seuls les mots en minuscules uniquement, en majuscule uniquement ou en minuscule sauf le premier caractère sont acceptées Vous pouvez utiliser un terminal (dans ce cas pour quitter le programme la seule solution est de déclencher une erreur - ce qui est très facile) ou interpréter un fichier .farm, et récupérer le résultat dans un interpréteur interactif ou un fichier texte. La commande est donc farm[.exe sous windows] le_fichier_texte_d'entrèe [-i le_programme] [-o la_sortie]. Pour compiler le code source : - sous linux il suffit de faire make - sous windows il faut recopier les instructions du makefile, ce qui donne : ocamlc -c ast.mli ocamlc -c ast.mli ast.ml ocamlyacc parser.mly ocamlc -c parser.mli ocamlc -c ast.cmo parser.cmi parser.ml ocamllex lexer.mll ocamlc -c parser.cmo lexer.cmi lexer.ml ocamlc -c ast.cmo compile.ml ocamlc ast.cmo parser.cmo lexer.cmo compile.cmo -o farm.exe farm.ml *************************************************************************************************************** Farm v. 4.2 by Julien REICHERT and Vivien MAISONNEUVE july 2008 In the current version, the instructions are : - the 8 brainfuck basic instructions : "ouah", "waf", "wau", "bark", "arf", "woof" or "ouaf" increments the pointed byte (if it is equal to 255 it becomes 0) "miaou", "meow", "miau", "miauw", "mew" or "miaow" decrements it (if it is equal to 0 it becomes 255) "meuh" or "moo" increments the pointer (doubles the array length if it is at extreme right) "coin", "quack" or "couac" decrements it (returns an error if it is at extreme left) "gloup", "gloups" or "bloup" replaces the pointed byte by the next character of the input file (possibly newline or end_of_file, error if the file is already ended) "groink" or "grunt" prints the pointed byte on the output "sss" or "hiss" jumps to the instruction after the "blater" or "blat" corresponding if the pointed byte is equal to 0 (continues else) "blater" or "blat" jumps back to the "sss" or "hiss" corresponding (beware of infinite loops) - instructions to begin and end a program : "cocorico" or "cock a doodle doo" is necessary to begin a program "houuu" or "howl" is necessary to end it - tool instructions to write down a text : "cui", "piu", "chirp", "tchip", "twiet" or "tweet" replaces the pointed byte by 97 (value of 'a') "squick", "squeak" or "squeal" replaces it by 122 (value of 'z') "groar" or "roar" replaces it by 65 (value of 'A') "bzz" or "buzz" replaces it by 90 (value of 'Z') "hihan", "heehaw" or "hee-haw" replaces it by 48 (value of '0') "bee" or "bleat" replaces it by 57 (value of '9') "cot" or "cluck" replaces it by 32 (value of ' ') - new memorization instructions "rouuu" switches the memorized byte (initial value 0) and the pointed one "leo" replaces the pointed byte by the value of the memorized one (does not affect the latter) "coucou" begins the registering of a list of instructions (erases the current memory) "glouglou" ou "gobble" ends this registering, all memorized instructions are NOT done "hihihi" makes at once all instructions in the memorized list - comments : "%" ignores everything until the end of line every character which is no letter (upper or lower case) is anyway ignored (except the '-' in "hee-haw") /!\ for an instruction to be accepted, the onomatopea must be only lower case, only upper case or only lower case but the first character in capital You can use a toplevel (in this case you must raise an error to quit the program, even if there is no other instruction, this one is very easy to do) or interprete a file in .farm, and print the results in the toplevel or a text file. The command is farm[.exe under windows] input_text_file [-i program] [-o output]. To compile the source code : - under linux you only have to write make - under windows you have to write down the instructions of the makefile, which are : ocamlc -c ast.mli ocamlc -c ast.mli ast.ml ocamlyacc parser.mly ocamlc -c parser.mli ocamlc -c ast.cmo parser.cmi parser.ml ocamllex lexer.mll ocamlc -c parser.cmo lexer.cmi lexer.ml ocamlc -c ast.cmo compile.ml ocamlc ast.cmo parser.cmo lexer.cmo compile.cmo -o farm.exe farm.ml