├── .gitattributes ├── .gitignore ├── .travis.yml ├── INSTALL.md ├── LICENSE ├── README.md ├── dev ├── diff.microalg.info.sh ├── nouvelle_commande.txt └── version_suivante.txt ├── doc.html ├── editeurs └── scite │ ├── SciTEGlobal.properties │ ├── jrepl.bat │ ├── malg-clj-scite.bat │ ├── malg-j-scite.bat │ ├── malg-njs-scite.bat │ ├── malg-rjs-scite.bat │ ├── malg.api │ ├── malg_abbrev.properties │ └── microalg.lua ├── emulisp ├── emulisp_core.js ├── emulisp_cv.js ├── emulisp_js.js ├── int.js ├── pil-njs ├── pil-njs.bat ├── pil-rjs └── pil-rjs.bat ├── ersatz ├── COPYING ├── README ├── lib.l ├── picolisp.jar ├── pil-j └── pil-j.bat ├── exemples ├── test_accents.malg ├── test_algues.malg ├── test_demander.malg ├── test_demander2.malg ├── test_demander3.malg ├── test_echappements.malg ├── test_listes.malg ├── test_logique.malg ├── test_millisecondes.malg ├── test_read.l ├── test_sequence_nb_pseudo_aleat.malg ├── test_tests.malg └── test_tortue.malg ├── faq.html ├── features ├── cli.py ├── hello.feature ├── interactions.feature └── invocations.feature ├── ide.html ├── install_scripts ├── fix_lettuce.sh └── install_picolisp.sh ├── jar └── js.jar ├── lib └── xml.l ├── malg ├── malg-clj.bat ├── malg-j ├── malg-j-repl.bat ├── malg-j.bat ├── malg-njs ├── malg-njs-repl.bat ├── malg-njs.bat ├── malg-rjs ├── malg-rjs-repl.bat ├── malg-rjs.bat ├── microalg-0.3.17.l ├── microalg.l ├── microalg_export.l ├── microalg_export_arbreninja.l ├── microalg_export_arbresvg.l ├── microalg_export_arbretxt.l ├── microalg_export_blockly.l ├── microalg_export_casio.l ├── microalg_export_javascript.l ├── microalg_export_microalg.l ├── microalg_export_processing.l ├── microalg_export_python.l ├── microalg_export_ti.l ├── microalg_tests.malg ├── microalg_tests.sh ├── microalg_tests_ersatz.bat ├── microalg_tests_ersatz.sh ├── microalg_tests_features.sh ├── microalg_tests_nodejs_emulisp.bat ├── microalg_tests_nodejs_emulisp.sh ├── microalg_tests_picolisp.sh ├── microalg_tests_rhino_emulisp.bat ├── microalg_tests_rhino_emulisp.sh ├── pde └── microalg │ └── microalg.pde ├── start_processing.bat ├── start_processing.sh ├── tuto.html ├── tuto_blocs.html ├── tuto_blocs_2.html ├── tuto_graphique.html ├── tuto_rapide.html ├── tuto_tortue.html ├── visuels ├── Sorted_binary_tree_postorder.svg ├── archi.malg ├── archi.svg └── logo_microalg.malg └── web ├── blockly ├── blockly_compressed.js └── media │ ├── 1x1.gif │ ├── click.mp3 │ ├── click.ogg │ ├── click.wav │ ├── delete.mp3 │ ├── delete.ogg │ ├── delete.wav │ ├── handclosed.cur │ ├── handopen.cur │ ├── quote0.png │ ├── quote1.png │ └── sprites.png ├── blockly_microalg.js ├── css-ninja-tree ├── css-ninja-tree.css ├── document.png ├── folder-horizontal.png ├── toggle-small-expand.png └── toggle-small.png ├── ide_injections.js ├── jquery.min.js ├── jquery.terminal-min.js ├── jquery.terminal.css ├── jquery.textcomplete.css ├── jquery.textcomplete.min.js ├── parenedit.css ├── parenedit.js ├── processing-1.4.15.min.js ├── showdown.js ├── showup.css ├── showup.js ├── style.css ├── svg-tree-drawer └── svg-tree-drawer.js └── tabIndent.js /.gitattributes: -------------------------------------------------------------------------------- 1 | emulisp/* linguist-vendored 2 | web/blockly/* linguist-vendored 3 | web/jquery.terminal* linguist-vendored 4 | web/parenedit* linguist-vendored 5 | web/showdown.js linguist-vendored 6 | web/showup* linguist-vendored 7 | tuto* linguist-vendored 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.pyc 3 | /editeurs/scite/*.exe 4 | /pde/microalg.out 5 | /picolisp/ 6 | /visuels/logo_microalg.svg 7 | /visuels/archi.svg 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | install: 2 | - sudo apt-get update -qq 3 | - sudo apt-get install gcc-multilib 4 | - npm install readline-sync 5 | - sudo pip install pexpect 6 | - sudo pip install lettuce 7 | - sudo ./install_scripts/fix_lettuce.sh 8 | script: sh microalg_tests.sh 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Microalg 2 | ======== 3 | 4 | 5 | 6 | 7 | Langage et environnements dédiés à l’algorithmique. 8 | 9 | [Site officiel](http://microalg.info/) 10 | 11 | MicroAlg est une sorte de [pseudo-code](https://fr.wikipedia.org/wiki/Pseudo-code) 12 | en français et exécutable sur machine. C’est un [langage 13 | embarqué](https://fr.wikipedia.org/wiki/Langage_d%C3%A9di%C3%A9#Langages_d.C3.A9di.C3.A9s_internes_et_externes) 14 | dans [PicoLisp](http://picolisp.com). Donc : 15 | 16 | * c’est un [Lisp](http://fr.wikipedia.org/wiki/Lisp), donc il n’y a pas de 17 | syntaxe à apprendre, juste des commandes, 18 | * elle peut *tourner* sur plusieurs plates-formes : 19 | * Javascript (navigateurs ou NodeJS) grâce à 20 | [EmuLisp](http://grahack.github.io/EmuLisp), 21 | * là où PicoLisp (ASM, C) peut tourner nativement, 22 | * la JVM grâce à Ersatz PicoLisp (une implémentation en Java de PicoLisp, 23 | par l’auteur de PicoLisp), 24 | * il est toujours possible si on se sent limité par ce langage, d’utiliser 25 | directement PicoLisp dans du code MicroAlg voir par exemple le fichier de 26 | tests `microalg_tests.malg`. 27 | 28 | Voir le [site officiel](http://microalg.info/) pour plus de détails, dont le 29 | code est dans [ce dépôt](https://github.com/Microalg/microalg.github.io). 30 | 31 | Installation 32 | ============ 33 | 34 | Il est possible d’installer MicroAlg sur sa machine ou sur son site. 35 | 36 | Voir le fichier [INSTALL.md](https://github.com/Microalg/Microalg/blob/latest/INSTALL.md). 37 | 38 | Fichiers 39 | ======== 40 | 41 | Listés dans l’ordre où ils apparaissent sur GitHub. 42 | 43 | * `dev` : différents outils pour les développeurs 44 | * `editeurs` : fichiers pour l’intégration avec différents éditeurs 45 | * `scite` : pour [SciTE](http://www.scintilla.org/SciTE.html) 46 | * `SciTEGlobal.properties` : configuration recommandée et/ou obligatoire 47 | pour l’intégration 48 | * `malg.api` : contient les signatures des commandes pour les 49 | infos-bulles 50 | * `malg_abbrev.properties` : permettra de mettre en place une structure 51 | en trois ou quatre touches (juste pour voir, relativement vide pour 52 | l’instant) 53 | * `malg-*-scite.bat` : exécutables permettant d’interpréter un `.malg` 54 | sous Windows et depuis SciTE 55 | * `microalg.lua` : le cœur de l’intégration avec l’éditeur (lexer, 56 | couleurs, commande pour l’exécution du fichier en cours…) 57 | * `emulisp` : implémentation de Picolisp en JS (voir 58 | [le dépôt semi-officiel](https://github.com/grahack/emulisp), mais attention, 59 | la version utilisée ici est une version expérimentale, qui guide le 60 | développement de la version semie-officielle) 61 | * `pil-njs*` script pour lancer EmuLisp sur Node 62 | * `pil-rjs*` script pour lancer EmuLisp sur Rhino 63 | * `ersatz` : implémentation de Picolisp en Java, par le créateur de PicoLisp 64 | * `pil-j*` script pour lancer Ersatz 65 | * `exemples` : quelques fichiers `.malg` (MicroAlg) ou `.l` (PicoLisp) en 66 | exemples, qui servent aussi pour les tests 67 | * `features` : tests de fonctionnalité pour les interpréteurs, rédigés en 68 | [Gherkin](https://github.com/cucumber/cucumber/wiki/Gherkin) 69 | * `cli.py` fait le lien entre les mots-clef des tests Gherkin et les 70 | actions à prendre pour exécuter concrètement ces tests 71 | * `install_scripts` : scripts d’installation : 72 | * `fix_lettuce.sh` : permet d’utiliser `lettuce` avec du texte comprenant 73 | des accents 74 | * `install_picolisp.sh` : pour l’interpréteur officiel de PicoLisp écrit en 75 | assembleur et C 76 | (d’où peut-être le répertoire `picolisp` qui traîne) 77 | * `jar` contient quelques archives Java 78 | * `js.jar` [Rhino](https://developer.mozilla.org/fr/docs/Rhino), 79 | l’implémentation de Javascript en Java par Mozilla 80 | * `lib` : quelques fichiers mi-`.l` mi-`.malg` 81 | * `xml.l` : bibliothèque en PicoLisp pour la génération de XML 82 | * `pde/microalg/microalg.pde` : pour la sortie graphique, avec 83 | [Processing](http://processing.org/) ou [Processing.js](http://processingjs.org/) 84 | * `pde/microalg.out/` : fichiers générés par Processing 85 | * `visuels` : divers fichiers graphiques comme par exemple le logo 86 | * `web` : des fichiers de complément pour les `.html` de ce projet 87 | * `blockly` : un extrait des fichiers du projet permettant de programmer 88 | avec des pièces de puzzle ([Blockly](http://code.google.com/p/blockly/)) 89 | * `blockly_microalg.js` : les blocs Blockly et leur générateur, 90 | correspondant aux mots-clés prédéfinis de MicroAlg 91 | * `css-ninja-tree` : pour afficher le code sous forme d’arbre en HTML/CSS 92 | * `ide_injections.js` : contient de quoi intégrer MicroAlg dans une page 93 | * `jquery.terminal*` : pour la console ou REPL ([site officiel](http://terminal.jcubic.pl/)) 94 | * `parenedit.*` : pour les parenthèses de couleur 95 | * `jquery.textcomplete.*` : pour les suggestions 96 | * `processing.*.min.js` : Processing pour le web 97 | * `showdown.*` : ([github](https://github.com/coreyti/showdown)) 98 | * `showup.*` : ([github](https://github.com/upstage/showup)) 99 | * `style.css` : la feuille de style 100 | * `svg-tree-drawer` : pour la visualisation du code sous forme d’arbre en SVG 101 | * `tabIndent.js` : pour indenter et désindenter avec la touche `TAB` 102 | * `.gitattributes` : fichier de configuration du dépôt `git`, surtout utilisé 103 | pour GitHub 104 | * `.gitignore` : spécification des fichiers non versionnés intentionnellement 105 | * `.travis.yml` : spécification des tests automatisés via [Travis](http://travis-ci.org/) 106 | * `INSTALL.md` : documentation complète concernant les différentes manières 107 | d’installer MicroAlg. 108 | * `LICENSE` : la licence 109 | * `README.md` : ce fichier (j’ai toujours rêvé d’écrire ça) 110 | * `doc.html` : la documentation de MicroAlg 111 | * `faq.html` : la foire aux questions de MicroAlg 112 | * `ide.html` : un IDE web de fortune, accessible [ici](http://microalg.info/ide.html) 113 | * `malg` : exécutable permettant d’interpréter un `.malg` avec PicoLisp (ASM/C) 114 | * `malg-clj.bat` : exécutable permettant d’interpréter un `.malg` avec MicroAlg-clj 115 | (Clojure), mais le `.jar` n’est pas fourni car réservé aux utilisateurs 116 | avancés 117 | * `malg-j` : exécutable permettant d’interpréter un `.malg` avec Ersatz (Java) 118 | * `malg-j.bat` : exécutable permettant d’interpréter un `.malg` avec Ersatz (Java) 119 | sous Windows 120 | * `malg-j-repl.bat` : exécutable permettant de travailler avec une console 121 | interactive avec Ersatz (Java) sous Windows 122 | * `malg-njs` : exécutable permettant d’interpréter un `.malg` avec Node et Emulisp 123 | * `malg-njs.bat` : exécutable permettant d’interpréter un `.malg` avec Node et Emulisp 124 | sous Windows 125 | * `malg-njs-repl.bat` : exécutable permettant de travailler avec une console 126 | interactive avec Node et Emulisp sous Windows 127 | * `malg-rjs` : exécutable permettant d’interpréter un `.malg` avec Rhino et Emulisp 128 | * `malg-rjs.bat` : exécutable permettant d’interpréter un `.malg` avec Rhino et Emulisp 129 | sous Windows 130 | * `malg-rjs-repl.bat` : exécutable permettant de travailler avec une console 131 | interactive avec Rhino et Emulisp sous Windows 132 | * `microalg.l` : implémentation de MicroAlg en PicoLisp, le cœur de ce projet 133 | * `microalg_export*` 134 | * `microalg_export.l` : fonctions PicoLisp préparant l’export en général 135 | * `microalg_export_arbreninja.l` : reprogrammation de MicroAlg pour la visualisation sous forme d’arbre en HTML/CSS 136 | * `microalg_export_arbresvg.l` : reprogrammation de MicroAlg pour la visualisation sous forme d’arbre graphique 137 | * `microalg_export_arbretxt.l` : reprogrammation de MicroAlg pour la visualisation sous forme d’arbre textuel 138 | * `microalg_export_blockly.l` : reprogrammation de MicroAlg pour la mise en place de blocs correspondant à un programme 139 | * `microalg_export_casio.l` : reprogrammation de MicroAlg pour l’export d’un programme vers le langage des Casio 140 | * `microalg_export_javascript.l` : reprogrammation de MicroAlg pour l’export d’un programme vers JavaScript 141 | * `microalg_export_microalg.l` : reprogrammation de MicroAlg pour l’export d’un programme vers MicroAlg 142 | * `microalg_export_processing.l` : reprogrammation de MicroAlg pour l’export d’un programme vers Processing 143 | * `microalg_export_python.l` : reprogrammation de MicroAlg pour l’export d’un programme vers Python 144 | * `microalg_export_ti.l` : reprogrammation de MicroAlg pour l’export d’un programme vers le langage des TI 145 | * `microalg_tests*` : 146 | * `microalg_tests.malg` : les tests des commandes MicroAlg testables avec 147 | PicoLisp/MicroAlg seulement 148 | * `microalg_tests.sh` : de quoi lancer les tests sur toutes les 149 | plates-formes possibles, features non comprises 150 | * `microalg_tests_*.bat` : de quoi lancer les tests avec Windows 151 | * `microalg_tests_*.sh` : de quoi lancer les tests autrement qu’avec Windows 152 | * `microalg_tests_features.sh` : de quoi lancer les tests de fonctionnalité 153 | * `tuto*.html` : pages web interactives pour apprendre MicroAlg, et plus 154 | généralement à faire ses premiers pas en algorithmique et en programmation 155 | * `tuto.html` : le tuto historique 156 | * `tuto_blocs.html` : le tuto avec les blocs (inachevé par manque de blocs) 157 | * `tuto_graphique.html` : le tuto sur les commandes ayant une sortie graphique, dont la tortue 158 | * `tuto_rapide.html` : le tuto pour les programmeurs avertis 159 | -------------------------------------------------------------------------------- /dev/diff.microalg.info.sh: -------------------------------------------------------------------------------- 1 | diff -rq . ../microalg.github.io | \ 2 | grep -v "Only in .: diff.microalg.info.sh" | \ 3 | grep -v swp | \ 4 | grep -v /\.git | \ 5 | grep -v .gitignore | \ 6 | grep -v README | \ 7 | grep -v LICENSE | \ 8 | grep -v INSTALL | \ 9 | grep -v CNAME | \ 10 | grep -v "Only in .: editeurs" | \ 11 | grep -v "Only in ./emulisp: emulisp_cv.js" | \ 12 | grep -v "Only in ./emulisp: emulisp_js.js" | \ 13 | grep -v "Only in ./emulisp: piljs.bat" | \ 14 | grep -v "Only in ./emulisp: pil-njs" | \ 15 | grep -v "Only in ./emulisp: pil-rjs" | \ 16 | grep -v "Only in .: ersatz" | \ 17 | grep -v "Only in .: ersatz_repl.l" | \ 18 | grep -v "Only in .: exemples" | \ 19 | grep -v "Only in .: features" | \ 20 | grep -v "Only in .: geogebra" | \ 21 | grep -v "Only in .: install_scripts" | \ 22 | grep -v "Only in .: lib" | \ 23 | grep -v "Only in .: malg" | \ 24 | grep -v "Only in .: netlogo" | \ 25 | grep -v "Only in .: picolisp" | \ 26 | grep -v "Only in .: todo" | \ 27 | grep -v "Only in .: .travis.yml" | \ 28 | grep -v "Only in ../microalg.github.io: 404.html" | \ 29 | grep -v "Only in ../microalg.github.io: comparaison.html" | \ 30 | grep -v "Only in ../microalg.github.io: images" | \ 31 | grep -v "Only in ../microalg.github.io: index.html" | \ 32 | grep -v "Only in ../microalg.github.io: logos.html" | \ 33 | grep -v "Only in ../microalg.github.io: params.json" | \ 34 | grep -v "Only in ../microalg.github.io: rapport_" | \ 35 | grep -v "Only in ../microalg.github.io: stylesheets" | \ 36 | grep -v "Only in .: microalg_tests" | \ 37 | grep -v "Only in .: .gitattributes" | \ 38 | tee 39 | -------------------------------------------------------------------------------- /dev/nouvelle_commande.txt: -------------------------------------------------------------------------------- 1 | # Check-list pour ajouter une commande dans MicroAlg: 2 | 3 | * microalg.l 4 | * doc de la commande dans `'doc` 5 | * implémentation de la commande en elle même 6 | * nouvelles erreurs (+ explications dans doc.html) 7 | * entrée dans la liste `symboles` 8 | * alias si accents 9 | * microalg_tests.malg 10 | * abréviation 11 | * `editeurs/scite/malg_abbrev.properties` 12 | * `web/ide_injections.js` 13 | * `doc.html` 14 | * Blockly 15 | * `web/blockly_microalg.js` 16 | * reserved words 17 | * config 18 | * génération 19 | * toolbox dans `web/ide_injections.js` 20 | * exports 21 | * microalg_export_blockly.l (/!\ Next) 22 | * microalg_export_casio.l 23 | * microalg_export_javascript.l 24 | * microalg_export_microalg.l 25 | * microalg_export_processing.l 26 | * microalg_export_python.l 27 | * microalg_export_ti.l 28 | * tutos 29 | * doc.html 30 | * penser à la section accents 31 | * liste syms par thèmes 32 | * doc spécifique à Blockly 33 | -------------------------------------------------------------------------------- /dev/version_suivante.txt: -------------------------------------------------------------------------------- 1 | git co master; 2 | ./microalg_tests.sh 3 | git push origin master 4 | 5 | déployer sur galerie via 6 | cd www/domains/galerie.microalg.info/microalg/ 7 | git co master 8 | git pull origin master 9 | Ctrl+F5 10 | # si ok 11 | git br -d prod_old; git co prod; git br prod_old; git merge master; git co master 12 | test de quelques pages: 13 | http://galerie.microalg.info/profgra:tests:images # pas de chance, bug 14 | http://galerie.microalg.info/profgra:tests:pgcd 15 | http://galerie.microalg.info/profgra:peda:fonctions_pures 16 | Si nouvelle conf: 17 | Ajouter section sur http://galerie.microalg.info/microalg:config_echantillons 18 | 19 | dans ce fichier: 20 | :%s/0.4.07/0.4.08/g # puis incrémenter le second 21 | :%s/0.4.06/0.4.07/g # remettre à la ver précédente, exécuter, incrémenter le second 22 | 23 | git tag -a v0.4.07 -f -m v0.4.07 24 | git push --tags 25 | 26 | # check nouveaux fichiers ou renames pour update README 27 | git log v0.4.06..v0.4.07 --diff-filter=A --summary | less 28 | git log v0.4.06..v0.4.07 --diff-filter=D --summary | less 29 | git log v0.4.06..v0.4.07 --diff-filter=R --summary | less 30 | 31 | git diff v0.4.06 v0.4.07 # pour préparer le change log 32 | Sur github, click sur Releases, puis sur la dernière, puis «Edit tag» 33 | Pas de «Release title» 34 | 35 | C’est l’occaze de peaufiner la release. 36 | 37 | ««« 38 | Voir les [instructions d’installation](https://github.com/Microalg/Microalg/blob/v0.4.07/INSTALL.md) ou [télécharger directement](https://github.com/Microalg/Microalg/releases/download/v0.4.07/microalg_0.4.07.zip) la version pour Windows (contenant l’éditeur SciTE 3.5.3). 39 | 40 | Changements notables depuis 0.4.06 : 41 | 42 | En bref : 43 | 44 | * Langage 45 | 46 | En détail : 47 | »»» 48 | 49 | num version 50 | git co master 51 | bump version dans microalg.l et microalg_tests.malg 52 | ./microalg_tests.sh 53 | modif INSTALL.md (à plusieurs endroits: 8 dans 6 lignes) 54 | # modif scripts de démarrage 55 | vim malg* # 7 fichiers 56 | git ap 57 | git cm "v0.4.06 -> v0.4.07" 58 | git push origin master 59 | git lol # pour vérif 60 | 61 | # redéployer sur galerie: 62 | git pull origin master # depuis serveur, puis 63 | git co prod; git merge master; git co master 64 | 65 | # faux tag «latest» sur working dir 66 | git co latest; git merge master; git push origin latest; git co master 67 | git lol # pour vérif 68 | 69 | git tag -a v0.4.07 -f -m v0.4.07 70 | git push --tags -f 71 | git lol # pour vérif 72 | 73 | git rma dist-win; git archive HEAD --prefix=microalg_0.4.07/ --format=zip > microalg_0.4.07.zip; git co master 74 | ajouter le zip à la release, puis publier 75 | 76 | déployer sur microalg.info 77 | # aller dans microalg.github.info 78 | git st 79 | # depuis microalg/github 80 | ./dev_tools/diff.microalg.info.sh 81 | # faire les copies, puis 82 | # check suppressions aussi 83 | # et attention aux fontes google à conserver (doc, ide, tutos) 84 | git add .; git cm "MAJ MicroAlg 0.4.07." 85 | modifs de index.html si besoin 86 | git push origin master 87 | modifs de index.html si besoin 88 | git push origin master 89 | 90 | 91 | tweet 92 | 93 | déployer sur profgra.org via (long !) 94 | cd /media/MOUSQUE/data/txt/ 95 | cd input/static/microalg 96 | git co master 97 | git pull origin master 98 | git rma pg.org.prod 99 | cd - 100 | sh ./html.sh; 101 | sh ./sync.sh 102 | 103 | -------------------------------------------------------------------------------- /editeurs/scite/SciTEGlobal.properties: -------------------------------------------------------------------------------- 1 | # Options générales facultatives mais recommandées 2 | position.maximize=1 3 | save.session=1 4 | save.recent=1 5 | use.tabs=0 6 | code.page=65001 7 | autocompleteword.automatic=1 8 | line.margin.visible=1 9 | line.margin.width=2+ 10 | title.full.path=2 11 | split.vertical=1 12 | output.horizontal.size=500 13 | edge.mode=1 14 | edge.column=80 15 | fold.symbols=3 16 | # Apparence des caractères 17 | my_size=size:12 18 | font.quality=2 19 | # Chasse fixe, voir http://fr.wikipedia.org/wiki/Chasse_%28typographie%29 20 | font.base=$(font.monospace),$(my_size) 21 | font.small=$(font.monospace),$(my_size) 22 | font.comment=$(font.monospace),$(my_size) 23 | font.text=$(font.monospace),$(my_size) 24 | font.text.comment=$(font.monospace),$(my_size) 25 | font.embedded.base=$(font.monospace),$(my_size) 26 | font.embedded.comment=$(font.monospace),$(my_size) 27 | font.vbs=$(font.monospace),$(my_size) 28 | # Apparence du curseur 29 | caret.fore=#FF0000 30 | caret.line.back=#000000 31 | caret.line.back.alpha=10 32 | caret.width=2 # 1, 2 ou 3 33 | # Apparence du panneau de sortie 34 | output.wrap=2 35 | output.scroll=2 36 | 37 | # Options concernant MicroAlg 38 | # Pas besoin si vous utilisez Windows: 39 | microalg_path=/opt/microalg 40 | # Comment est stylé un fichier avant son enregistrement: 41 | default.file.ext=.malg 42 | # Simplification du menu Langages: 43 | menu.language=MicroAlg|malg||Text|txt|| 44 | # Filtres pour Fichier/Ouvrir 45 | open.filter=Tous les fichiers (*.*)|*|Fichiers MicroAlg (*.malg)|*.malg| 46 | # Chargement 47 | if PLAT_WIN 48 | ext.lua.startup.script=$(SciteDefaultHome)\microalg.lua 49 | if PLAT_GTK 50 | ext.lua.startup.script=$(microalg_path)/editeurs/scite/microalg.lua 51 | -------------------------------------------------------------------------------- /editeurs/scite/malg-clj-scite.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SET NO_PAUSE=SVP 3 | SET SCITE_DIR=%~dp0 4 | SET MICROALG_DIR=%SCITE_DIR%..\.. 5 | %MICROALG_DIR%\malg-clj.bat "%1" 6 | -------------------------------------------------------------------------------- /editeurs/scite/malg-j-scite.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SET NO_PAUSE=SVP 3 | SET SCITE_DIR=%~dp0 4 | SET MICROALG_DIR=%SCITE_DIR%..\.. 5 | %MICROALG_DIR%\malg-j.bat "%1" 6 | -------------------------------------------------------------------------------- /editeurs/scite/malg-njs-scite.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SET NO_PAUSE=SVP 3 | SET SCITE_DIR=%~dp0 4 | SET MICROALG_DIR=%SCITE_DIR%..\.. 5 | %MICROALG_DIR%\malg-njs.bat "%1" 6 | -------------------------------------------------------------------------------- /editeurs/scite/malg-rjs-scite.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SET NO_PAUSE=SVP 3 | SET SCITE_DIR=%~dp0 4 | SET MICROALG_DIR=%SCITE_DIR%..\.. 5 | %MICROALG_DIR%\malg-rjs.bat "%1" 6 | -------------------------------------------------------------------------------- /editeurs/scite/malg.api: -------------------------------------------------------------------------------- 1 | + x1 x2 ...: Additionne les nombres fournis en paramètre. 2 | - x1 x2: Soustrait x2 de x1. 3 | * x1 x2 ...: Multiplie les nombres fournis en paramètre. 4 | / x1 x2: Divise x1 par x2. 5 | % n1 n2: Reste de la division euclidienne de n1 par n2. 6 | ** x1 x2: Met x1 à la puissance x2. 7 | ^ x1 x2: Met x1 à la puissance x2. 8 | !!! "texte": Commentaire. 9 | = val1 val2 ...: Comparaison : val1 = val2. 10 | =/ val1 val2 ...: Comparaison : val1 =/ val2. 11 | < val1 val2 ...: Comparaison : val1 < val2. 12 | <= val1 val2 ...: Comparaison : val1 <= val2. 13 | > val1 val2 ...: Comparaison : val1 > val2. 14 | >= val1 val2 ...: Comparaison : val1 >= val2. 15 | ? Symbole remplaçant la commande à tester dans `Exemples_de`. 16 | Affecter_a var val [En_position idx]: Affectation de la valeur `val` à la variable `var`. 17 | Afficher val: Affiche la valeur `val`. 18 | Aide sym: Aide sur le symbole `sym`. 19 | Ajouter_a obj: Affecte un nouvel élément à la fin de `obj` (après le dernier élément). 20 | Alors : Mot-clef intermédiaire d'un `Si`. 21 | Concatener val1 val2 ...: Met bout à bout les textes ou valeurs. 22 | Declarer var1 var2 ... De_type "type" : Déclare les variables `var...` du type `type`. 23 | Definir (commande args) doc auteur instructions : Permet de définir des commandes. 24 | Demander : Retourne le texte tapé par l'utilisateur. 25 | Demander_un_nombre : Convertit le texte tapé par l'utilisateur en nombre et le retourne. 26 | En_position : Mot-clef intermédiaire pour la commande `Affecter_a`. 27 | Entier@ min max : Retourne un entier pseudo-aléatoire entre `min` et `max`. 28 | Et b1 b2 ...: Opération logique. 29 | Exemples_de commande [liste d’exemples]: Permet de lire ou écrire les exemples-tests d’une commande. 30 | Faire instructions Tant_que test: Boucle où `instructions` s’exécutent tant que `test` est `Vrai`. 31 | Faux : Booléen. 32 | Initialiser@ [val]: Initialise le générateur de valeurs pseudo-aléatoires. 33 | Liste [élements] : Construit une liste avec les paramètres fournis. 34 | Longueur val: Donne la longueur d'une liste ou d'un texte. 35 | Millisecondes: Donne le nombre de millisecondes écoulées depuis le début de l’exécution du programme. 36 | Nieme val pos: Retourne l'élément à la position `pos` dans la valeur `val`. 37 | Nieme@ val : Retourne un élément pseudo-aléatoire dans `val`. 38 | Nombre val: Convertit `val` en nombre. 39 | Non b: Opération logique. 40 | Ou b1 b2 ...: Opération logique. 41 | Queue val: Retourne `val` (liste ou texte), privé de son premier élément. 42 | Repere x_min x_max y_min y_max: Change la zone que le carré graphique représente. 43 | Repeter n Fois instructions: Répète `n` fois les `instructions`. 44 | Retirer_de obj: Retire le dernier élément à la fin de `obj` et le retourne. 45 | Retourner val: À utiliser à la fin de la définition d'une commande. 46 | Rien : Valeur représentant l'absence de valeur. 47 | Si test Alors instructions1 [Sinon instructions2]: Exécution conditionnelle. 48 | Sinon : Mot-clef intermédiaire d'un `Si`. 49 | Tant_que test Faire instructions: Boucle où `instructions` s’exécutent tant que `test` est `Vrai`. 50 | Tester cmd: Vérifie que les exemples de la commande passée en argument sont conformes. 51 | Tete val: Retourne le premier élément de `val` (liste ou texte). 52 | Texte val: Convertit `val` en texte. 53 | Type val: Retourne le type de la valeur `val`. 54 | Vide? val: Teste si `val` est vide. 55 | Vrai : Booléen. 56 | -------------------------------------------------------------------------------- /editeurs/scite/malg_abbrev.properties: -------------------------------------------------------------------------------- 1 | # Voir aussi dans web/ide_injections.js. 2 | 3 | (Af=(Affecter_a |)\n 4 | (Afe=(Affecter_a | En_position )\n 5 | (A=(Afficher |)\n 6 | (Aj=(Ajouter_a |)\n 7 | (Al=(!!! "Algo |")\n(!!! "Fin algo ")\n 8 | (At=(Afficher "|")\n 9 | (Co=(Concatener |) 10 | (D=(Declarer | De_type "")\n 11 | (De=(Definir (|)\n "..."\n "..."\n (Retourner )\n)\n 12 | (Di=(Diff |) 13 | (Dm=(Demander)| 14 | (Dn=(Demander_un_nombre)| 15 | (Dnp=(Demander_un_nombre_pour |)\n 16 | (E=(Exemples_de |\n (Liste\n (? )\n (? )\n )\n)\n 17 | (E@=(Entier@ |) 18 | # Pour Faire, deux lignes pour aider à penser au compteur. 19 | (F=(Faire\n (|)\n ()\n Tant_que ()\n)\n 20 | (I@=(Initialiser@ |)\n 21 | (Li=(Liste |) 22 | (Lo=(Longueur |) 23 | (M=(Millisecondes)| 24 | (Ni=(Nieme |) 25 | (N@=(Nieme@ |) 26 | (No=(Nombre |) 27 | (Pr=(Produit |) 28 | (Pu=(Puissance |) 29 | (Q=(Quotient |) 30 | (R=(Repeter | Fois\n ()\n)\n 31 | (Ra=(Racine |) 32 | (Rd=(Retirer_de |) 33 | (Re=(Retourner |)\n 34 | (Rp=(Repere |)\n 35 | (Rs=(Reste |) 36 | (S=(Si (|) Alors\n ()\n)\n 37 | (So=(Somme |) 38 | (Ss=(Si (|)\n Alors ()\n Sinon ()\n)\n 39 | (Te=(Tester |)\n 40 | # Pour Tant_que, deux lignes pour aider à penser au compteur. 41 | (Tq=(Tant_que (|)\n Faire\n ()\n ()\n)\n 42 | -------------------------------------------------------------------------------- /editeurs/scite/microalg.lua: -------------------------------------------------------------------------------- 1 | -- -*- coding: utf-8 -*- 2 | 3 | print("Running microalg.lua...") 4 | 5 | -- Debug proc: 6 | function malg_debug(str) 7 | -- print(str) 8 | end 9 | 10 | -- Detect the platform: 11 | local uname_s = io.popen("uname -s"):read("*l") 12 | if uname_s == "Linux" then 13 | malg_debug("MicroAlg: " .. props["microalg_path"]) 14 | else 15 | malg_debug("Windows...") 16 | props["microalg_path"] = [[$(SciteDefaultHome)\..\..]] 17 | end 18 | 19 | -- Set some properties (.properties are not used because they need to be in the same dir) 20 | props["lexer.*.malg"] = "script_malg" 21 | props["lexer.*.l"] = "script_pico" 22 | props["indent.size.*.malg"]="4" 23 | -- Disable diff syntax highlighting in output pane: 24 | -- http://www.scintilla.org/SciTEFAQ.html#OutputColour 25 | props["style.errorlist.11"]="fore:#000000" 26 | props["style.errorlist.12"]="fore:#000000" 27 | 28 | -- Styles for the lexer states: 29 | -- NORMAL 30 | props["style.script_malg.0"] = "fore:#000000" 31 | -- TXT 32 | props["style.script_malg.1"] = "fore:#009f00" 33 | -- CMD 34 | props["style.script_malg.2"] = "fore:#00009f" 35 | -- COMZ 36 | props["style.script_malg.3"] = "fore:#999999" 37 | -- ESC 38 | props["style.script_malg.4"] = "fore:#006600,back:#e0efe0" 39 | -- Rainbow parens 40 | props["style.script_malg.11"] = "back:#ffaabb" 41 | props["style.script_malg.12"] = "back:#ffddbb" 42 | props["style.script_malg.13"] = "back:#ffffdd" 43 | props["style.script_malg.14"] = "back:#ddffbb" 44 | props["style.script_malg.15"] = "back:#cceeff" 45 | props["style.script_malg.16"] = "back:#ddccff" 46 | props["style.script_malg.10"] = "back:#bbbbee" 47 | -- Paren at current char (OK vs not OK) 48 | props["braces.check"] = "1" 49 | props["style.script_malg.34"] = "fore:#000000,back:#999999" 50 | props["style.script_malg.35"] = "fore:#000000,back:#ff0000" 51 | -- Copy microalg props to picolisp props. 52 | -- NORMAL 53 | props["style.script_pico.0"] = props["style.script_malg.0"] 54 | -- TXT 55 | props["style.script_pico.1"] = props["style.script_malg.1"] 56 | -- CMD 57 | props["style.script_pico.2"] = props["style.script_malg.2"] 58 | -- COMZ 59 | props["style.script_pico.3"] = props["style.script_malg.3"] 60 | -- Rainbow parens 61 | props["style.script_pico.11"] = props["style.script_malg.11"] 62 | props["style.script_pico.12"] = props["style.script_malg.12"] 63 | props["style.script_pico.13"] = props["style.script_malg.13"] 64 | props["style.script_pico.14"] = props["style.script_malg.14"] 65 | props["style.script_pico.15"] = props["style.script_malg.15"] 66 | props["style.script_pico.16"] = props["style.script_malg.16"] 67 | props["style.script_pico.10"] = props["style.script_malg.10"] 68 | -- Paren at current char (OK vs not OK) 69 | props["style.script_pico.34"] = props["style.script_malg.34"] 70 | props["style.script_pico.35"] = props["style.script_malg.34"] 71 | -- Back to MicroAlg 72 | -- Other props 73 | props["api.*.malg"] = "$(microalg_path)/editeurs/scite/malg.api" 74 | props["calltip.script_malg.parameters.start"] = " " 75 | props["calltip.script_malg.parameters.end"] = ":" 76 | props["calltip.script_malg.parameters.separators"] = " " 77 | props["calltip.script_malg.end.definition"] = ":" 78 | props["abbreviations.*.malg"] = "$(microalg_path)/editeurs/scite/malg_abbrev.properties" 79 | -- props["command.help.*.malg"] = "" 80 | -- props["command.help.subsystem.*.malg"] = "" 81 | -- props["command.scite.help"] = "" 82 | -- props["command.scite.help.subsystem"] = "" 83 | 84 | -- Configure F5 action 85 | props["1"] = "malg-rjs" 86 | if uname_s == "Linux" then 87 | sed = " | sed -r " 88 | enclosing_quotes = sed .. [['s/^"(.*)"$/\1/']] 89 | escaped_dble_quotes = sed .. [['s/\\"/"/g']] 90 | escaped_hat_char = sed .. [['s/\\\^/\^/g']] 91 | escaped_backslash = sed .. [['s/\\\\/\\/g']] 92 | hat_J = sed .. [['s/\^J/\n/g']] 93 | command = "$(microalg_path)/$(1) $(FilePath)" 94 | .. enclosing_quotes 95 | .. escaped_dble_quotes 96 | .. escaped_hat_char 97 | .. escaped_backslash 98 | .. hat_J 99 | else 100 | jrepl = [[ | $(SciteDefaultHome)\jrepl.bat ]] 101 | jrepl_opts = " /X" 102 | enclosing_quotes = jrepl .. [["^\q(.*)\q$" $1]] .. jrepl_opts 103 | escaped_dble_quotes = jrepl .. [["\\\q" "\q"]] .. jrepl_opts 104 | escaped_hat_char = jrepl .. [["\\\^" "^"]] .. jrepl_opts 105 | escaped_backslash = jrepl .. [["\\\\" "\"]] .. jrepl_opts 106 | hat_J = jrepl .. [["\^J" "\n"]] .. jrepl_opts 107 | command = [[$(SciteDefaultHome)\$(1)-scite.bat $(FilePath)]] 108 | .. enclosing_quotes 109 | .. escaped_dble_quotes 110 | .. escaped_hat_char 111 | .. escaped_backslash 112 | .. hat_J 113 | props["command.build.*.malg"] = [[start $(microalg_path)\start_processing.bat]] 114 | end 115 | 116 | props["command.1.*"] = command 117 | props["command.name.1.*"] = "Exécuter le programme" 118 | props["command.shortcut.1.*"] = "F5" 119 | 120 | -- Definition of the lexer: 121 | function OnStyle(styler) 122 | if styler.language == 'script_malg' then 123 | malg_debug("Styling a MicroAlg file...") 124 | elseif styler.language == 'script_pico' then 125 | malg_debug("Styling a PicoLisp file...") 126 | else 127 | malg_debug("Language: " .. styler.language) 128 | styler:EndStyling() 129 | return 130 | end 131 | 132 | -- S: State 133 | S_NORMAL = 0 134 | S_TXT = 1 135 | S_CMD = 2 136 | S_COMZ = 3 137 | S_ESC = 4 138 | S_PAREN_base = 10 139 | S_PAREN_bad = 35 140 | 141 | local paren_level = 0 142 | local old_level 143 | styler:StartStyling(0, styler.startPos + styler.lengthDoc, styler.initStyle) 144 | 145 | styler:SetState(S_NORMAL) 146 | while styler:More() do 147 | -- malg_debug(styler:Current() .. " (" .. styler:State() .. ")") 148 | 149 | if styler:State() >= S_PAREN_base then -- also resets S_PAREN_bad 150 | styler:SetState(S_NORMAL) 151 | elseif styler:State() == S_ESC then 152 | styler:SetState(S_TXT) 153 | elseif styler:State() == S_TXT then -- here we 'forward' (see *) 154 | if styler:Match([[\]]) or styler:Match([[^]]) then 155 | styler:SetState(S_ESC) 156 | styler:Forward() 157 | elseif styler:Match('"') then 158 | styler:ForwardSetState(S_NORMAL) 159 | else 160 | styler:Forward() 161 | end 162 | elseif styler:State() == S_CMD then 163 | if styler:Match(' ') or styler:Match(')') then 164 | styler:SetState(S_NORMAL) 165 | elseif styler:Match('(') then 166 | if styler.language == 'script_malg' then 167 | styler:SetState(S_PAREN_bad) 168 | elseif styler.language == 'script_pico' then 169 | styler:SetState(S_NORMAL) 170 | end 171 | end 172 | elseif styler:State() == S_COMZ then 173 | if styler:Match('\n') then 174 | styler:SetState(S_NORMAL) 175 | styler:Forward() 176 | end 177 | end 178 | -- Where to go from S_NORMAL 179 | if styler:State() == S_NORMAL then 180 | if styler:Match('"') then 181 | styler:SetState(S_TXT) 182 | styler:Forward() 183 | elseif styler:Match('(') then 184 | paren_level = (paren_level + 1) % 7 185 | styler:SetState(S_PAREN_base + paren_level) 186 | styler:ForwardSetState(S_CMD) 187 | elseif styler:Match(')') then 188 | old_level = paren_level 189 | paren_level = (paren_level - 1) % 7 190 | styler:SetState(S_PAREN_base + old_level) 191 | styler:Forward() 192 | elseif styler.language == 'script_pico' and styler:Match('#') then 193 | styler:SetState(S_COMZ) 194 | styler:Forward() 195 | else 196 | styler:Forward() 197 | end 198 | elseif styler:State() ~= S_TXT then -- * fixes the 'forward' in S_TXT 199 | styler:Forward() 200 | end 201 | end 202 | styler:EndStyling() 203 | end 204 | 205 | -------------------------------------------------------------------------------- /emulisp/emulisp_js.js: -------------------------------------------------------------------------------- 1 | /* 11feb14jk 2 | * (c) Jon Kleiser 3 | */ 4 | 5 | var EMULISP_JS = (function (ec) { 6 | 7 | var deFn = ec.forSymbolWithNameDefineFun, 8 | forSymbolWithNamePushValue = ec.forSymbolWithNamePushValue, 9 | forSymbolWithNameSetValue = ec.forSymbolWithNameSetValue, 10 | boxNativeObject = ec.boxNativeObject, 11 | isCell = ec.isCell, 12 | isSymbol = ec.isSymbol, 13 | evalArgs = ec.evalArgs, 14 | evalLisp = ec.evalLisp, 15 | newTransSymbol = ec.newTransSymbol, 16 | prog = ec.prog, 17 | valueToStr = ec.valueToStr, 18 | NIL = ec.NIL, T = ec.T; 19 | 20 | forSymbolWithNameSetValue("js:E", new Number(Math.E)); 21 | forSymbolWithNameSetValue("js:PI", new Number(Math.PI)); 22 | forSymbolWithNameSetValue("js:Doc", boxNativeObject(document)); 23 | forSymbolWithNameSetValue("js:Win", boxNativeObject(window)); 24 | 25 | deFn("js:alert", function(c) { var arr = [], v = NIL; 26 | c = evalArgs(c); while (c !== NIL) { v = c.car; arr.push(valueToStr(v)); c = c.cdr; } 27 | alert(arr.join("\n")); return v; 28 | }); 29 | 30 | deFn("js:confirm", function(c) { var arr = []; 31 | c = evalArgs(c); while (c !== NIL) { arr.push(valueToStr(c.car)); c = c.cdr; } 32 | return confirm(arr.join("\n")) ? T : NIL; 33 | }); 34 | 35 | // (js:prompt "What's your age?" "sixtysomething") 36 | deFn("js:prompt", function(c) { 37 | var r = prompt(valueToStr(evalLisp(c.car)), valueToStr(evalLisp(c.cdr.car))); 38 | return (r !== null) ? newTransSymbol(r) : NIL; 39 | }); 40 | 41 | deFn("js:getElementById", function(c) { 42 | var doc = document, elem = doc.getElementById(evalLisp(c.car).valueOf()); 43 | return (elem != null) ? boxNativeObject(elem) : NIL; 44 | }); 45 | 46 | // (js:onEventLisp (js:getElementById "dummy") "click" (prinl "A click on " js:Target)) 47 | deFn("js:onEventLisp", function(c) { 48 | var objBox = evalLisp(c.car), obj = objBox.obj, evtType = evalLisp(c.cdr.car).valueOf(); 49 | obj[evtType + "Lisp"] = c.cdr.cdr; // Lisp code to execute on event 50 | if (c.cdr.cdr != NIL) { 51 | // Installing event handler 52 | obj["on" + evtType] = function(evt) { 53 | try { 54 | var ts = forSymbolWithNamePushValue("js:Target", objBox); 55 | var es = forSymbolWithNamePushValue("js:Event", 56 | boxNativeObject(evt ? evt : window.event)); 57 | prog(obj[evtType + "Lisp"]); 58 | ts.popValue(); 59 | es.popValue(); 60 | } catch (e) { alert(evtType + "Lisp: " + e); } 61 | }; 62 | } else { 63 | // Removing event handler (no Lisp code given after event type) 64 | obj["on" + evtType] = null; 65 | } 66 | return objBox; 67 | }); 68 | 69 | // (js:clearInterval intervalId) 70 | deFn("js:clearInterval", function(c) { return clearInterval(evalLisp(c.car)) ? T : NIL; }); 71 | 72 | // (js:clearTimeout timeoutId) 73 | deFn("js:clearTimeout", function(c) { return clearTimeout(evalLisp(c.car)) ? T : NIL; }); 74 | 75 | /* Most browsers seem to support the form of setInterval(f,t,p) and setTimeout(f,t,p) where 76 | the first parameter is of type function, and the parameters after the second are parameters 77 | to that function. If your browser requires the first parameter to be of type string, then 78 | you can use the two slightly longer alternatives. 79 | */ 80 | // (js:setIntervalLisp (prinl "ping") 5000) 81 | deFn("js:setIntervalLisp", function(c) { 82 | var id = setInterval(evalLisp, evalLisp(c.cdr.car), c.car); 83 | return new Number(id); 84 | }); 85 | /* 86 | deFn("js:setIntervalLisp", function(c) { 87 | var str = lispToStr(c.car); 88 | gParseCache[str] = c.car; 89 | var jsStr = "evalLisp(gParseCache[\"" + str.replace(/"/g, "\\\"") + "\"])"; 90 | var id = setInterval(jsStr, evalLisp(c.cdr.car)); 91 | return new Number(id); 92 | }); 93 | */ 94 | // (js:setTimeoutLisp (prinl "ping") 3000) 95 | deFn("js:setTimeoutLisp", function(c) { 96 | var id = setTimeout(evalLisp, evalLisp(c.cdr.car), c.car); 97 | return new Number(id); 98 | }); 99 | /* 100 | deFn("js:setTimeoutLisp", function(c) { 101 | var str = lispToStr(c.car); 102 | gParseCache[str] = c.car; 103 | var jsStr = "evalLisp(gParseCache[\"" + str.replace(/"/g, "\\\"") + "\"])"; 104 | var id = setTimeout(jsStr, evalLisp(c.cdr.car)); 105 | return new Number(id); 106 | }); 107 | */ 108 | 109 | 110 | // Some reflection stuff similar to the 'java' and 'public' functions in ErsatzLisp 111 | 112 | function applyConstructor(ctor, args) { 113 | switch (args.length) { 114 | case 0: return new ctor(); 115 | case 1: return new ctor(args[0]); 116 | case 2: return new ctor(args[0], args[1]); 117 | case 3: return new ctor(args[0], args[1], args[2]); 118 | // add more cases if you like 119 | } 120 | var jsStr = "new ctor(args[0]"; 121 | for (var i=1; i= 0, j >= 0 ; --i, --j) { 85 | res[i] += carry + a[j]; 86 | carry = 0; 87 | 88 | if (res[i] >= 10) { 89 | res[i] -= 10; 90 | carry = 1; 91 | } 92 | } 93 | 94 | // carry the rest of the way 95 | for (; i >= 0 ; --i) { 96 | res[i] += carry; 97 | carry = 0; 98 | if (res[i] >= 10) { 99 | res[i] -= 10; 100 | carry = 1; 101 | } 102 | 103 | // no carry, rest of the number will be unchanged 104 | if (carry === 0) { 105 | break; 106 | } 107 | } 108 | 109 | // remaining carry? 110 | if (carry > 0) { 111 | res.unshift(1); 112 | } 113 | 114 | return out; 115 | } 116 | 117 | Int.prototype.sub = function(num) { 118 | var self = this; 119 | 120 | // some operations are destructive 121 | var num = Int(num); 122 | 123 | if(self._s != num._s) { 124 | num._s ^= 1; 125 | var res = this.add(num); 126 | num._s ^= 1; 127 | return res; 128 | } 129 | 130 | var s1 = self._s; 131 | var s2 = num._s; 132 | 133 | // make numbers positive for determining the greater one 134 | // in absolute terms 135 | self._s = num._s = 0; 136 | 137 | // make a the smaller number (abs value) 138 | var c = self.lt(num); 139 | var a = c ? self._d : num._d; 140 | var b = c ? num._d : self._d; 141 | 142 | // restore original signs 143 | self._s = s1; 144 | num._s = s2; 145 | 146 | var la = a.length; 147 | var lb = b.length; 148 | 149 | var out = Int((c) ? num : self); 150 | out._s = num._s & self._s; // ?? 151 | var res = out._d; 152 | 153 | // basic subtraction for common size 154 | var borrow = 0; 155 | for (var i = lb - 1, j = la - 1; i >= 0, j >= 0 ; --i, --j) { 156 | res[i] -= a[j] + borrow; 157 | borrow = 0; 158 | 159 | if (res[i] < 0) { 160 | res[i] += 10; 161 | borrow = 1; 162 | } 163 | } 164 | 165 | // carry the rest of the way 166 | for (; i >= 0 ; --i) { 167 | res[i] -= borrow; 168 | borrow = 0; 169 | if (res[i] < 0) { 170 | res[i] += 10; 171 | borrow = 1; 172 | } 173 | 174 | // no carry, rest of the number will be unchanged 175 | if (borrow === 0) { 176 | break; 177 | } 178 | } 179 | 180 | // flip the sign if sub num was larger 181 | c && (out._s ^= 1); 182 | 183 | trim_zeros(out); 184 | 185 | // TODO the subtraction should just be smarter 186 | if (out._d.length === 0) { 187 | out._s = 0; 188 | } 189 | 190 | return out; 191 | }; 192 | 193 | Int.prototype.mul = function(num) { 194 | var self = this; 195 | 196 | var r = self._d.length >= (num = Int(num))._d.length; 197 | var a = (r ? self : num)._d; 198 | var b = (r ? num : self)._d; 199 | 200 | var la = a.length; 201 | var lb = b.length; 202 | 203 | var sum = Int(); 204 | var zeros = []; 205 | 206 | // loop for smaller number 207 | for (var i = lb - 1 ; i >= 0 ; --i) { 208 | var out = Int(); 209 | 210 | // insert proper number of trailing 0s 211 | var val = out._d = out._d.concat(zeros); 212 | 213 | // reset carry 214 | var carry = 0; 215 | 216 | // top number 217 | for (var j = la - 1; j >= 0; --j) { 218 | // multiplication result 219 | var mul = b[i] * a[j] + carry; 220 | 221 | // this is the single digit we keep 222 | var res = mul % 10; 223 | 224 | // carry amount 225 | carry = Math.floor(mul / 10); 226 | 227 | // insert the number into our new integer 228 | val.unshift(res); 229 | } 230 | 231 | // apply any remaining carry 232 | if (carry) { 233 | val.unshift(carry); 234 | } 235 | 236 | sum = sum.add(out); 237 | zeros.push(0); 238 | } 239 | 240 | sum._s = self._s ^ num._s; 241 | return sum; 242 | }; 243 | 244 | Int.prototype.div = function(num) { 245 | var self = this; 246 | 247 | // copy since we change sign of num 248 | var num = Int(num); 249 | 250 | if(num.eq0()) { 251 | throw new Error('Division by 0'); 252 | } 253 | else if(self.eq0()) { 254 | return Int(); 255 | } 256 | 257 | // copy since we do destructive things 258 | var numerator = self._d.slice(); 259 | 260 | var quo = Int(); 261 | quo._s = self._s ^ num._s; 262 | 263 | // normalize num to positive number 264 | var orig_s = num._s; 265 | num._s = 0; 266 | 267 | // remainder from previous calculation 268 | var rem = Int(); 269 | 270 | while (numerator.length) { 271 | // long division 272 | // shift numbers off the numerator until we have achieved size 273 | // every number after the first causes a 0 to be inserted 274 | // numbers shifted in from the remainder should not cause 0 insertion 275 | 276 | var c = 0; 277 | while (numerator.length && rem.lt(num)) { 278 | if (c++ > 0) { 279 | quo._d.push(0); 280 | } 281 | 282 | // shift a number from numerator to our running num 283 | rem._d.push(numerator.shift()); 284 | 285 | // important to trim here since 009 - N won't be done right otherwise 286 | trim_zeros(rem); 287 | } 288 | 289 | var count = 0; 290 | while(rem.gte(num) && ++count) { 291 | rem = rem.sub(num); 292 | } 293 | 294 | if (count === 0) { 295 | quo._d.push(0); 296 | break; 297 | } 298 | 299 | quo._d.push(count); 300 | } 301 | 302 | var rlen = rem._d.length; 303 | 304 | if (rlen > 1 || (quo._s && rlen > 0)) { 305 | rem = rem.add(5); 306 | } 307 | 308 | if (quo._s && (rlen !== rem._d.length || rem._d[0] >= 5)) { 309 | quo = quo.sub(1); 310 | } 311 | 312 | // put back the sign of num 313 | num._s = orig_s; 314 | 315 | return trim_zeros(quo); 316 | }; 317 | 318 | Int.prototype.mod = function(num) { 319 | return this.sub(this.div(num).mul(num)); 320 | }; 321 | 322 | Int.prototype.pow = function(num) { 323 | var out = Int(this); 324 | if((num = (Int(num))) == 0) { 325 | return out.set(1); 326 | } 327 | 328 | for(var i = Math.abs(num); --i; out.set(out.mul(this))); 329 | return num < 0 ? out.set((Int(1)).div(out)) : out; 330 | }; 331 | 332 | /// set this number to the value of num 333 | Int.prototype.set = function(num) { 334 | this.constructor(num); 335 | return this; 336 | }; 337 | 338 | /// -1 if self < n, 0 if self == n, 1 if self > n 339 | Int.prototype.cmp = function(num) { 340 | var self = this; 341 | var num = ensure_int(num); 342 | 343 | if (self._s != num._s) { 344 | return self._s ? -1 : 1; 345 | } 346 | 347 | var a = self._d; 348 | var b = num._d; 349 | 350 | var la = a.length; 351 | var lb = b.length; 352 | 353 | if (la != lb) { 354 | return ((la > lb) ^ self._s) ? 1 : -1; 355 | } 356 | 357 | for (var i = 0; i < la; ++i) { 358 | if (a[i] != b[i]) { 359 | return ((a[i] > b[i]) ^ self._s) ? 1 : -1; 360 | } 361 | } 362 | 363 | // no differences 364 | return 0; 365 | }; 366 | 367 | Int.prototype.neg = function() { 368 | var out = Int(this); 369 | out._s ^= 1; 370 | return out; 371 | }; 372 | 373 | Int.prototype.abs = function() { 374 | var out = Int(this); 375 | out._s = 0; 376 | return out; 377 | }; 378 | 379 | // alphabet for converting to a specific base 380 | var alphabet = '0123456789abcdefghijklmnopqrstuvwxyz'; 381 | 382 | Int.prototype.valueOf = Int.prototype.toString = function(radix){ 383 | var self = this; 384 | 385 | if (self._nan) { 386 | return NaN; 387 | } 388 | 389 | if (radix === 'number' || !radix || radix === 10) { 390 | return (self._s && self._d.length ? '-' : '') + ((self._d.length) ? self._d.join('') : '0'); 391 | } 392 | 393 | if (radix < 2 || radix > 36) { 394 | throw RangeError('radix out of range: ' + radix); 395 | } 396 | 397 | var radix_pow = Math.pow(radix, 6); 398 | 399 | var rem = self; 400 | var result = ''; 401 | while (true) { 402 | var div = rem.div(radix_pow); 403 | var int = rem.sub(div.mul(radix_pow)); 404 | var digits = (+int.toString()).toString(radix); 405 | rem = div; 406 | 407 | if (rem.eq(0)) { 408 | return digits + result; 409 | } 410 | else { 411 | while (digits.length < 6) { 412 | digits = '0' + digits; 413 | } 414 | result = '' + digits + result; 415 | } 416 | } 417 | }; 418 | 419 | Int.prototype.gt = function (num) { 420 | return this.cmp(num) > 0; 421 | }; 422 | 423 | Int.prototype.gte = function (num) { 424 | return this.cmp(num) >= 0; 425 | }; 426 | 427 | Int.prototype.eq = function (num) { 428 | return this.cmp(num) === 0; 429 | }; 430 | 431 | Int.prototype.eq0 = function () { 432 | return this._d.length === 0; 433 | }; 434 | 435 | Int.prototype.ne = function (num) { 436 | return this.cmp(num) !== 0; 437 | }; 438 | 439 | Int.prototype.lt = function (num) { 440 | return this.cmp(num) < 0; 441 | }; 442 | 443 | Int.prototype.lte = function (num) { 444 | return this.cmp(num) <= 0; 445 | }; 446 | 447 | /// private api 448 | 449 | function ensure_int(val) { 450 | if (val instanceof Int) { 451 | return val; 452 | } 453 | 454 | return Int(val); 455 | } 456 | 457 | /// remove leading 0's from the int 458 | function trim_zeros(int) { 459 | while (int._d.length && int._d[0] === 0) { 460 | int._d.shift(); 461 | } 462 | 463 | return int; 464 | } 465 | 466 | // module.exports = Int; 467 | 468 | -------------------------------------------------------------------------------- /emulisp/pil-njs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ':' //; exec "$(command -v nodejs || command -v node)" "$0" "$@" 3 | 4 | // Helper file to run EmuLisp on NodeJS. 5 | 6 | fs = require('fs') 7 | path = require('path') 8 | 9 | // Override _stdPrint with the official mechanism. 10 | function stdPrint(text) { 11 | console.log(text.replace(/\n$/g,'')); 12 | } 13 | // Override _warn with the official mechanism. 14 | function warn(msg) { 15 | console.log(msg); 16 | } 17 | 18 | var NO_DEBUG = "piljs -> no debug yet"; 19 | 20 | // Load int.js. 21 | var int_src = fs.readFileSync( 22 | path.resolve(__dirname, 'int.js')).toString(); 23 | eval(int_src); 24 | 25 | // Load EmuLisp. 26 | var emulisp_src = fs.readFileSync( 27 | path.resolve(__dirname, 'emulisp_core.js')).toString(); 28 | eval(emulisp_src); 29 | 30 | // Process command line args. 31 | // TODO http://www.software-lab.de/doc/refL.html#load 32 | var arglist = process.argv.slice(2); 33 | while (true) { 34 | var arg = arglist.shift(); 35 | if (typeof arg == 'undefined') { 36 | // Now all command line args have been consumed. 37 | break; 38 | } 39 | var src; 40 | if (arg.slice(0, 1) == '-') { 41 | // Interpret arg as source code. 42 | src = '(' + arg.slice(1) + ')'; 43 | } else { 44 | // Interpret arg as a file to read. 45 | if(fs.existsSync(arg)) { 46 | src = fs.readFileSync(arg).toString(); 47 | } else { 48 | if (arg == '+') { 49 | console.log("+ not supported (yet)"); 50 | } else { 51 | console.log(arg + " not found."); 52 | } 53 | } 54 | } 55 | try { 56 | EMULISP_CORE.eval(src); 57 | } catch(e) { 58 | console.log(e.message) 59 | EMULISP_CORE.eval("(run *Err)"); 60 | console.log("? (" + NO_DEBUG + ")"); 61 | } 62 | } 63 | 64 | // REPL 65 | var readlinesync = require('readline-sync'); 66 | readlinesync.setPrompt(": "); 67 | while (true) { 68 | var user_input = readlinesync.prompt(); 69 | try { 70 | var result = EMULISP_CORE.eval(user_input); 71 | console.log('-> ' + result); 72 | } catch(e) { 73 | console.log("!? " + user_input) 74 | console.log(e.message) 75 | EMULISP_CORE.eval("(run *Err)"); 76 | console.log("? (" + NO_DEBUG + ")"); 77 | } 78 | } 79 | 80 | // vim: filetype=javascript 81 | -------------------------------------------------------------------------------- /emulisp/pil-njs.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set NODE_PATH=%USERPROFILE%\AppData\Roaming\npm\node_modules;"%NODE_PATH%" 3 | echo Emulisp 4 | node %~dp0\pil-njs %1 %2 %3 %4 %5 %6 5 | pause>nul|set/p="Une touche pour quitter."&echo( 6 | -------------------------------------------------------------------------------- /emulisp/pil-rjs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ':' //; exec java -jar $(dirname "$(readlink -f "$0")")/../jar/js.jar "$0" "$@" 3 | 4 | // Helper file to run EmuLisp on RhinoJS. 5 | 6 | // Fix the default print in Rhino and add println: 7 | // See http://mail.openjdk.java.net/pipermail/nashorn-dev/2013-September/001951.html 8 | function print(arg) { 9 | java.lang.System.out.print(arg); 10 | } 11 | function println(arg) { 12 | java.lang.System.out.println(arg); 13 | } 14 | 15 | // Override _stdPrint with the official mechanism. 16 | function stdPrint(text) { 17 | print(text); 18 | } 19 | // Override _warn with the official mechanism. 20 | function warn(msg) { 21 | print(msg); 22 | } 23 | 24 | var NO_DEBUG = "piljs -> no debug yet"; 25 | 26 | // Load EmuLisp. 27 | // Trick to give Rhino the MicroAlg path: 28 | var before_rhino_regex = new RegExp('^(.*)js\.jar.*'); 29 | var matches = before_rhino_regex.exec(environment["sun.java.command"]); 30 | var abs_path = matches[1] + "../"; 31 | load(abs_path + 'emulisp/int.js'); 32 | load(abs_path + 'emulisp/emulisp_core.js'); 33 | 34 | // Process command line args. 35 | // TODO http://www.software-lab.de/doc/refL.html#load 36 | var arglist = arguments; 37 | while (true) { 38 | var arg = arglist.shift(); 39 | if (typeof arg == 'undefined') { 40 | // Now all command line args have been consumed. 41 | break; 42 | } 43 | var src; 44 | if (arg.slice(0, 1) == '-') { 45 | // Interpret arg as source code. 46 | src = '(' + arg.slice(1) + ')'; 47 | } else { 48 | // Interpret arg as a file to read. 49 | var f = new java.io.File(arg) 50 | if(f.exists()) { 51 | src = readFile(arg); 52 | } else { 53 | if (arg == '+') { 54 | println("+ not supported (yet)"); 55 | } else { 56 | println(arg + " not found."); 57 | } 58 | } 59 | } 60 | try { 61 | EMULISP_CORE.eval(src); 62 | } catch(e) { 63 | println(e.message) 64 | EMULISP_CORE.eval("(run *Err)"); 65 | println("? (" + NO_DEBUG + ")"); 66 | } 67 | } 68 | 69 | // REPL 70 | importPackage(java.io); 71 | importPackage(java.lang); 72 | var stdin = new BufferedReader(new InputStreamReader(System['in'])); 73 | var user_input; 74 | while (true) { 75 | print(': '); 76 | user_input = stdin.readLine(); 77 | try { 78 | var result = EMULISP_CORE.eval(user_input); 79 | println('-> ' + result); 80 | } catch(e) { 81 | println("!? " + user_input) 82 | println(e.message) 83 | EMULISP_CORE.eval("(run *Err)"); 84 | println("? (" + NO_DEBUG + ")"); 85 | } 86 | } 87 | 88 | // vim: filetype=javascript 89 | -------------------------------------------------------------------------------- /emulisp/pil-rjs.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo Emulisp 3 | java -jar %~dp0\..\jar\js.jar %~dp0\pil-rjs -------------------------------------------------------------------------------- /ersatz/COPYING: -------------------------------------------------------------------------------- 1 | PicoLisp Copyright (c) Software Lab. Alexander Burger 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /ersatz/README: -------------------------------------------------------------------------------- 1 | 08may13abu 2 | (c) Software Lab. Alexander Burger 3 | 4 | 5 | Ersatz PicoLisp 6 | =============== 7 | 8 | Ersatz PicoLisp is a version of PicoLisp completely written in Java. It requires 9 | a 1.6 Java Runtime Environment. 10 | 11 | It should be the last resort when there is no other way to run a "real" 12 | PicoLisp. Also, it may be used to bootstrap the 64-bit version, which requires a 13 | running PicoLisp to build from the sources. 14 | 15 | Unfortunately, ErsatzLisp lacks everything which makes up "true" PicoLisp: 16 | Speed, small memory footprint, and simple internal structures. 17 | 18 | Performance is rather poor. It is 5 to 10 times slower, allocates a huge amount 19 | of memory at startup (600 MB vs. 3 MB), and needs 2.5 to 4 times the space for 20 | runtime Lisp data. But efficiency was not a major goal. Instead, performance was 21 | often sacrificed in favor of simpler or more modular structures. 22 | 23 | There is no support for 24 | 25 | -- raw console input ('key') and line editing 26 | -- child processes ('fork') 27 | -- interprocess communication ('tell', 'hear', 'ipc', 'udp' etc.) 28 | -- databases (external symbols) 29 | -- signal handling 30 | 31 | 32 | Invocation 33 | ---------- 34 | 35 | Ersatz PicoLisp can be started - analog to 'pil' - as 36 | 37 | $ ersatz/pil 38 | 39 | This includes slightly simplified versions of the standard libraries as loaded 40 | by the "real" 'pil' (without database, but with Pilog and XML support). 41 | 42 | To start it in debug mode, use 43 | 44 | $ ersatz/pil + 45 | 46 | 47 | On non-Unix systems, you might start 'java' directly, e.g.: 48 | 49 | java -DPID=42 -cp .;tmp;picolisp.jar PicoLisp lib.l 50 | 51 | Instead of '42' some other number may be passed. It is used to simulate a 52 | "process ID", so it should be different for every running instance of Ersatz 53 | PicoLisp. 54 | 55 | 56 | Building the JAR file 57 | --------------------- 58 | 59 | The actual source files are 60 | 61 | sys.src # The system 62 | fun.src # Function definitions 63 | 64 | The PicoLisp script "mkJar" will read them, generate the Java source file 65 | "PicoLisp.java", compile that with 'javac', and pack the result into a JAR (Java 66 | Archive) file. "mkJar" expects to be run in the "ersatz/" directory, e.g.: 67 | 68 | $ (cd ersatz; ./mkJar) 69 | -------------------------------------------------------------------------------- /ersatz/picolisp.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/ersatz/picolisp.jar -------------------------------------------------------------------------------- /ersatz/pil-j: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 29nov10abu 3 | 4 | # Run Ersatz PicoLisp 5 | exec java -DPID=$$ -cp .:tmp:${0%/*}/picolisp.jar PicoLisp ${0%/*}/lib.l "$@" 6 | -------------------------------------------------------------------------------- /ersatz/pil-j.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo Ersatz PicoLisp 3 | REM Inspiration for this file: 4 | REM https://www.mail-archive.com/picolisp@software-lab.de/msg02076.html 5 | REM You have to install Java and/or may have to tweak your PATH. 6 | REM See here: https://www.java.com/en/download/help/path.xml 7 | REM e.g. add ; (separator) then "C:\Program Files (x86)\Java\jre7\bin" 8 | java -DPID=42 -jar %~dp0\picolisp.jar %~dp0\lib.l %1 %2 %3 %4 %5 %6 9 | pause 10 | -------------------------------------------------------------------------------- /exemples/test_accents.malg: -------------------------------------------------------------------------------- 1 | (Afficher (Concatener "uno " "dos")) 2 | (Declarer txt1 De_type "texte") 3 | (Affecter_a txt1 "uno") 4 | (Afficher txt1) 5 | (Afficher (Concatener txt1 "!")) 6 | 7 | (Afficher (Concaténer "uno " "dos")) 8 | (Declarer txt2 De_type "texte") 9 | (Affecter_à txt2 "dos") 10 | (Afficher txt2) 11 | (Afficher (Concaténer txt2 "!")) -------------------------------------------------------------------------------- /exemples/test_algues.malg: -------------------------------------------------------------------------------- 1 | (RAZ) 2 | (Epaisseur 2) 3 | (Remplissage (Liste 255 255 255)) 4 | (Declarer n x y r decalage De_type "nombre") 5 | (Affecter_a n 1) 6 | (Affecter_a x 0) 7 | (Tant_que (<= n 5) 8 | Faire 9 | (Affecter_a credit_iterations 300) 10 | (Affecter_a x (+ (* n 50) 150)) 11 | (Affecter_a y 200) 12 | (Affecter_a r 25) 13 | (Affecter_a decalage 0) 14 | (Tant_que (>= r 4) 15 | Faire 16 | (Contour (Liste (Entier@ 0 255) (Entier@ 0 255) (Entier@ 0 255))) 17 | (Cercle (Liste x y) r) 18 | (Affecter_a decalage (+ decalage (Entier@ -1 1))) 19 | (Si (< decalage -2) Alors 20 | (Affecter_a decalage -2) 21 | ) 22 | (Si (> decalage 2) Alors 23 | (Affecter_a decalage -2) 24 | ) 25 | (Affecter_a x (+ x decalage)) 26 | (Affecter_a y (+ y 2)) 27 | (Si (= 1 (Entier@ 1 6)) Alors 28 | (Affecter_a r (- r 2)) 29 | ) 30 | ) 31 | (Affecter_a n (+ n 1)) 32 | ) 33 | -------------------------------------------------------------------------------- /exemples/test_demander.malg: -------------------------------------------------------------------------------- 1 | (Afficher "Votre nom ?") 2 | (Afficher (Concatener "Salut " (Demander))) 3 | -------------------------------------------------------------------------------- /exemples/test_demander2.malg: -------------------------------------------------------------------------------- 1 | (Afficher "Votre nom ?") 2 | (Demander) 3 | (Afficher (Concatener "Salut " texte_demandé)) 4 | -------------------------------------------------------------------------------- /exemples/test_demander3.malg: -------------------------------------------------------------------------------- 1 | (Afficher "Un nombre ?") 2 | (Demander_un_nombre) 3 | (Afficher (+ nombre_demandé 1)) 4 | -------------------------------------------------------------------------------- /exemples/test_echappements.malg: -------------------------------------------------------------------------------- 1 | (Afficher "Il a dit :^J\"Bonjour\" \^\^") 2 | (Afficher "") 3 | (Afficher "Ah bon ? Il a dit : 4 | \"Bonjour\" ? :\\") -------------------------------------------------------------------------------- /exemples/test_listes.malg: -------------------------------------------------------------------------------- 1 | (Exemples_de Retirer_de 2 | (Liste 3 | (? (Liste 1 2)) 2 4 | (? (Liste 1 2 3)) 3 5 | ) 6 | ) 7 | (Tester Retirer_de) 8 | (!!! "Ajouter_a est intestable car ne retourne rien.") 9 | -------------------------------------------------------------------------------- /exemples/test_logique.malg: -------------------------------------------------------------------------------- 1 | (Exemples_de Non 2 | (Liste 3 | (? Faux) Vrai 4 | (? Vrai) Faux 5 | ) 6 | ) 7 | (Tester Non) 8 | 9 | (Exemples_de Ou 10 | (Liste 11 | (? Faux Faux) Faux 12 | (? Faux Vrai) Vrai 13 | (? Vrai Faux) Vrai 14 | ) 15 | ) 16 | (Tester Ou) 17 | -------------------------------------------------------------------------------- /exemples/test_millisecondes.malg: -------------------------------------------------------------------------------- 1 | (Affecter_a credit_iterations 2000) 2 | 3 | (Declarer depart apres_la_boucle apres_la_2eme_boucle De_type "nombre") 4 | (Declarer i De_type "nombre") 5 | (Declarer texte De_type "texte") 6 | 7 | (Affecter_a depart (Millisecondes)) 8 | (Afficher (Concatener 9 | (Texte depart) 10 | " millisecondes écoulées avant l’exécution de la première ligne." 11 | )) 12 | (Affecter_a i 0) 13 | (Affecter_a texte "") 14 | (Tant_que (< i 500) 15 | Faire 16 | (Ajouter_a texte "a") 17 | (Affecter_a i (+ i 1)) 18 | ) 19 | (Affecter_a apres_la_boucle (Millisecondes)) 20 | (Afficher (Concatener 21 | "Nous en sommes à " 22 | (Texte apres_la_boucle) 23 | " millisecondes après 500 Ajouter_a." 24 | )) 25 | (Afficher (Concatener 26 | "Soit " 27 | (Texte (- apres_la_boucle depart)) 28 | " millisecondes pour 1ère la boucle." 29 | )) 30 | (Affecter_a i 0) 31 | (Affecter_a texte "") 32 | (Tant_que (< i 500) 33 | Faire 34 | (Ajouter_a texte "a") 35 | (Affecter_a i (+ i 1)) 36 | ) 37 | (Affecter_a apres_la_2eme_boucle (Millisecondes)) 38 | (Afficher (Concatener 39 | "Nous en sommes à " 40 | (Texte apres_la_2eme_boucle) 41 | " millisecondes après 500 autres Ajouter_a." 42 | )) 43 | (Afficher (Concatener 44 | "Soit " 45 | (Texte (- apres_la_2eme_boucle apres_la_boucle)) 46 | " millisecondes pour 2ème la boucle." 47 | )) 48 | -------------------------------------------------------------------------------- /exemples/test_read.l: -------------------------------------------------------------------------------- 1 | (println "Votre nom ?") 2 | (println (pack "Salut " (in NIL (read " !")))) 3 | (bye) 4 | -------------------------------------------------------------------------------- /exemples/test_sequence_nb_pseudo_aleat.malg: -------------------------------------------------------------------------------- 1 | (Declarer i De_type "nombre") 2 | 3 | (Definir (Afficher_10_des_de_6) 4 | "Affiche dix tirages de dés à 6 faces." 5 | "ProfGra" 6 | (Affecter_a i 0) 7 | (Tant_que (< i 10) Faire 8 | (Afficher (Entier@ 1 6)) 9 | (Affecter_a i (+ i 1)) 10 | ) 11 | ) 12 | (Afficher_10_des_de_6) 13 | (Afficher "---------") 14 | (Affecter_a sequence_tirages@ (Liste 1 2 3 4)) 15 | (Afficher_10_des_de_6) 16 | (Afficher "---------") 17 | (Affecter_a sequence_tirages@ (Liste)) 18 | (Afficher_10_des_de_6) 19 | -------------------------------------------------------------------------------- /exemples/test_tests.malg: -------------------------------------------------------------------------------- 1 | (Definir (Double x) 2 | "Retourne le double du paramètre `x`." 3 | "Profgra" 4 | (Retourner (* 2 x)) 5 | ) 6 | (!!! "La commande suivante «attache» à `Double` une liste d’exemples.") 7 | (!!! "Cette liste contient des appels et les retours correspondants.") 8 | (!!! "Vous êtes invitée à «casser» les tests, juste pour voir...") 9 | (Exemples_de Double 10 | (Liste 11 | (? 1) 2 12 | (? 2) 4 13 | (? 3) 6 14 | ) 15 | ) 16 | (Afficher "Les exemples de `Double` sont :") 17 | (Afficher (Exemples_de Double)) 18 | (!!! "Vérifions que la commande `Double` respecte les exemples.") 19 | (Tester Double) 20 | (Afficher "Voilà, c’est testé.") 21 | 22 | (!!! "Attention, utilisation avancée !") 23 | (!!! "Une commande peut récupérer les exemples d’une autre commande.") 24 | (Exemples_de Plus_un (Exemples_de Double)) 25 | (Afficher "Les exemples de `Plus_un` sont :") 26 | (Afficher (Exemples_de Plus_un)) 27 | -------------------------------------------------------------------------------- /exemples/test_tortue.malg: -------------------------------------------------------------------------------- 1 | (RAZ) 2 | (Declarer longueur i De_type "nombre") 3 | (Affecter_a longueur 100) 4 | (TD 30) 5 | (AV longueur) 6 | (TD 120) 7 | (AV longueur) 8 | (TD 30) 9 | (Affecter_a i 0) 10 | (Tant_que (<= i 4) Faire 11 | (AV longueur) 12 | (TD 90) 13 | (Affecter_a i (+ i 1)) 14 | ) 15 | -------------------------------------------------------------------------------- /faq.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | FAQ - MicroAlg 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 21 | 26 | 62 | 73 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /features/cli.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from lettuce import world, step, before, after 3 | import pexpect 4 | 5 | @before.each_scenario 6 | def world_init(scenario): 7 | world.interp = '' # name of the interpreter 8 | world.arg_list = [] # list of strings to provide to the interpreter 9 | world.process = None # the process pexpect will spawn 10 | world.timeout = 5 # timeout in seconds 11 | world.inputs = [] # list of strings that the user may input 12 | world.output = '' # string that will be displayed 13 | 14 | @step(u'Le programme (.*)') 15 | def le_programme(step, interp): 16 | world.interp = interp 17 | 18 | @step(u'Avec argument (.*)') 19 | def avec_argument(step, arg): 20 | world.arg_list.append(arg) 21 | 22 | @step(u'Ayant démarré') 23 | def ayant_demarre(step): 24 | world.process = pexpect.spawn(world.interp, world.arg_list, 25 | timeout=world.timeout) 26 | 27 | @step(u'Avec interaction (.*)') 28 | def avec_interaction(step, user_input): 29 | world.inputs.append(user_input) 30 | 31 | @step(u'Doit afficher «([^»]*)(»?)') 32 | def doit_afficher(step, expected, singleline): 33 | try: 34 | user_input = None 35 | # Append first prompt: 36 | world.process.expect('.*') 37 | world.output += world.process.after 38 | # Process user inputs: 39 | for user_input in world.inputs: 40 | world.process.sendline(user_input) 41 | world.process.expect('.*') 42 | world.output += world.process.after # we see input + result, nice 43 | # The end: 44 | world.process.expect('.*') 45 | # We rstrip because Lettuce seems to do the same when parsing multiline. 46 | world.output += world.process.after.rstrip('\n') 47 | world.process.expect(pexpect.EOF) 48 | except KeyboardInterrupt: 49 | print "Killing process before reraising KeyboardInterrupt." 50 | world.process.close() 51 | raise KeyboardInterrupt 52 | except pexpect.EOF: 53 | world.process.close() 54 | if user_input is None: 55 | tpl = "Le programme etait deja fini avant toute interaction.\n" + \ 56 | "La sortie etait %s" 57 | raise AssertionError(tpl % world.output) 58 | else: 59 | tpl = "Le programme etait deja fini lors de %s. La sortie etait %s" 60 | raise AssertionError(tpl % (user_input, world.output)) 61 | except pexpect.TIMEOUT: 62 | world.process.close() 63 | tpl = "Le test dure + de %s s. La sortie etait %s" 64 | raise AssertionError(tpl % (world.timeout, world.output)) 65 | # Post process output: 66 | world.output = world.output.replace('\r', '') 67 | if not singleline: 68 | expected = step.multiline 69 | # Final check: 70 | assert world.output == expected, \ 71 | u"Devait afficher %s, mais on a eu %s." % (expected, world.output) 72 | -------------------------------------------------------------------------------- /features/hello.feature: -------------------------------------------------------------------------------- 1 | # language: fr 2 | Fonctionnalité: Invocation des interpréteurs sur un script 'Hello World!' 3 | Pour pouvoir faire travailler les interpréteurs non-interactivement 4 | En tant qu’utilisateurs 5 | Il faut pouvoir les invoquer sur un fichier. 6 | 7 | Scénario: Avec «pil», je peux lire l’exemple test_read.l. 8 | Le programme pil 9 | Avec argument exemples/test_read.l 10 | Ayant démarré 11 | Avec interaction tout le monde! 12 | Doit afficher « 13 | """ 14 | ""Votre nom ?"" 15 | tout le monde! 16 | ""Salut tout le monde!"" 17 | """ 18 | 19 | Scénario: Avec «pilj», je peux lire l’exemple test_read.l. 20 | Le programme pilj 21 | Avec argument exemples/test_read.l 22 | Ayant démarré 23 | Avec interaction tout le monde! 24 | Doit afficher « 25 | """ 26 | ""Votre nom ?"" 27 | tout le monde! 28 | ""Salut tout le monde!"" 29 | """ 30 | 31 | Scénario: Avec «piljs», je peux lire l’exemple test_read.l. 32 | Le programme piljs 33 | Avec argument exemples/test_read.l 34 | Ayant démarré 35 | Avec interaction tout le monde! 36 | Doit afficher « 37 | """ 38 | ""Votre nom ?"" 39 | tout le monde! 40 | ""Salut tout le monde!"" 41 | """ 42 | 43 | Scénario: Avec «malg», je peux lire l’exemple test_demander.malg. 44 | Le programme malg 45 | Avec argument exemples/test_demander.malg 46 | Ayant démarré 47 | Avec interaction tout le monde! 48 | Doit afficher « 49 | """ 50 | ""Votre nom ?"" 51 | tout le monde! 52 | ""Salut tout le monde!"" 53 | """ 54 | 55 | Scénario: Avec «malgj», je peux lire l’exemple test_demander.malg. 56 | Le programme malgj 57 | Avec argument exemples/test_demander.malg 58 | Ayant démarré 59 | Avec interaction tout le monde! 60 | Doit afficher « 61 | """ 62 | ""Votre nom ?"" 63 | tout le monde! 64 | ""Salut tout le monde!"" 65 | """ 66 | 67 | Scénario: Avec «malgjs», je peux lire l’exemple test_demander.malg. 68 | Le programme malgjs 69 | Avec argument exemples/test_demander.malg 70 | Ayant démarré 71 | Avec interaction tout le monde! 72 | Doit afficher « 73 | """ 74 | ""Votre nom ?"" 75 | tout le monde! 76 | ""Salut tout le monde!"" 77 | """ 78 | 79 | -------------------------------------------------------------------------------- /features/interactions.feature: -------------------------------------------------------------------------------- 1 | # language: fr 2 | Fonctionnalité: Invocation des interpréteurs, interactions puis sortie 3 | Pour pouvoir faire travailler les interpréteurs interactivement 4 | En tant qu’utilisateurs 5 | Il faut pouvoir les invoquer, taper des instructions, et en sortir. 6 | 7 | Scénario: Avec «pil», je peux faire une simple addition. 8 | Le programme pil 9 | Ayant démarré 10 | Avec interaction (+ 2 2) 11 | Avec interaction (bye) 12 | Doit afficher « 13 | """ 14 | : (+ 2 2) 15 | -> 4 16 | : (bye) 17 | """ 18 | 19 | Scénario: Avec «pilj», je peux faire une simple addition. 20 | Le programme pilj 21 | Ayant démarré 22 | Avec interaction (+ 2 2) 23 | Avec interaction (bye) 24 | Doit afficher « 25 | """ 26 | : (+ 2 2) 27 | -> 4 28 | : (bye) 29 | """ 30 | 31 | Scénario: Avec «piljs», je peux faire une simple addition. 32 | Le programme piljs 33 | Ayant démarré 34 | Avec interaction (+ 2 2) 35 | Avec interaction (bye) 36 | Doit afficher « 37 | """ 38 | : (+ 2 2) 39 | -> 4 40 | : (bye) 41 | """ 42 | 43 | Scénario: Avec «malg», je peux faire une simple addition. 44 | Le programme malg 45 | Ayant démarré 46 | Avec interaction (+ 2 2) 47 | Avec interaction (bye) 48 | Doit afficher « 49 | """ 50 | : (+ 2 2) 51 | -> 4 52 | : (bye) 53 | """ 54 | 55 | Scénario: Avec «malgj», je peux faire une simple addition. 56 | Le programme malgj 57 | Ayant démarré 58 | Avec interaction (+ 2 2) 59 | Avec interaction (bye) 60 | Doit afficher « 61 | """ 62 | : (+ 2 2) 63 | -> 4 64 | : (bye) 65 | """ 66 | 67 | Scénario: Avec «malgjs», je peux faire une simple addition. 68 | Le programme malgjs 69 | Ayant démarré 70 | Avec interaction (+ 2 2) 71 | Avec interaction (bye) 72 | Doit afficher « 73 | """ 74 | : (+ 2 2) 75 | -> 4 76 | : (bye) 77 | """ 78 | 79 | -------------------------------------------------------------------------------- /features/invocations.feature: -------------------------------------------------------------------------------- 1 | # language: fr 2 | Fonctionnalité: Invocation des interpréteurs et leur sortie 3 | Pour pouvoir utiliser les interpréteurs 4 | En tant qu’utilisateurs 5 | Il faut pouvoir les invoquer et en sortir. 6 | 7 | Scénario: Avec l’interpréteur officiel de PicoLisp (écrit en ASM et C). 8 | Le programme pil 9 | Ayant démarré 10 | Avec interaction (bye) 11 | Doit afficher «: (bye)» 12 | 13 | Scénario: Avec l’interpréteur en Java de PicoLisp (nommé Ersatz). 14 | Le programme pilj 15 | Ayant démarré 16 | Avec interaction (bye) 17 | Doit afficher «: (bye)» 18 | 19 | Scénario: Avec l’interpréteur en Javascript (NodeJS + Emulisp) de PicoLisp. 20 | Le programme piljs 21 | Ayant démarré 22 | Avec interaction (bye) 23 | Doit afficher «: (bye)» 24 | 25 | Scénario: Avec l’interpréteur de MicroAlg sur 'pil'. 26 | Le programme malg 27 | Ayant démarré 28 | Avec interaction (bye) 29 | Doit afficher «: (bye)» 30 | 31 | Scénario: Avec l’interpréteur de MicroAlg sur 'pilj' (Java). 32 | Le programme malgj 33 | Ayant démarré 34 | Avec interaction (bye) 35 | Doit afficher «: (bye)» 36 | 37 | Scénario: Avec l’interpréteur de MicroAlg sur 'piljs' (Javascript). 38 | Le programme malgjs 39 | Ayant démarré 40 | Avec interaction (bye) 41 | Doit afficher «: (bye)» 42 | 43 | -------------------------------------------------------------------------------- /ide.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MicroAlg - Web IDE 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 31 |
32 | 38 |
39 |
40 |   41 |
42 |   43 |
44 |

45 |
46 |

MicroAlg - web IDE

47 |

Qu’est-ce ?

48 |

Cette page est un 49 | environnement 50 | de développement intégré de fortune pour 51 | MicroAlg.

52 |

Elle permet pour l’instant de faire quelques tests, mais aussi 53 | d’avoir une vitrine en ligne pour ce langage. D’autres façons 54 | d’utiliser MicroAlg sont en cours de développement. Voir pour cela 55 | la page d’installation.

56 | 57 |

Instructions

58 |

Édition de scripts

59 |

La zone avec les pièces de puzzle 60 | permet de programmer visuellement, avec la souris. Fini les fautes 61 | de frappe. Elle crée le code MicroAlg correspondant et l’envoie 62 | dans la zone de texte juste en dessous.

63 |

Commencer par cliquer sur une des catégories de commandes sur la 64 | gauche (Valeurs, Cmdes……) et glisser un 65 | bloc Afficher dans le bloc Programme de 66 | l’espace de travail. Puis dans la catégorie Autres, 67 | prendre un bloc de texte (avec les guillemets "..."), 68 | le glisser au bout du bloc Afficher puis taper un 69 | message dans ce dernier bloc. Le code correspondant s’affichera 70 | dans la fenêtre en dessous, et pourra être exécuté en cliquant sur 71 | le bouton Exécuter.

72 |

Pour apprendre MicroAlg au travers de cette interface, suivre 73 | le tutoriel correspondant.

74 |

La première zone de texte permet 75 | d’éditer des scripts. Pour les exécuter, appuyer sur 76 | Ctrl+Entrée ou cliquer sur le bouton 77 | Exécuter.

78 |

L’affichage des résultats se fait juste après la fenêtre 79 | d’édition si vous utilisez la commande Afficher, ou 80 | dans la fenêtre graphique si vous utilisez 81 | des commandes 82 | graphiques.

83 |

Consoles interactives

84 |

Les autres zones de texte permettent un échange « instructions 85 | après instructions » avec l’environnement.

86 |

C’est pratique pour tester des instructions quand on développe 87 | un programme dans la zone d’édition de scripts.

88 |

En particulier, la deuxième zone de texte 89 | est un terminal de fortune, bricolé pour l’occasion. Pour exécuter 90 | le code, appuyer sur Ctrl+Entrée ou 91 | cliquer sur le bouton Exécuter.

92 |

La troisième zone de texte 93 | utilise un plugin jQuery 94 | d’émulation de terminal. Elle est donc assez confortable mais ses 95 | parenthèses ne sont pas colorées et on ne peut pas passer à la 96 | ligne sans exécuter le code.

97 | 98 |
99 |
100 |















101 |















102 |
103 |
104 | 123 | 124 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /install_scripts/fix_lettuce.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sed -i -e 's/self.wrt(str(reason.step))/self.wrt(unicode(reason.step))/' /usr/local/lib/python2.7/dist-packages/lettuce/plugins/reporter.py 3 | -------------------------------------------------------------------------------- /install_scripts/install_picolisp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "Installing Picolisp..." 3 | VERSION=3.1.6 4 | wget "http://software-lab.de/picoLisp-$VERSION.tgz" 5 | tar xzf "picoLisp-$VERSION.tgz" 6 | mv picoLisp picolisp 7 | rm "picoLisp-$VERSION.tgz" 8 | 9 | cd picolisp/src 10 | make 11 | cd - 12 | -------------------------------------------------------------------------------- /jar/js.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/jar/js.jar -------------------------------------------------------------------------------- /lib/xml.l: -------------------------------------------------------------------------------- 1 | # https://www.mail-archive.com/picolisp@software-lab.de/msg00510.html 2 | # https://www.mail-archive.com/picolisp@software-lab.de/msg04592.html 3 | 4 | (de Lst 5 | ( Lst) ) 6 | 7 | (de (Lst) 8 | (let Tag (pop 'Lst) 9 | (prin "<" Tag) 10 | (while (and Lst (atom (car Lst))) 11 | (prin " " (pop 'Lst) "=\"") 12 | (escXml (eval (pop 'Lst) 1)) 13 | (prin "\"") ) 14 | (ifn Lst 15 | (prin "/>") 16 | (prin ">") 17 | (run Lst 1) 18 | (prin "") ) ) ) 19 | (de escXml (X) 20 | (for C (chop X) 21 | (case C 22 | ("\"" (prin """)) 23 | ("&" (prin "&")) 24 | ("<" (prin "<")) 25 | (">" (prin ">")) 26 | (T (prin C)) ) ) ) 27 | -------------------------------------------------------------------------------- /malg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "MicroAlg 0.4.07 (PicoLisp)" 4 | echo 5 | 6 | # http://stackoverflow.com/questions/242538/unix-shell-script-find-out-which-directory-the-script-file-resides#1638397 7 | SCRIPT=$(readlink -f "$0") 8 | SCRIPTPATH=$(dirname "$SCRIPT") 9 | 10 | if [ -n "${1+x}" ] 11 | then 12 | # Un arg est reçu. 13 | if [ -f "$1" ] 14 | then 15 | # Si l’arg est un nom valide de fichier, on lit ce fichier. 16 | pil $SCRIPTPATH/microalg.l $1 -bye 17 | else 18 | # Sinon, erreur. 19 | echo "$1: ce fichier n'existe pas." 20 | fi 21 | else 22 | # Sans arg, on lance le REPL. 23 | pil $SCRIPTPATH/microalg.l 24 | fi 25 | -------------------------------------------------------------------------------- /malg-clj.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo MicroAlg-clj (Clojure) 3 | echo. 4 | SET MICROALG_DIR=%~dp0 5 | java -jar %MICROALG_DIR%/jar\microalg-clj.jar %1 6 | IF NOT DEFINED NO_PAUSE pause>nul|set/p="Une touche pour quitter."&echo( 7 | -------------------------------------------------------------------------------- /malg-j: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "MicroAlg 0.4.07 (Ersatz)" 4 | echo 5 | 6 | # http://stackoverflow.com/questions/242538/unix-shell-script-find-out-which-directory-the-script-file-resides#1638397 7 | SCRIPT=$(readlink -f "$0") 8 | SCRIPTPATH=$(dirname "$SCRIPT") 9 | 10 | if [ -n "${1+x}" ] 11 | then 12 | # Un arg est reçu. 13 | if [ -f "$1" ] 14 | then 15 | # Si l’arg est un nom valide de fichier, on lit ce fichier. 16 | pil-j $SCRIPTPATH/microalg.l $1 -bye 17 | else 18 | # Sinon, erreur. 19 | echo "$1: ce fichier n'existe pas." 20 | fi 21 | else 22 | # Sans arg, on lance le REPL. 23 | pil-j $SCRIPTPATH/microalg.l 24 | fi 25 | -------------------------------------------------------------------------------- /malg-j-repl.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo MicroAlg 0.4.07 (Ersatz) 3 | echo Taper (bye) pour quitter. 4 | echo. 5 | SET MICROALG_DIR=%~dp0 6 | SET ERSATZ_DIR=%MICROALG_DIR%\ersatz 7 | java -DPID=42 -jar %ERSATZ_DIR%\picolisp.jar %ERSATZ_DIR%\lib.l %MICROALG_DIR%microalg.l %1 8 | -------------------------------------------------------------------------------- /malg-j.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo MicroAlg 0.4.07 (Ersatz) 3 | echo. 4 | SET MICROALG_DIR=%~dp0 5 | SET ERSATZ_DIR=%MICROALG_DIR%\ersatz 6 | java -DPID=42 -jar %ERSATZ_DIR%\picolisp.jar %ERSATZ_DIR%\lib.l %MICROALG_DIR%microalg.l %1 -bye 7 | IF NOT DEFINED NO_PAUSE pause>nul|set/p="Une touche pour quitter."&echo( 8 | -------------------------------------------------------------------------------- /malg-njs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "MicroAlg 0.4.07 (NodeJS + EmuLisp)" 4 | echo 5 | 6 | # http://stackoverflow.com/questions/242538/unix-shell-script-find-out-which-directory-the-script-file-resides#1638397 7 | SCRIPT=$(readlink -f "$0") 8 | SCRIPTPATH=$(dirname "$SCRIPT") 9 | 10 | if [ -n "${1+x}" ] 11 | then 12 | # Un arg est reçu. 13 | if [ -f "$1" ] 14 | then 15 | # Si l’arg est un nom valide de fichier, on lit ce fichier. 16 | pil-njs $SCRIPTPATH/microalg.l $1 -bye 17 | else 18 | # Sinon, erreur. 19 | echo "$1: ce fichier n'existe pas." 20 | fi 21 | else 22 | # Sans arg, on lance le REPL. 23 | pil-njs $SCRIPTPATH/microalg.l 24 | fi 25 | -------------------------------------------------------------------------------- /malg-njs-repl.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set NODE_PATH=%USERPROFILE%\AppData\Roaming\npm\node_modules;"%NODE_PATH%" 3 | echo MicroAlg 0.4.07 (NodeJS + EmuLisp) 4 | echo Taper (bye) pour quitter. 5 | echo. 6 | SET MICROALG_DIR=%~dp0 7 | SET EMULISP_DIR=%MICROALG_DIR%\emulisp 8 | node %EMULISP_DIR%\pil-njs %MICROALG_DIR%\microalg.l 9 | -------------------------------------------------------------------------------- /malg-njs.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set NODE_PATH=%USERPROFILE%\AppData\Roaming\npm\node_modules;"%NODE_PATH%" 3 | echo MicroAlg 0.4.07 (NodeJS + EmuLisp) 4 | echo. 5 | SET MICROALG_DIR=%~dp0 6 | SET EMULISP_DIR=%MICROALG_DIR%\emulisp 7 | node %EMULISP_DIR%\pil-njs %MICROALG_DIR%\microalg.l "%1" -bye 8 | IF NOT DEFINED NO_PAUSE pause>nul|set/p="Une touche pour quitter."&echo( 9 | -------------------------------------------------------------------------------- /malg-rjs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "MicroAlg 0.4.07 (RhinoJS + EmuLisp)" 4 | echo 5 | 6 | # http://stackoverflow.com/questions/242538/unix-shell-script-find-out-which-directory-the-script-file-resides#1638397 7 | SCRIPT=$(readlink -f "$0") 8 | SCRIPTPATH=$(dirname "$SCRIPT") 9 | 10 | if [ -n "${1+x}" ] 11 | then 12 | # Un arg est reçu. 13 | if [ -f "$1" ] 14 | then 15 | # Si l’arg est un nom valide de fichier, on lit ce fichier. 16 | pil-rjs $SCRIPTPATH/microalg.l $1 -bye 17 | else 18 | # Sinon, erreur. 19 | echo "$1: ce fichier n'existe pas." 20 | fi 21 | else 22 | # Sans arg, on lance le REPL. 23 | pil-rjs $SCRIPTPATH/microalg.l 24 | fi 25 | -------------------------------------------------------------------------------- /malg-rjs-repl.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo MicroAlg 0.4.07 (Rhino + EmuLisp) 3 | echo Taper (bye) pour quitter. 4 | echo. 5 | SET MICROALG_DIR=%~dp0 6 | SET EMULISP_DIR=%MICROALG_DIR%\emulisp 7 | java -jar %MICROALG_DIR%\jar\js.jar %EMULISP_DIR%\pil-rjs %MICROALG_DIR%\microalg.l 8 | -------------------------------------------------------------------------------- /malg-rjs.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo MicroAlg 0.4.07 (Rhino + EmuLisp) 3 | echo. 4 | SET MICROALG_DIR=%~dp0 5 | SET EMULISP_DIR=%MICROALG_DIR%\emulisp 6 | java -jar %MICROALG_DIR%\jar\js.jar %EMULISP_DIR%\pil-rjs %MICROALG_DIR%\microalg.l "%1" -bye 7 | IF NOT DEFINED NO_PAUSE pause>nul|set/p="Une touche pour quitter."&echo( 8 | -------------------------------------------------------------------------------- /microalg_export.l: -------------------------------------------------------------------------------- 1 | (setq !cmdes_sans_retour 2 | '(!!! AV BC LC TD TG Affecter_a Afficher Ajouter_a Cercle Contour 3 | Declarer Definir Ellipse Epaisseur Exemples_de 4 | Faire Initialiser@ RAZ Rectangle Remplissage Repere Repeter Retirer_de 5 | Retourner Segment Si Tant_que Tester Triangle) ) 6 | 7 | (de proteger_source src (mapcar 'proteger_source_aux src (need (length src) T))) 8 | (de proteger_source_aux (src premier_niveau) 9 | (cond 10 | ((num? src) (list 'Litteral src)) 11 | ((str? src) (list 'Litteral src)) 12 | ((sym? src) (if (index src '(Vrai Faux Rien Alors Sinon Tant_que Faire 13 | En_position De_type Fois)) 14 | src 15 | (list 'Variable src))) 16 | (T (if (and (not premier_niveau) 17 | (index (car src) !cmdes_sans_retour)) 18 | (list 'indent 19 | (cons (car src) 20 | (mapcar 'proteger_source_aux (cdr src)))) 21 | (cons (car src) (mapcar 'proteger_source_aux (cdr src))) 22 | ) 23 | ) 24 | ) 25 | ) 26 | 27 | (de proteger_source_sans_indentation src (mapcar 'proteger_source_sans_indentation_aux src)) 28 | (de proteger_source_sans_indentation_aux (src) 29 | (cond 30 | ((num? src) (list 'Litteral src)) 31 | ((str? src) (list 'Litteral src)) 32 | ((sym? src) (if (index src '(Vrai Faux Rien Alors Sinon Tant_que Faire 33 | En_position De_type Fois)) 34 | src 35 | (list 'Variable src))) 36 | (T (cons (car src) (mapcar 'proteger_source_sans_indentation_aux (cdr src)))) 37 | ) 38 | ) 39 | 40 | # Default implementation, should be reimplemented for every textual language: 41 | (de indent (!instr) !instr) 42 | # Standard implementation, if needed: 43 | (de indent_std (!instr) 44 | (let (!lines_with_final_NIL (mapcar pack (split (chop !instr) "^J")) 45 | !lines (reverse (cdr (reverse !lines_with_final_NIL)))) 46 | (mapcar (list '(!line) 47 | (list 'pack " " '!line "^J")) !lines) 48 | ) 49 | ) 50 | 51 | (ifn glue 52 | (de glue (c l) 53 | (cond 54 | ((not (<> 0 (length l))) "") 55 | ((not (<> 1 (length l))) (car l)) 56 | (T (pack (car l) c (glue c (cdr l)))) 57 | ) 58 | ) 59 | ) 60 | 61 | (ifn caadr 62 | (de caadr (arg) 63 | (car (car (cdr arg))) 64 | ) 65 | ) 66 | 67 | (setq Somme '+) 68 | (setq Diff '-) 69 | (setq Produit '*) 70 | (setq Quotient '/) 71 | (setq Reste '%) 72 | (setq Puissance '^) -------------------------------------------------------------------------------- /microalg_export_arbreninja.l: -------------------------------------------------------------------------------- 1 | (setq *id 0) 2 | (de arbreninja malg_src 3 | (pack "
  1. " 4 | (mapcar 'arbreninja_rec malg_src) 5 | "
" 6 | ) 7 | ) 8 | 9 | (de arbreninja_rec (malg_src) 10 | (cond 11 | ((atom malg_src) (pack "
  • " 12 | (ifn (str? malg_src) malg_src 13 | (pack "« " malg_src " »") ) 14 | "
  • ")) 15 | (T (let (cmd (car malg_src) 16 | args (cdr malg_src)) 17 | (inc '*id) 18 | (pack "" 19 | "" 20 | (if args 21 | (pack "
      " (mapcar 'arbreninja_rec args) "
    ")) 22 | ) 23 | ) 24 | ) 25 | ) 26 | ) -------------------------------------------------------------------------------- /microalg_export_arbresvg.l: -------------------------------------------------------------------------------- 1 | (de arbresvg malg_src 2 | (push 'malg_src 'Programme) 3 | (arbresvg_rec malg_src) 4 | ) 5 | 6 | (de arbresvg_rec (malg_src !indent_level !node_str) 7 | (cond 8 | ((atom malg_src) (pack "{\"label\":\"" 9 | (ifn (str? malg_src) 10 | (pack " " malg_src " ") 11 | (pack "«" malg_src "»") ) 12 | "\"}")) 13 | (T (let (cmd (car malg_src) 14 | args (cdr malg_src)) 15 | (pack "{\"label\":\"" 16 | cmd 17 | "\", \"children\": [" 18 | (glue ", " (mapcar 'arbresvg_rec args)) 19 | "]}" 20 | ) 21 | ) 22 | ) 23 | ) 24 | ) 25 | 26 | (ifn glue 27 | (de glue (c l) 28 | (cond 29 | ((not (<> 0 (length l))) "") 30 | ((not (<> 1 (length l))) (car l)) 31 | (T (pack (car l) c (glue c (cdr l)))) 32 | ) 33 | ) 34 | ) -------------------------------------------------------------------------------- /microalg_export_arbretxt.l: -------------------------------------------------------------------------------- 1 | (de arbretxt malg_src 2 | (pack (mapcar 'arbretxt_rec malg_src)) 3 | ) 4 | 5 | (de arbretxt_rec (malg_src !indent_level !node_str) 6 | (ifn !indent_level (setq !indent_level 0)) 7 | (pack 8 | (if (gt0 !indent_level) (pack (need (dec !indent_level) "│ ") !node_str)) 9 | (cond 10 | ((atom malg_src) (pack (if (str? malg_src) (pack "\"" malg_src "\"") malg_src) "^J")) 11 | (T (let (cmd (car malg_src) 12 | rev_args (reverse (cdr malg_src)) 13 | args_but_last (reverse (cdr rev_args)) 14 | last_arg (car rev_args) 15 | length_but_last (length args_but_last)) 16 | (pack cmd "^J" 17 | (if rev_args (pack 18 | (mapcar 'arbretxt_rec args_but_last (need length_but_last (inc !indent_level)) (need length_but_last "├─")) 19 | (arbretxt_rec last_arg (inc !indent_level) "└─"))) 20 | ) 21 | ) 22 | ) 23 | ) 24 | ) 25 | ) -------------------------------------------------------------------------------- /microalg_export_casio.l: -------------------------------------------------------------------------------- 1 | (de Litteral (content) 2 | (cond 3 | ((num? content) content) 4 | ((str? content) (pack "\"" content "\"")) 5 | (T "Littéral de type inconnu.") 6 | )) 7 | (de Variable inputs 8 | (let (nom_var (car inputs)) 9 | (if nom_var nom_var "") 10 | ) 11 | ) 12 | (de indent (!instr) 13 | (indent_std !instr) 14 | ) 15 | 16 | (de + @ (pack "(" (glue "+" (rest)) ")")) 17 | (de - (A B) (pack "(" A "-" B ")")) 18 | (de * @ (pack "(" (glue "×" (rest)) ")")) 19 | (de / (A B) (pack "(" A "÷" B ")")) 20 | (de % (A B) (pack "Mod(" A "," B ")")) 21 | (de ^ (A B) (pack "(" A "\^" B ")")) 22 | (de Carre (A) (pack "(" A ")²")) 23 | (setq Carré Carre) 24 | (de Racine (A) (pack "√(" A ")")) 25 | 26 | (setq Somme +) 27 | (setq Diff -) 28 | (setq Produit *) 29 | (setq Quotient /) 30 | (setq Reste %) 31 | (setq Puissance ^) 32 | 33 | (de !!! (comz) (pack "' " (cdr (reverse (cdr (reverse (chop comz))))) "^J")) 34 | (de Afficher (obj) (pack obj "◢^J")) 35 | (de !store (!arg_lst) 36 | (let (var (eval (car !arg_lst)) 37 | val (cadr !arg_lst)) 38 | (cond 39 | ((== 'Demander (car val)) (pack "?→Str " var "^J")) 40 | ((== 'Demander_un_nombre (car val)) (pack "?→" var "^J")) 41 | ((and (== 'Nombre (car val)) 42 | (== 'Demander (car (cadr val)))) (pack "?→" var "^J")) 43 | (T (pack (eval val) "→" var "^J")) 44 | ) 45 | )) 46 | (de Declarer !arg_lst 47 | (let (!splitted (split !arg_lst 'De_type) 48 | !vars (mapcar 'cadr (car !splitted)) # var name is in (Variable ...) 49 | !type (caadr !splitted)) 50 | (pack "' " (glue " " !vars) " de type " (cadr !type) "^J") # type is in (Litteral ...) 51 | ) 52 | ) 53 | (setq Déclarer 'Declarer) 54 | (de Affecter_a !arg_lst (!store !arg_lst)) 55 | (setq Affecter_à 'Affecter_a) 56 | (de Demander () (pack "-- La commande `Demander` doit être utilisée avec " 57 | "`Affecter_a`. --")) 58 | (de Demander_un_nombre () (pack "-- La commande `Demander_un_nombre` doit être utilisée avec " 59 | "`Affecter_a`. --")) 60 | (de Demander_un_nombre_pour !arg_lst 61 | (let (!var (cadr (car !arg_lst))) # var name is in (Variable ...) 62 | (pack "?→" !var "^J") 63 | ) 64 | ) 65 | (de Entier@ (A B) (pack "RanInt#(" A "," B ")")) 66 | (setq Vrai "1") 67 | (setq Faux "0") 68 | (setq Rien "Rien") 69 | (de Si arg_lst (let (condition (car arg_lst) 70 | kw_alors (cadr arg_lst) 71 | splitted (split (cddr arg_lst) 'Sinon) 72 | bloc_vrai (car splitted) 73 | bloc_faux (cadr splitted)) 74 | (pack 75 | "If " (eval condition) "^J" "Then^J" 76 | (mapcar 'eval bloc_vrai) 77 | (if bloc_faux (pack "Else^J" (mapcar 'eval bloc_faux))) 78 | "IfEnd^J" 79 | ) 80 | ) 81 | ) 82 | (de Non (bool) (pack "(Not " bool ")")) 83 | (de Et !arg_lst (pack "(" (glue " And " (mapcar 'eval !arg_lst)) ")")) 84 | (de Ou !arg_lst (pack "(" (glue " Or " (mapcar 'eval !arg_lst)) ")")) 85 | (de Tant_que arg_lst (let (!cond (car arg_lst) 86 | !mot-clef (cadr arg_lst) 87 | !corps (cddr arg_lst)) 88 | (pack 89 | "While " (eval !cond) "^J" 90 | (mapcar 'eval !corps) 91 | "WhileEnd^J" 92 | ) 93 | ) 94 | ) 95 | (de Faire arg_lst (let (!splitted (split arg_lst 'Tant_que) 96 | !corps (car !splitted) 97 | !cond (caadr !splitted)) 98 | (pack 99 | "Do^J" 100 | (mapcar 'eval !corps) 101 | "LpWhile " (eval !cond) "^J" 102 | ) 103 | ) 104 | ) 105 | 106 | (de = (A B) (pack "(" A "=" B ")")) 107 | (de < (A B) (pack "(" A "<" B ")")) 108 | (de <= (A B) (pack "(" A "<=" B ")")) 109 | (de > (A B) (pack "(" A ">" B ")")) 110 | (de >= (A B) (pack "(" A ">=" B ")")) 111 | (de =/ (A B) (pack "(" A "≠" B ")")) 112 | 113 | (de ... () " (...) ") 114 | 115 | (de !no_export (cmd) 116 | (pack "-- La commande " cmd " ne peut être exportée. --^J")) 117 | 118 | (de Concatener () (!no_export "Concatener")) # StrJoin( 119 | (de Concaténer () (!no_export "Concaténer")) 120 | (de Liste () (!no_export "Liste")) 121 | (de Longueur () (!no_export "Longueur")) 122 | (de Nieme () (!no_export "Nieme")) 123 | (de Tete () (!no_export "Tete")) 124 | (de Queue () (!no_export "Queue")) 125 | (de Ajouter_a () (!no_export "Ajouter_a")) 126 | (de Retirer_de () (!no_export "Retirer_de")) 127 | # En_position 128 | (de Initialiser@ () (!no_export "Initialiser@")) 129 | (de Nieme@ () (!no_export "Nieme@")) 130 | (de Type () (!no_export "Type")) 131 | (de Texte () (!no_export "Texte")) 132 | (de Nombre () (!no_export "Nombre")) 133 | # Alors Sinon 134 | (de Repeter () (!no_export "Repeter")) 135 | (de Répéter () (!no_export "Répéter")) 136 | (de Definir () (!no_export "Definir")) 137 | (de Définir () (!no_export "Définir")) 138 | (de Retourner () (!no_export "Retourner")) 139 | (de Exemples_de () (!no_export "Exemples_de")) 140 | (de Tester () (!no_export "Tester")) 141 | (de ? () (!no_export "?")) 142 | (de Millisecondes () (!no_export "Millisecondes")) 143 | 144 | (de AV () (!no_export "AV")) 145 | (de BC () (!no_export "BC")) 146 | (de LC () (!no_export "LC")) 147 | (de TD () (!no_export "TD")) 148 | (de TG () (!no_export "TG")) 149 | (de Cercle () (!no_export "Cercle")) 150 | (de Contour () (!no_export "Contour")) 151 | (de Ellipse () (!no_export "Ellipse")) 152 | (de Epaisseur () (!no_export "Epaisseur")) 153 | (de RAZ () (!no_export "RAZ")) 154 | (de Rectangle () (!no_export "Rectangle")) 155 | (de Remplissage () (!no_export "Remplissage")) 156 | (de Repere () (!no_export "Repere")) 157 | (de Segment () (!no_export "Segment")) 158 | (de Triangle () (!no_export "Triangle")) 159 | (de 1000Cosinus () (!no_export "1000Cosinus")) 160 | (de 1000Sinus () (!no_export "1000Sinus")) 161 | -------------------------------------------------------------------------------- /microalg_export_javascript.l: -------------------------------------------------------------------------------- 1 | (de Litteral (content) 2 | (cond 3 | ((num? content) content) 4 | ((str? content) (pack "\"" content "\"")) 5 | (T "Littéral de type inconnu.") 6 | )) 7 | (de Variable inputs 8 | (let (nom_var (car inputs)) 9 | (if nom_var nom_var "") 10 | ) 11 | ) 12 | (de indent (!instr) 13 | (indent_std !instr)) 14 | 15 | (de + @ (pack "(" (glue " + " (rest)) ")")) 16 | (de - (A B) (pack "(" A "-" B ")")) 17 | (de * @ (pack "(" (glue " * " (rest)) ")")) 18 | (de / (A B) (pack "(" A "/" B ")")) 19 | (de % (A B) (pack "(" A "%" B ")")) 20 | (de ^ (A B) (pack "Math.pow(" A ", " B ")")) 21 | (de Racine (A) (pack "Math.sqrt(" A ")")) 22 | 23 | (de !!! (comz) (pack "// " (cdr (reverse (cdr (reverse (chop comz))))) "^J")) 24 | (de Afficher (obj) (pack "console.log(" obj ");^J")) 25 | (de Declarer !arg_lst 26 | (let (!splitted (split !arg_lst 'De_type) 27 | !vars (mapcar 'cadr (car !splitted)) # var name is in (Variable ...) 28 | !type (cadr (caadr !splitted))) # type is in (Litteral ...) 29 | (pack "var " (glue ", " !vars) ";^J") 30 | ) 31 | ) 32 | (setq Déclarer 'Declarer) 33 | (de Concatener @ (glue " + " (rest))) 34 | (setq Concaténer 'Concatener) 35 | (de Affecter_a !arg_lst 36 | (let (!var (cadr (car !arg_lst)) # var name is in (Variable ...) 37 | !val (eval (cadr !arg_lst))) 38 | (pack !var " = " !val ";^J"))) 39 | (setq Affecter_à 'Affecter_a) 40 | (de Entier@ (A B) (pack "int(" A " + random(" B "-" A "+1))")) 41 | (setq Vrai "true") 42 | (setq Faux "false") 43 | (setq Rien "null") 44 | (de Si arg_lst (let (condition (car arg_lst) 45 | kw_alors (cadr arg_lst) 46 | splitted (split (cddr arg_lst) 'Sinon) 47 | bloc_vrai (car splitted) 48 | bloc_faux (cadr splitted)) 49 | (pack 50 | "if (" (eval condition) ")^J" "{^J" 51 | (mapcar 'eval bloc_vrai) 52 | (if bloc_faux (pack "} else {^J" (mapcar 'eval bloc_faux))) 53 | "}^J" 54 | ) 55 | ) 56 | ) 57 | (de Non (bool) (pack "!(" bool ")")) 58 | (de Et !arg_lst (pack "(" (glue " && " (mapcar 'eval !arg_lst)) ")")) 59 | (de Ou !arg_lst (pack "(" (glue " || " (mapcar 'eval !arg_lst)) ")")) 60 | (de Tant_que arg_lst (let (!cond (car arg_lst) 61 | !mot-clef (cadr arg_lst) 62 | !corps (cddr arg_lst)) 63 | (pack 64 | "while (" (eval !cond) ") {^J" 65 | (mapcar 'eval !corps) 66 | "}^J" 67 | ) 68 | ) 69 | ) 70 | (de Faire arg_lst (let (!splitted (split arg_lst 'Tant_que) 71 | !corps (car !splitted) 72 | !cond (caadr !splitted)) 73 | (pack 74 | "do {^J" 75 | (mapcar 'eval !corps) 76 | "} while (" (eval !cond) ");^J" 77 | ) 78 | ) 79 | ) 80 | 81 | (de = (A B) (pack "(" A " === " B ")")) 82 | (de < (A B) (pack "(" A " < " B ")")) 83 | (de <= (A B) (pack "(" A " <= " B ")")) 84 | (de > (A B) (pack "(" A " > " B ")")) 85 | (de >= (A B) (pack "(" A " >= " B ")")) 86 | (de =/ (A B) (pack "(" A " != " B ")")) 87 | 88 | (de Liste @ (pack "[" (glue ", " (rest)) "]")) 89 | 90 | (de 1000Cosinus (angle) (pack "Math.cos(" angle "/180*Math.PI)")) 91 | (de 1000Sinus (angle) (pack "Math.sin(" angle "/180*Math.PI)")) 92 | 93 | (de Longueur (A) (pack A ".length")) 94 | (de Nieme (obj idx) (pack obj "[" idx "-1]")) 95 | (de Millisecondes () "(new Date().getTime())") 96 | 97 | (de Demander () "window.prompt()") 98 | (de Demander_un_nombre () "parseFloat(window.prompt())") 99 | (de Demander_un_nombre_pour !arg_lst 100 | (let (!var (cadr (car !arg_lst))) # var name is in (Variable ...) 101 | (pack !var " = parseFloat(window.prompt());^J") 102 | ) 103 | ) 104 | (de Type (A) (pack "typeof(" A ")")) 105 | 106 | (de Tete (obj) (pack obj "[0]")) 107 | (de Queue (obj) (pack obj ".slice(1)")) 108 | (de Ajouter_a (obj val) (pack obj ".push(" val ");^J")) 109 | (de Retirer_de (obj val) (pack obj ".pop();^J")) 110 | # En_position 111 | (de Nieme@ (obj idx) (pack obj "[Math.floor(Math.random() * " obj ".length)]")) 112 | (de Texte (obj) (pack "String(" obj ")")) 113 | (de Nombre (obj) (pack "parseFloat(" obj ")")) 114 | (de ... () " (...) ") 115 | 116 | (de !no_export (cmd) 117 | (pack "-- La commande " cmd " ne peut être exportée. --^J")) 118 | 119 | (de Initialiser@ () (!no_export "Initialiser@")) 120 | (de Definir () (!no_export "Definir")) 121 | (de Définir () (!no_export "Définir")) 122 | (de Retourner () (!no_export "Retourner")) 123 | (de Exemples_de () (!no_export "Exemples_de")) 124 | (de Tester () (!no_export "Tester")) 125 | (de ? () (!no_export "?")) 126 | # Alors Sinon 127 | (de Repeter () (!no_export "Repeter")) 128 | (de Répéter () (!no_export "Répéter")) 129 | 130 | (de AV () (!no_export "AV")) 131 | (de BC () (!no_export "BC")) 132 | (de LC () (!no_export "LC")) 133 | (de TD () (!no_export "TD")) 134 | (de TG () (!no_export "TG")) 135 | (de Cercle () (!no_export "Cercle")) 136 | (de Contour () (!no_export "Contour")) 137 | (de Ellipse () (!no_export "Ellipse")) 138 | (de Epaisseur () (!no_export "Epaisseur")) 139 | (de RAZ () (!no_export "RAZ")) 140 | (de Rectangle () (!no_export "Rectangle")) 141 | (de Remplissage () (!no_export "Remplissage")) 142 | (de Repere () (!no_export "Repere")) 143 | (de Segment () (!no_export "Segment")) 144 | (de Triangle () (!no_export "Triangle")) 145 | -------------------------------------------------------------------------------- /microalg_export_microalg.l: -------------------------------------------------------------------------------- 1 | (de Litteral (content) 2 | (cond 3 | ((num? content) content) 4 | ((str? content) (pack "\"" content "\"")) 5 | (T "Littéral de type inconnu.") 6 | )) 7 | (de Variable inputs 8 | (let (nom_var (car inputs)) 9 | (if nom_var nom_var "") 10 | ) 11 | ) 12 | (de indent (!instr) 13 | (let (!lines_with_final_NIL (mapcar pack (split (chop !instr) "^J")) 14 | !lines (reverse (cdr (reverse !lines_with_final_NIL)))) 15 | (mapcar (list '(!line) 16 | (list 'pack " " '!line "^J")) !lines) 17 | ) 18 | ) 19 | 20 | (de + @ (pack "(+ " (glue " " (rest)) ")")) 21 | (de - (A B) (pack "(- " A " " B ")")) 22 | (de * @ (pack "(* " (glue " " (rest)) ")")) 23 | (de / (A B) (pack "(/ " A " " B ")")) 24 | (de % (A B) (pack "(% " A " " B ")")) 25 | (de ^ (A B) (pack "(\^ " A " " B ")")) 26 | (de Racine (A) (pack "(Racine " A ")")) 27 | 28 | (de !!! (comz) (pack "(!!! " (if comz @ "\"\"") ")^J")) 29 | (de Afficher (obj) (pack "(Afficher " obj ")^J")) 30 | (de Declarer !arg_lst 31 | (let (!splitted (split !arg_lst 'De_type) 32 | !vars (mapcar 'cadr (car !splitted)) # var name is in (Variable ...) 33 | !type (cadr (caadr !splitted))) # type is in (Litteral ...) 34 | (pack "(Declarer " 35 | (glue " " !vars) 36 | " De_type \"" 37 | !type "\")^J" 38 | ) 39 | ) 40 | ) 41 | (setq Déclarer 'Declarer) 42 | (de Concatener @ 43 | (let (!arg_lst (rest) 44 | !space_separated (glue " " !arg_lst) 45 | !length (length !space_separated)) 46 | (if (le0 (dec '!length 30)) # à la louche 47 | (pack "(Concatener " !space_separated ")") 48 | (pack "^J (Concatener^J " 49 | (glue "^J " !arg_lst) "^J" 50 | " )" 51 | "^J") 52 | ) 53 | ) 54 | ) 55 | (setq Concaténer 'Concatener) 56 | (de Affecter_a !arg_lst 57 | (let (!var (cadr (car !arg_lst)) # var name is in (Variable ...) 58 | !val (eval (cadr !arg_lst))) 59 | (pack "(Affecter_a " !var " " !val ")^J"))) 60 | (setq Affecter_à 'Affecter_a) 61 | (de Entier@ (A B) (pack "(Entier@ " A " " B ")")) 62 | (setq Vrai "Vrai") 63 | (setq Faux "Faux") 64 | (de Si arg_lst (let (condition (car arg_lst) 65 | kw_alors (cadr arg_lst) 66 | splitted (split (cddr arg_lst) 'Sinon) 67 | bloc_vrai (car splitted) 68 | bloc_faux (cadr splitted)) 69 | (pack 70 | "(Si " (eval condition) "^J" 71 | " Alors^J" 72 | (mapcar 'eval bloc_vrai) 73 | (if bloc_faux 74 | (pack " Sinon^J" 75 | (mapcar 'eval bloc_faux))) 76 | ")^J" 77 | ) 78 | ) 79 | ) 80 | (de Non (bool) (pack "(Non " bool ")")) 81 | (de Et @ (pack "(Et " (glue " " (rest)) ")")) 82 | (de Ou @ (pack "(Ou " (glue " " (rest)) ")")) 83 | (de Tant_que arg_lst (let (!cond (car arg_lst) 84 | !mot-clef (cadr arg_lst) 85 | !corps (cddr arg_lst)) 86 | (pack 87 | "(Tant_que " (eval !cond) "^J" 88 | " Faire^J" 89 | (mapcar 'eval !corps) 90 | ")^J" 91 | ) 92 | ) 93 | ) 94 | (de Faire arg_lst (let (!splitted (split arg_lst 'Tant_que) 95 | !corps (car !splitted) 96 | !cond (caadr !splitted)) 97 | (pack 98 | "(Faire^J" 99 | (mapcar 'eval !corps) 100 | " Tant_que " (eval !cond) "^J" 101 | ")^J" 102 | ) 103 | ) 104 | ) 105 | 106 | (de = (A B) (pack "(= " A " " B ")")) 107 | (de < (A B) (pack "(< " A " " B ")")) 108 | (de <= (A B) (pack "(<= " A " " B ")")) 109 | (de > (A B) (pack "(> " A " " B ")")) 110 | (de >= (A B) (pack "(>= " A " " B ")")) 111 | (de =/ (A B) (pack "(=/ " A " " B ")")) 112 | 113 | (de Liste @ (pack "(Liste " (glue " " (rest)) ")")) 114 | 115 | (de 1000Cosinus (angle) (pack "(1000Cosinus " angle ")")) 116 | (de 1000Sinus (angle) (pack "(1000Sinus " angle ")")) 117 | 118 | (de Longueur (A) (pack "(Longueur " A ")")) 119 | (de Nieme (obj idx) (pack "(Nieme " obj " " idx ")")) 120 | (de Millisecondes () "(Millisecondes)") 121 | 122 | (de RAZ () "(RAZ)^J") 123 | (de Cercle inputs 124 | (let (origine (eval (car inputs)) 125 | r (eval (cadr inputs))) 126 | (pack "(Cercle " origine " " r ")^J") 127 | ) 128 | ) 129 | (de Contour (coul) 130 | (pack "(Contour " coul ")^J")) 131 | (de Remplissage (coul) 132 | (pack "(Remplissage " coul ")^J")) 133 | (de Ellipse inputs 134 | (let (origine (eval (car inputs)) 135 | r1 (eval (cadr inputs)) 136 | r2 (eval (caddr inputs))) 137 | (pack "(Ellipse " origine " " r1 " " r2 ")^J") 138 | ) 139 | ) 140 | (de Epaisseur (e) 141 | (pack "(Epaisseur " e ")^J") 142 | ) 143 | (de Rectangle (p1 p2) 144 | (pack "(Rectangle " p1 " " p2 ")^J") 145 | ) 146 | (de Segment (p1 p2) 147 | (pack "(Segment " p1 " " p2 ")^J") 148 | ) 149 | (de Triangle (p1 p2 p3) 150 | (pack "(Triangle " p1 " " p2 " " p3 ")^J") 151 | ) 152 | (de Repere (xmin xmax ymin ymax xscl yscl) 153 | (pack "(Repere " xmin " " xmax " " ymin " " ymax 154 | (if xscl (pack " " xscl " " yscl)) 155 | ")^J" 156 | ) 157 | ) 158 | 159 | (de Tete (obj) (pack "(Tete " obj ")")) 160 | (de Queue (obj) (pack "(Queue " obj ")")) 161 | (de Ajouter_a (obj val) (pack "(Ajouter_a " obj " " val ")")) 162 | (de Retirer_de (obj) (pack "(Retirer_de " obj ")")) 163 | # En_position 164 | (de Nieme@ (obj) (pack "(Nieme@ " obj ")")) 165 | (de Texte (obj) (pack "(Texte " obj ")")) 166 | (de Nombre (obj) (pack "(Nombre " obj ")")) 167 | # Alors Sinon 168 | (de Repeter !inputs 169 | (let (nb (eval (car !inputs)) 170 | prg (cddr !inputs)) 171 | (pack "(Repeter " nb " Fois^J" 172 | (mapcar 'eval prg) 173 | ")^J" 174 | ) 175 | ) 176 | ) 177 | (setq Répéter 'Repeter) 178 | (de ... () "(...)") 179 | (de Demander () (pack "(Demander)")) 180 | (de Demander_un_nombre () (pack "(Demander_un_nombre)")) 181 | (de Demander_un_nombre_pour !arg_lst 182 | (let (!var (cadr (car !arg_lst))) # var name is in (Variable ...) 183 | (pack "(Demander_un_nombre_pour " !var ")^J") 184 | ) 185 | ) 186 | (de Initialiser@ (n) (pack "(Initialiser@ " n ")^J")) 187 | (de Type (obj) (pack "(Type " obj ")")) 188 | (de AV (n) (pack "(AV " n ")^J")) 189 | (de BC () (pack "(BC)^J")) 190 | (de LC () (pack "(LC)^J")) 191 | (de TD (a) (pack "(TD" (if a (pack " " @)) ")^J")) 192 | (de TG (a) (pack "(TG" (if a (pack " " @)) ")^J")) 193 | 194 | (de !no_export (cmd) 195 | (pack "-- La commande " cmd " ne peut être exportée. --^J")) 196 | 197 | (de Definir () (!no_export "Definir")) 198 | (de Définir () (!no_export "Définir")) 199 | (de Retourner () (!no_export "Retourner")) 200 | (de Exemples_de () (!no_export "Exemples_de")) 201 | (de Tester () (!no_export "Tester")) 202 | (de ? () (!no_export "?")) 203 | (setq Rien "Rien") 204 | -------------------------------------------------------------------------------- /microalg_export_processing.l: -------------------------------------------------------------------------------- 1 | (de Litteral (content) 2 | (cond 3 | ((num? content) content) 4 | ((str? content) (pack "\"" content "\"")) 5 | (T "Littéral de type inconnu.") 6 | )) 7 | (de Variable inputs 8 | (let (nom_var (car inputs)) 9 | (if nom_var nom_var "") 10 | ) 11 | ) 12 | (de indent (!instr) 13 | (indent_std !instr)) 14 | 15 | (de + (A B) (pack "(" A "+" B ")")) 16 | (de - (A B) (pack "(" A "-" B ")")) 17 | (de * (A B) (pack "(" A "*" B ")")) 18 | (de / (A B) (pack "(" A "/" B ")")) 19 | (de % (A B) (pack "(" A "%" B ")")) 20 | (de ^ (A B) (pack "pow(" A ", " B ")")) 21 | (de Racine (A) (pack "sqrt(" A ")")) 22 | 23 | (de !!! (comz) (pack "// " (cdr (reverse (cdr (reverse (chop comz))))) "^J")) 24 | (de Afficher (obj) (pack "println(" obj ");^J")) 25 | (de Declarer !arg_lst 26 | (let (!splitted (split !arg_lst 'De_type) 27 | !vars (mapcar 'cadr (car !splitted)) # var name is in (Variable ...) 28 | !type (cadr (caadr !splitted))) # type is in (Litteral ...) 29 | (cond 30 | ((not (<> !type "nombre")) 31 | (pack "float " (glue ", " !vars) ";^J")) 32 | ((not (<> !type "texte")) 33 | (pack "String " (glue ", " !vars) ";^J")) 34 | (T (pack "Impossible de gérer le type « " !type " » avec Processing.^J")) 35 | ) 36 | ) 37 | ) 38 | (setq Déclarer 'Declarer) 39 | (de Concatener @ (glue " + " (rest))) 40 | (setq Concaténer 'Concatener) 41 | (de Affecter_a !arg_lst 42 | (let (!var (cadr (car !arg_lst)) # var name is in (Variable ...) 43 | !val (eval (cadr !arg_lst))) 44 | (pack !var " = " !val ";^J"))) 45 | (setq Affecter_à 'Affecter_a) 46 | (de Entier@ (A B) (pack "int(" A " + random(" B "-" A "+1))")) 47 | (setq Vrai "true") 48 | (setq Faux "false") 49 | (setq Rien "null") 50 | (de Si arg_lst (let (condition (car arg_lst) 51 | kw_alors (cadr arg_lst) 52 | splitted (split (cddr arg_lst) 'Sinon) 53 | bloc_vrai (car splitted) 54 | bloc_faux (cadr splitted)) 55 | (pack 56 | "if (" (eval condition) ")^J" "{^J" 57 | (mapcar 'eval bloc_vrai) 58 | (if bloc_faux (pack "} else {^J" (mapcar 'eval bloc_faux))) 59 | "}^J" 60 | ) 61 | ) 62 | ) 63 | (de Non (bool) (pack "!(" bool ")")) 64 | (de Et @ (pack "(" (glue " && " (rest)) ")")) 65 | (de Ou ? (pack "(" (glue " || " (rest)) ")")) 66 | (de Tant_que arg_lst (let (!cond (car arg_lst) 67 | !mot-clef (cadr arg_lst) 68 | !corps (cddr arg_lst)) 69 | (pack 70 | "while (" (eval !cond) ") {^J" 71 | (mapcar 'eval !corps) 72 | "}^J" 73 | ) 74 | ) 75 | ) 76 | (de Faire arg_lst (let (!splitted (split arg_lst 'Tant_que) 77 | !corps (car !splitted) 78 | !cond (caadr !splitted)) 79 | (pack 80 | "do {^J" 81 | (mapcar 'eval !corps) 82 | "} while (" (eval !cond) ");^J" 83 | ) 84 | ) 85 | ) 86 | 87 | (de = (A B) (pack "(" A " == " B ")")) 88 | (de < (A B) (pack "(" A " < " B ")")) 89 | (de <= (A B) (pack "(" A " <= " B ")")) 90 | (de > (A B) (pack "(" A " > " B ")")) 91 | (de >= (A B) (pack "(" A " >= " B ")")) 92 | (de =/ (A B) (pack "(" A " != " B ")")) 93 | 94 | (de Liste @ (pack "[" (glue ", " (rest)) "]")) 95 | 96 | (de 1000Cosinus (angle) (pack "cos(radians(" angle "))")) 97 | (de 1000Sinus (angle) (pack "sin(radians(" angle "))")) 98 | 99 | (de Longueur (A) (pack A ".length")) 100 | (de Nieme (obj idx) (pack obj "[" idx "-1]")) 101 | (de Millisecondes () "millis()") 102 | 103 | (de RAZ () "background(255);^J") 104 | (de Cercle inputs 105 | (let (origine (car inputs) 106 | orig_x (eval (cadr origine)) 107 | orig_y (eval (caddr origine)) 108 | r (eval (cadr inputs))) 109 | (pack "ellipse(" orig_x ", " orig_y ", 2*" r ", 2*" r ");^J") 110 | ) 111 | ) 112 | (de Contour inputs 113 | (let (couleur (car inputs) 114 | R (eval (cadr couleur)) 115 | V (eval (caddr couleur)) 116 | B (eval (cadddr couleur))) 117 | (pack "stroke(" R ", " V ", " B ");^J"))) 118 | (de Remplissage inputs 119 | (let (couleur (car inputs) 120 | R (eval (cadr couleur)) 121 | V (eval (caddr couleur)) 122 | B (eval (cadddr couleur))) 123 | (pack "fill(" R ", " V ", " B ");^J"))) 124 | (de Ellipse inputs 125 | (let (origine (car inputs) 126 | orig_x (eval (cadr origine)) 127 | orig_y (eval (caddr origine)) 128 | r1 (eval (cadr inputs)) 129 | r2 (eval (caddr inputs))) 130 | (pack "ellipse(" orig_x ", " orig_y ", 2*" r1 ", 2*" r2 ");^J") 131 | ) 132 | ) 133 | (de Epaisseur inputs 134 | (let (e (eval (cadr (car inputs)))) 135 | (pack "strokeWeight(" e ");^J") 136 | ) 137 | ) 138 | (de Rectangle inputs 139 | (let (p1 (car inputs) 140 | p2 (cadr inputs) 141 | x1 (eval (cadr p1)) 142 | y1 (eval (caddr p1)) 143 | x2 (eval (cadr p2)) 144 | y2 (eval (caddr p2))) 145 | (pack "rect(" x1 ", " y1 ", " x2 ", " y2 ");^J") 146 | ) 147 | ) 148 | (de Segment inputs 149 | (let (p1 (car inputs) 150 | p2 (cadr inputs) 151 | x1 (eval (cadr p1)) 152 | y1 (eval (caddr p1)) 153 | x2 (eval (cadr p2)) 154 | y2 (eval (caddr p2))) 155 | (pack "line(" x1 ", " y1 ", " x2 ", " y2 ");^J") 156 | ) 157 | ) 158 | (de Triangle inputs 159 | (let (p1 (car inputs) 160 | p2 (cadr inputs) 161 | p3 (caddr inputs) 162 | x1 (eval (cadr p1)) 163 | y1 (eval (caddr p1)) 164 | x2 (eval (cadr p2)) 165 | y2 (eval (caddr p2)) 166 | x3 (eval (cadr p3)) 167 | y3 (eval (caddr p3))) 168 | (pack "triangle(" x1 ", " y1 ", " x2 ", " y2 ", " x3 ", " y3 ");^J") 169 | ) 170 | ) 171 | (de Repere () (!no_export "Repere")) 172 | 173 | (de Tete () (!no_export "Tete")) 174 | (de Queue () (!no_export "Queue")) 175 | (de Ajouter_a () (!no_export "Ajouter_a")) 176 | (de Retirer_de () (!no_export "Retirer_de")) 177 | # En_position 178 | (de Nieme@ () (!no_export "Nieme@")) 179 | (de Texte () (!no_export "Texte")) 180 | (de Nombre () (!no_export "Nombre")) 181 | # Alors Sinon 182 | (de Repeter () (!no_export "Repeter")) 183 | (de Répéter () (!no_export "Répéter")) 184 | (de ... () " (...) ") 185 | 186 | (de !no_export (cmd) 187 | (pack "-- La commande " cmd " ne peut être exportée. --^J")) 188 | 189 | (de Demander () (!no_export "Demander")) 190 | (de Demander_un_nombre () (!no_export "Demander_un_nombre")) 191 | (de Demander_un_nombre_pour () (!no_export "Demander_un_nombre_pour")) 192 | (de Initialiser@ () (!no_export "Initialiser@")) 193 | (de Type () (!no_export "Type")) 194 | (de Definir () (!no_export "Definir")) 195 | (de Définir () (!no_export "Définir")) 196 | (de Retourner () (!no_export "Retourner")) 197 | (de Exemples_de () (!no_export "Exemples_de")) 198 | (de Tester () (!no_export "Tester")) 199 | (de ? () (!no_export "?")) 200 | 201 | (de AV () (!no_export "AV")) 202 | (de BC () (!no_export "BC")) 203 | (de LC () (!no_export "LC")) 204 | (de TD () (!no_export "TD")) 205 | (de TG () (!no_export "TG")) 206 | -------------------------------------------------------------------------------- /microalg_export_python.l: -------------------------------------------------------------------------------- 1 | (de Litteral (content) 2 | (cond 3 | ((num? content) content) 4 | ((str? content) (pack "\"" content "\"")) 5 | (T "Littéral de type inconnu.") 6 | )) 7 | (de Variable inputs 8 | (let (nom_var (car inputs)) 9 | (if nom_var nom_var "") 10 | ) 11 | ) 12 | (de indent (!instr) 13 | (let (!lines_with_final_NIL (mapcar pack (split (chop !instr) "^J")) 14 | !lines (reverse (cdr (reverse !lines_with_final_NIL)))) 15 | (mapcar (list '(!line) 16 | (list 'pack " " '!line "^J")) !lines) 17 | ) 18 | ) 19 | 20 | (de + @ (pack "(" (glue " + " (rest)) ")")) 21 | (de - (A B) (pack "(" A "-" B ")")) 22 | (de * @ (pack "(" (glue " * " (rest)) ")")) 23 | (de / (A B) (pack "(" A "/" B ")")) 24 | (de % (A B) (pack "(" A "%" B ")")) 25 | (de ^ (A B) (pack "(" A "**" B ")")) 26 | (de Racine (A) (pack "math.sqrt(" A ")")) 27 | 28 | (de !!! (comz) (pack "# " (cdr (reverse (cdr (reverse (chop comz))))) "^J")) 29 | (de Afficher (obj) (pack "print(" obj ")^J")) 30 | (de Declarer !arg_lst 31 | (let (!splitted (split !arg_lst 'De_type) 32 | !vars (mapcar 'cadr (car !splitted)) # var name is in (Variable ...) 33 | !type (cadr (caadr !splitted))) # type is in (Litteral ...) 34 | (pack "# " (glue ", " !vars) " sont une ou plusieures variables" 35 | " de type " !type "^J") 36 | ) 37 | ) 38 | (setq Déclarer 'Declarer) 39 | (de Concatener @ (glue " + " (rest))) 40 | (setq Concaténer 'Concatener) 41 | (de Affecter_a !arg_lst 42 | (let (!var (cadr (car !arg_lst)) # var name is in (Variable ...) 43 | !val (eval (cadr !arg_lst))) 44 | (pack !var " = " !val "^J"))) 45 | (setq Affecter_à 'Affecter_a) 46 | (de Entier@ (A B) (pack "random.randint(" A ", " B ")")) 47 | (setq Vrai "True") 48 | (setq Faux "False") 49 | (setq Rien "None") 50 | (de Si arg_lst (let (condition (car arg_lst) 51 | kw_alors (cadr arg_lst) 52 | splitted (split (cddr arg_lst) 'Sinon) 53 | bloc_vrai (car splitted) 54 | bloc_faux (cadr splitted)) 55 | (pack 56 | "if " (eval condition) ":^J" 57 | (mapcar 'eval bloc_vrai) 58 | (if bloc_faux (pack "else:^J" (mapcar 'eval bloc_faux))) 59 | ) 60 | ) 61 | ) 62 | (de Non (bool) (pack "not (" bool ")")) 63 | (de Et !arg_lst (pack "(" (glue " and " (mapcar 'eval !arg_lst)) ")")) 64 | (de Ou !arg_lst (pack "(" (glue " or " (mapcar 'eval !arg_lst)) ")")) 65 | (de Tant_que arg_lst (let (!cond (car arg_lst) 66 | !mot-clef (cadr arg_lst) 67 | !corps (cddr arg_lst)) 68 | (pack 69 | "while " (eval !cond) ":^J" 70 | (mapcar 'eval !corps) 71 | ) 72 | ) 73 | ) 74 | (de Faire arg_lst (let (!splitted (split arg_lst 'Tant_que) 75 | !corps (car !splitted) 76 | !cond (caadr !splitted)) 77 | (pack 78 | "while True:^J" 79 | (mapcar 'eval !corps) 80 | " if not (" (eval !cond) "):^J" 81 | " break^J" 82 | ) 83 | ) 84 | ) 85 | (de Repeter arg_lst (let (nb (eval (car arg_lst)) 86 | prg (cddr arg_lst)) 87 | (pack "for _ in range(" nb "):^J" 88 | (mapcar 'eval prg) 89 | ) 90 | ) 91 | ) 92 | (setq Répéter 'Repeter) 93 | (de = (A B) (pack "(" A " == " B ")")) 94 | (de < (A B) (pack "(" A " < " B ")")) 95 | (de <= (A B) (pack "(" A " <= " B ")")) 96 | (de > (A B) (pack "(" A " > " B ")")) 97 | (de >= (A B) (pack "(" A " >= " B ")")) 98 | (de =/ (A B) (pack "(" A " != " B ")")) 99 | 100 | (de Liste @ (pack "[" (glue ", " (rest)) "]")) 101 | 102 | (de 1000Cosinus (angle) (pack "math.cos(" angle "/180*math.pi)")) 103 | (de 1000Sinus (angle) (pack "math.sin(" angle "/180*math.pi)")) 104 | 105 | (de Longueur (A) (pack "len(" A ")")) 106 | (de Nieme (obj idx) (pack obj "[" idx "-1]")) 107 | (de Millisecondes () "(time.time()*1000.0)") 108 | 109 | (de Demander () "input()") 110 | (de Demander_un_nombre () "float(input())") 111 | (de Demander_un_nombre_pour !arg_lst 112 | (let (!var (cadr (car !arg_lst))) # var name is in (Variable ...) 113 | (pack !var "=float(input())^J") 114 | ) 115 | ) 116 | (de Type (A) (pack "type(" A ")")) 117 | 118 | (de Tete (obj) (pack obj "[0]")) 119 | (de Queue (obj) (pack obj "[1:]")) 120 | (de Ajouter_a (obj val) (pack obj ".append(" val ")^J")) 121 | (de Retirer_de (obj val) (pack obj ".pop()^J")) 122 | # En_position 123 | (de Nieme@ (obj) (pack "random.choice(" obj ")")) 124 | (de Texte (obj) (pack "str(" obj ")")) 125 | (de Nombre (obj) (pack "float(" obj ")")) 126 | (de ... () " (...) ") 127 | 128 | (de !no_export (cmd) 129 | (pack "-- La commande " cmd " ne peut être exportée. --^J")) 130 | 131 | (de Initialiser@ () (!no_export "Initialiser@")) 132 | (de Definir () (!no_export "Definir")) 133 | (de Définir () (!no_export "Définir")) 134 | (de Retourner () (!no_export "Retourner")) 135 | (de Exemples_de () (!no_export "Exemples_de")) 136 | (de Tester () (!no_export "Tester")) 137 | (de ? () (!no_export "?")) 138 | # Alors Sinon 139 | 140 | (de AV () (!no_export "AV")) 141 | (de BC () (!no_export "BC")) 142 | (de LC () (!no_export "LC")) 143 | (de TD () (!no_export "TD")) 144 | (de TG () (!no_export "TG")) 145 | (de Cercle () (!no_export "Cercle")) 146 | (de Contour () (!no_export "Contour")) 147 | (de Ellipse () (!no_export "Ellipse")) 148 | (de Epaisseur () (!no_export "Epaisseur")) 149 | (de RAZ () (!no_export "RAZ")) 150 | (de Rectangle () (!no_export "Rectangle")) 151 | (de Remplissage () (!no_export "Remplissage")) 152 | (de Repere () (!no_export "Repere")) 153 | (de Segment () (!no_export "Segment")) 154 | (de Triangle () (!no_export "Triangle")) 155 | -------------------------------------------------------------------------------- /microalg_export_ti.l: -------------------------------------------------------------------------------- 1 | (de Litteral (content) 2 | (cond 3 | ((num? content) content) 4 | ((str? content) (pack "\"" content "\"")) 5 | (T "Littéral de type inconnu.") 6 | )) 7 | (de Variable inputs 8 | (let (nom_var (car inputs)) 9 | (if nom_var nom_var "") 10 | ) 11 | ) 12 | (de indent (!instr) 13 | (indent_std !instr) 14 | ) 15 | 16 | (de + @ (pack "(" (glue "+" (rest)) ")")) 17 | (de - (A B) (pack "(" A "-" B ")")) 18 | (de * @ (pack "(" (glue "×" (rest)) ")")) 19 | (de / (A B) (pack "(" A "÷" B ")")) 20 | (de % (A B) (pack "Mod(" A "," B ")")) 21 | (de ^ (A B) (pack "(" A "\^" B ")")) 22 | (de Carre (A) (pack "(" A ")²")) 23 | (setq Carré Carre) 24 | (de Racine (A) (pack "√(" A ")")) 25 | 26 | (setq Somme +) 27 | (setq Diff -) 28 | (setq Produit *) 29 | (setq Quotient /) 30 | (setq Reste %) 31 | (setq Puissance ^) 32 | 33 | (de !!! (comz) (pack "\" " (cdr (reverse (cdr (reverse (chop comz))))) "^J")) 34 | (de Afficher (obj) (pack "Disp " obj "^J")) 35 | (de !store (!arg_lst) 36 | (let (var (eval (car !arg_lst)) 37 | val (cadr !arg_lst)) 38 | (cond 39 | ((== 'Demander (car val)) (pack "Prompt Str" var "^J")) 40 | ((== 'Demander_un_nombre (car val)) (pack "Prompt " var "^J")) 41 | ((and (== 'Nombre (car val)) 42 | (== 'Demander (car (cadr val)))) (pack "Prompt " var "^J")) 43 | (T (pack (eval val) "→" var "^J")) 44 | ) 45 | )) 46 | (de Declarer !arg_lst 47 | (let (!splitted (split !arg_lst 'De_type) 48 | !vars (mapcar 'cadr (car !splitted)) # var name is in (Variable ...) 49 | !type (caadr !splitted)) 50 | (pack "\" " (glue " " !vars) " de type " (cadr !type) "^J") # type is in (Litteral ...) 51 | ) 52 | ) 53 | (setq Déclarer 'Declarer) 54 | (de Affecter_a !arg_lst (!store !arg_lst)) 55 | (setq Affecter_à 'Affecter_a) 56 | (de Demander () (pack "-- La commande `Demander` doit être utilisée avec " 57 | "`Affecter_a`. --")) 58 | (de Demander_un_nombre () (pack "-- La commande `Demander_un_nombre` doit être utilisée avec " 59 | "`Affecter_a`. --")) 60 | (de Demander_un_nombre_pour !arg_lst 61 | (let (!var (cadr (car !arg_lst))) # var name is in (Variable ...) 62 | (pack "Prompt " !var "^J") 63 | ) 64 | ) 65 | (de Entier@ (A B) (pack "randInt(" A "," B ")")) 66 | (setq Vrai "1") 67 | (setq Faux "0") 68 | (setq Vrai "Rien") 69 | (de Si arg_lst (let (condition (car arg_lst) 70 | kw_alors (cadr arg_lst) 71 | splitted (split (cddr arg_lst) 'Sinon) 72 | bloc_vrai (car splitted) 73 | bloc_faux (cadr splitted)) 74 | (pack 75 | "If " (eval condition) "^J" "Then^J" 76 | (mapcar 'eval bloc_vrai) 77 | (if bloc_faux (pack "Else^J" (mapcar 'eval bloc_faux))) 78 | "End^J" 79 | ) 80 | ) 81 | ) 82 | (de Non (bool) (pack "not(" bool ")")) 83 | (de Et !arg_lst (pack "(" (glue " and " (mapcar 'eval !arg_lst)) ")")) 84 | (de Ou !arg_lst (pack "(" (glue " or " (mapcar 'eval !arg_lst)) ")")) 85 | (de Tant_que arg_lst (let (!cond (car arg_lst) 86 | !mot-clef (cadr arg_lst) 87 | !corps (cddr arg_lst)) 88 | (pack 89 | "While " (eval !cond) "^J" 90 | (mapcar 'eval !corps) 91 | "End^J" 92 | ) 93 | ) 94 | ) 95 | 96 | (de = (A B) (pack "(" A "=" B ")")) 97 | (de < (A B) (pack "(" A "<" B ")")) 98 | (de <= (A B) (pack "(" A "≤" B ")")) 99 | (de > (A B) (pack "(" A ">" B ")")) 100 | (de >= (A B) (pack "(" A "≥" B ")")) 101 | (de =/ (A B) (pack "(" A "≠" B ")")) 102 | 103 | (de ... () " (...) ") 104 | 105 | (de 1000Cosinus (!angle) (pack "(1000×cos(" !angle "))")) 106 | (de 1000Sinus (!angle) (pack "(1000×sin(" !angle "))")) 107 | 108 | (de !no_export (cmd) 109 | (pack "-- La commande " cmd " ne peut être exportée. --^J")) 110 | 111 | (de Concatener () (!no_export "Concatener")) # StrJoin( 112 | (de Concaténer () (!no_export "Concaténer")) 113 | (de Liste () (!no_export "Liste")) 114 | (de Longueur () (!no_export "Longueur")) 115 | (de Nieme () (!no_export "Nieme")) 116 | (de Tete () (!no_export "Tete")) 117 | (de Queue () (!no_export "Queue")) 118 | (de Ajouter_a () (!no_export "Ajouter_a")) 119 | (de Retirer_de () (!no_export "Retirer_de")) 120 | # En_position 121 | (de Initialiser@ () (!no_export "Initialiser@")) 122 | (de Nieme@ () (!no_export "Nieme@")) 123 | (de Type () (!no_export "Type")) 124 | (de Texte () (!no_export "Texte")) 125 | (de Nombre () (!no_export "Nombre")) 126 | # Alors Sinon 127 | (de Faire () (!no_export "Faire")) 128 | (de Repeter () (!no_export "Repeter")) 129 | (de Répéter () (!no_export "Répéter")) 130 | (de Definir () (!no_export "Definir")) 131 | (de Définir () (!no_export "Définir")) 132 | (de Retourner () (!no_export "Retourner")) 133 | (de Exemples_de () (!no_export "Exemples_de")) 134 | (de Tester () (!no_export "Tester")) 135 | (de ? () (!no_export "?")) 136 | (de Millisecondes () (!no_export "Millisecondes")) 137 | 138 | (de AV () (!no_export "AV")) 139 | (de BC () (!no_export "BC")) 140 | (de LC () (!no_export "LC")) 141 | (de TD () (!no_export "TD")) 142 | (de TG () (!no_export "TG")) 143 | (de Cercle () (!no_export "Cercle")) 144 | (de Contour () (!no_export "Contour")) 145 | (de Ellipse () (!no_export "Ellipse")) 146 | (de Epaisseur () (!no_export "Epaisseur")) 147 | (de RAZ () (!no_export "RAZ")) 148 | (de Rectangle () (!no_export "Rectangle")) 149 | (de Remplissage () (!no_export "Remplissage")) 150 | (de Repere () (!no_export "Repere")) 151 | (de Segment () (!no_export "Segment")) 152 | (de Triangle () (!no_export "Triangle")) 153 | -------------------------------------------------------------------------------- /microalg_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sh microalg_tests_picolisp.sh 3 | EXIT_MALG=$? 4 | sh microalg_tests_ersatz.sh 5 | EXIT_MALG_J=$? 6 | sh microalg_tests_nodejs_emulisp.sh 7 | EXIT_MALG_NJS=$? 8 | sh microalg_tests_rhino_emulisp.sh 9 | EXIT_MALG_RJS=$? 10 | #sh microalg_tests_features.sh 11 | EXIT_FEATURES=0 12 | exit $(($EXIT_MALG | $EXIT_MALG_J | $EXIT_MALG_NJS | $EXIT_MALG_RJS | $EXIT_FEATURES)) 13 | -------------------------------------------------------------------------------- /microalg_tests_ersatz.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo "Testing with Ersatz..." 3 | malg-j.bat microalg_tests.malg 4 | -------------------------------------------------------------------------------- /microalg_tests_ersatz.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PATH=$PATH:`pwd`/ersatz 4 | echo "Testing with Ersatz..." 5 | ./malg-j microalg_tests.malg 6 | 7 | -------------------------------------------------------------------------------- /microalg_tests_features.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ -z `which lettuce` ] 3 | then 4 | pip install lettuce 5 | fi 6 | 7 | PATH=$PATH:`pwd`:`pwd`/picolisp:`pwd`/ersatz:`pwd`/emulisp 8 | lettuce --verbosity=2 9 | -------------------------------------------------------------------------------- /microalg_tests_nodejs_emulisp.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo "Testing with NodeJS + EmuLisp..." 3 | malg-njs.bat microalg_tests.malg 4 | -------------------------------------------------------------------------------- /microalg_tests_nodejs_emulisp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PATH=$PATH:`pwd`/emulisp 4 | echo "Testing with NodeJS + Emulisp..." 5 | ./malg-njs microalg_tests.malg 6 | 7 | -------------------------------------------------------------------------------- /microalg_tests_picolisp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -n "${TRAVIS+x}" ] 4 | then 5 | ./install_scripts/install_picolisp.sh 6 | fi 7 | PATH=$PATH:`pwd`/picolisp 8 | echo "Testing with PicoLisp..." 9 | ./malg microalg_tests.malg 10 | 11 | -------------------------------------------------------------------------------- /microalg_tests_rhino_emulisp.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo "Testing with NodeJS + EmuLisp..." 3 | malg-rjs.bat microalg_tests.malg 4 | -------------------------------------------------------------------------------- /microalg_tests_rhino_emulisp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PATH=$PATH:`pwd`/emulisp 4 | echo "Testing with Rhino + Emulisp..." 5 | ./malg-rjs microalg_tests.malg 6 | 7 | -------------------------------------------------------------------------------- /pde/microalg/microalg.pde: -------------------------------------------------------------------------------- 1 | // From http://www.openprocessing.org/sketch/26896 2 | 3 | import processing.net.Server; 4 | import processing.net.Client; 5 | 6 | Turtle turtle; 7 | 8 | Server s; 9 | Client c; 10 | String data; 11 | 12 | int w = 600; 13 | int h = 600; 14 | 15 | float x_min = 0; 16 | float x_max = 600; 17 | float y_min = 0; 18 | float y_max = 600; 19 | 20 | void setup() { 21 | size(w, h); 22 | try { 23 | s = new Server(this, 12345); 24 | } catch (Exception e) { 25 | // processing.js n'a pas de Server. 26 | } 27 | reset(); 28 | rectMode(CORNERS); 29 | } 30 | 31 | void reset() { 32 | background(#FFFFFF); 33 | strokeWeight(1); 34 | stroke(color(0, 0, 0)); 35 | fill(1, 0, 0, 0); // 0, 0, 0, 0 n’est pas transparent (bug de Processing) 36 | turtle = new Turtle(); 37 | } 38 | 39 | class Turtle { 40 | float x, y; 41 | float oldx, oldy; 42 | float angle; 43 | color tcolor; 44 | 45 | Turtle() { 46 | oldx = width/2; 47 | oldy = height/2; 48 | x = oldx; 49 | y = oldy; 50 | tcolor = #000000; 51 | angle = 0; 52 | stroke(tcolor); 53 | } 54 | 55 | void forward(float step) { 56 | x = oldx - step * cos(radians(angle+90)); 57 | y = oldy - step * sin(radians(angle+90)); 58 | line(oldx, oldy, x, y); 59 | oldx = x; 60 | oldy = y; 61 | } 62 | 63 | void left(float dangle) { 64 | angle -= dangle; 65 | } 66 | 67 | void right(float dangle) { 68 | angle += dangle; 69 | } 70 | 71 | void pencolor(color ncolor) { 72 | tcolor = ncolor; 73 | stroke(tcolor); 74 | } 75 | 76 | void penup() { 77 | noStroke(); 78 | } 79 | 80 | void pendown() { 81 | stroke(tcolor); 82 | } 83 | } 84 | 85 | float mapx(float x) { 86 | return map(x, x_min, x_max, 0, 600); 87 | } 88 | 89 | float mapy(float y) { 90 | return map(y, y_min, y_max, 600, 0); 91 | } 92 | 93 | float mapw(float x) { 94 | return map(x, 0, x_max - x_min, 0, 600); 95 | } 96 | 97 | float maph(float y) { 98 | return map(y, 0, y_max - y_min, 0, 600); 99 | } 100 | 101 | void interact(String data) { 102 | String[] params = data.split(" "); 103 | String cmd = ""; 104 | switch (params.length) { 105 | case 0: 106 | cmd = data; 107 | break; 108 | default: 109 | cmd = params[0]; 110 | break; 111 | } 112 | if (false) { 113 | // pas de switch sur les strings !!! 114 | } else if (cmd.equals("Repere")) { 115 | x_min = float(params[1]); 116 | x_max = float(params[2]); 117 | y_min = float(params[3]); 118 | y_max = float(params[4]); 119 | } else if (cmd.equals("Contour")) { 120 | int alpha = 255; 121 | if (params.length == 5) { 122 | alpha = int(params[4]); 123 | } 124 | Color c = color(int(params[1]), int(params[2]), int(params[3]), alpha); 125 | stroke(c); 126 | turtle.pencolor(c); 127 | } else if (cmd.equals("Remplissage")) { 128 | int alpha = 255; 129 | if (params.length == 5) { 130 | alpha = int(params[4]); 131 | } 132 | // 0, 0, 0, 0 n’est pas transparent (bug de Processing) 133 | if (alpha == 0) params[1] = "1"; 134 | fill(int(params[1]), int(params[2]), int(params[3]), alpha); 135 | } else if (cmd.equals("Epaisseur")) { 136 | strokeWeight(int(params[1])); 137 | } else if (cmd.equals("Segment")) { 138 | line(mapx(float(params[1])), mapy(float(params[2])), 139 | mapx(float(params[3])), mapy(float(params[4]))); 140 | } else if (cmd.equals("Cercle")) { 141 | ellipse(mapx(float(params[1])), mapy(float(params[2])), 142 | mapw(float(params[3])), maph(float(params[3]))); 143 | } else if (cmd.equals("Ellipse")) { 144 | ellipse(mapx(float(params[1])), mapy(float(params[2])), 145 | mapw(float(params[3])), maph(float(params[4]))); 146 | } else if (cmd.equals("Rectangle")) { 147 | rect(mapx(float(params[1])), mapy(float(params[2])), 148 | mapx(float(params[3])), mapy(float(params[4]))); 149 | } else if (cmd.equals("Triangle")) { 150 | triangle(mapx(float(params[1])), mapy(float(params[2])), 151 | mapx(float(params[3])), mapy(float(params[4])), 152 | mapx(float(params[5])), mapy(float(params[6]))); 153 | } else if (cmd.equals("AV")) { 154 | turtle.forward(float(params[1])); 155 | } else if (cmd.equals("TD")) { 156 | turtle.right(float(params[1])); 157 | } else if (cmd.equals("TG")) { 158 | turtle.left(float(params[1])); 159 | } else if (cmd.equals("BC")) { 160 | turtle.pendown(); 161 | } else if (cmd.equals("LC")) { 162 | turtle.penup(); 163 | } else if (cmd.equals("RAZ")) { 164 | reset(); 165 | } else { 166 | println("Commande non reconnue : " + data); 167 | } 168 | } 169 | 170 | void draw() { 171 | if (s == null) { 172 | // Sans doute la version processing.js. 173 | } else { 174 | c = s.available(); 175 | if (c != null) { 176 | data = trim(c.readString()); 177 | interact(data); 178 | } 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /start_processing.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SET MICROALG_DIR=%~dp0 3 | %MICROALG_DIR%\processing\processing-java.exe --run --force --sketch=%MICROALG_DIR%\pde\microalg --output=%MICROALG_DIR%\pde\microalg.out 4 | exit -------------------------------------------------------------------------------- /start_processing.sh: -------------------------------------------------------------------------------- 1 | processing-java --run --force --sketch=pde/microalg --output=pde/microalg.out 2 | -------------------------------------------------------------------------------- /visuels/archi.malg: -------------------------------------------------------------------------------- 1 | (load "lib/xml.l") 2 | # TODO: inclure blockly, processing, processingJS, webGL, openGL, swing, NP++ 3 | # TODO: checker la nécessité des fill de MACHINE (a pas dans microalg.l) 4 | (setq W "#FFF") # blanc 5 | (setq R "#F00") # rouge 6 | (setq V "#0F0") # vert 7 | (setq B "#00F") # bleu 8 | (setq N "#000") # noir 9 | (setq L 800 H 450) 10 | (setq H_rects 45) 11 | (setq L_rects 110) 12 | (setq malg_x_pos 75) 13 | (setq malg_cadre_x_pos 20) 14 | (setq malg-j_x_pos 205) 15 | (setq malg-j_cadre_x_pos 150) 16 | (setq malg-rjs_x_pos 335) 17 | (setq malg-rjs_cadre_x_pos 280) 18 | (setq malg-njs_x_pos 465) 19 | (setq malg-njs_cadre_x_pos 410) 20 | (setq malg-js_browser_x_pos 605) 21 | (setq malg-js_cadre_browser_x_pos 540) 22 | (setq p5_depart_x_pos 350) 23 | (setq p5_arrivee_x_pos 745) 24 | (setq p5js_depart_x_pos 650) 25 | (setq p5js_arrivee_x_pos 715) 26 | (setq largeur_machine 650) 27 | (setq couche_machine (- H 20)) 28 | (setq couche_1 325) 29 | (setq couche_2 280) 30 | (setq couche_3 235) 31 | (setq couche_malg_l 180) 32 | (setq couche_malg 120) 33 | (setq couche_resultat 25) 34 | (setq text_conf_small '(text xml:space "preserve" text-anchor "middle" font-family "serif" font-size 18 fill N stroke-width 1)) 35 | (setq text_conf_big '(text xml:space "preserve" text-anchor "middle" font-family "serif" font-size 24 fill N stroke-width 1)) 36 | ( svg width L height H xmlns "http://www.w3.org/2000/svg" xmlns:svg "http://www.w3.org/2000/svg" stroke-width 5 stroke N fill W 37 | # cadre 38 | ( rect height H width L x 0 y 0) 39 | # IHM 40 | (apply (list (append text_conf_small '(x (/ (+ malg_x_pos malg-njs_x_pos) 2) y couche_resultat (prin "résultat dans la console"))))) 41 | ( line x1 (/ (+ malg_x_pos malg-njs_x_pos) 2) y1 35 x2 (/ (+ malg_x_pos malg-njs_x_pos) 2) y2 50 stroke-width 5 stroke N) 42 | (apply (list (append text_conf_small '(x (/ (+ malg_x_pos malg-njs_x_pos) 2) y 70 (prin "`malg* fichier.malg` (ou depuis éditeur)"))))) 43 | (apply (list (append text_conf_small '(x malg-js_browser_x_pos y couche_resultat (prin "HTML"))))) 44 | ( line x1 malg-js_browser_x_pos y1 35 x2 malg-js_browser_x_pos y2 50 stroke-width 5 stroke N) 45 | (apply (list (append text_conf_small '(x malg-js_browser_x_pos y 70 (prin "formulaire"))))) 46 | # microalg.l 47 | ( rect height H_rects width largeur_machine x malg_cadre_x_pos y (- couche_malg_l 30)) 48 | (apply (list (append text_conf_big '(x (/ (+ malg_x_pos malg-js_browser_x_pos) 2) y couche_malg_l (prin "microalg.l"))))) 49 | # malg 50 | ( rect height H_rects width L_rects x malg_cadre_x_pos y (- couche_malg 30)) 51 | (apply (list (append text_conf_big '(x malg_x_pos y couche_malg (prin "malg"))))) 52 | ( line x1 malg_x_pos y1 (- couche_malg_l H_rects) x2 malg_x_pos y2 (- couche_malg_l 30) stroke-width 5 stroke N) 53 | ( line x1 malg_x_pos y1 (+ couche_malg_l (/ H_rects 3)) x2 malg_x_pos y2 (+ couche_malg_l 30) stroke-width 5 stroke N) 54 | (apply (list (append text_conf_big '(x malg_x_pos y couche_3 (prin "pil"))))) 55 | (apply (list (append text_conf_big '(x malg_x_pos y couche_2 (prin "PicoLisp"))))) 56 | ( line x1 malg_x_pos y1 290 x2 malg_x_pos y2 (- couche_machine 30) stroke-width 5 stroke N) 57 | # malg-j 58 | ( rect height H_rects width L_rects x malg-j_cadre_x_pos y (- couche_malg 30) stroke-width 5 stroke N fill W) 59 | (apply (list (append text_conf_big '(x malg-j_x_pos y couche_malg (prin "malg-j"))))) 60 | ( line x1 malg-j_x_pos y1 (- couche_malg_l H_rects) x2 malg-j_x_pos y2 (- couche_malg_l 30) stroke-width 5 stroke N) 61 | ( line x1 malg-j_x_pos y1 (+ couche_malg_l (/ H_rects 3)) x2 malg-j_x_pos y2 (+ couche_malg_l 30) stroke-width 5 stroke N) 62 | (apply (list (append text_conf_big '(x malg-j_x_pos y couche_3 (prin "pil-j"))))) 63 | (apply (list (append text_conf_big '(x malg-j_x_pos y couche_2 (prin "Ersatz"))))) 64 | ( line x1 malg-j_x_pos y1 290 x2 malg-j_x_pos y2 350 stroke-width 5 stroke N) 65 | # malg-rjs 66 | ( rect height H_rects width L_rects x malg-rjs_cadre_x_pos y (- couche_malg 30) stroke-width 5 stroke N fill W) 67 | (apply (list (append text_conf_big '(x malg-rjs_x_pos y couche_malg (prin "malg-rjs"))))) 68 | ( line x1 malg-rjs_x_pos y1 (- couche_malg_l H_rects) x2 malg-rjs_x_pos y2 (- couche_malg_l 30) stroke-width 5 stroke N) 69 | ( line x1 malg-rjs_x_pos y1 (+ couche_malg_l (/ H_rects 3)) x2 malg-rjs_x_pos y2 (+ couche_malg_l 30) stroke-width 5 stroke N) 70 | (apply (list (append text_conf_big '(x malg-rjs_x_pos y couche_3 (prin "pil-rjs"))))) 71 | (apply (list (append text_conf_big '(x malg-rjs_x_pos y couche_2 (prin "EmuLisp"))))) 72 | (apply (list (append text_conf_big '(x malg-rjs_x_pos y couche_1 (prin "Rhino"))))) 73 | ( line x1 malg-rjs_x_pos y1 335 x2 malg-rjs_x_pos y2 350 stroke-width 5 stroke N) 74 | # malg-njs 75 | ( rect height H_rects width L_rects x malg-njs_cadre_x_pos y (- couche_malg 30) stroke-width 5 stroke N fill W) 76 | (apply (list (append text_conf_big '(x malg-njs_x_pos y couche_malg (prin "malg-njs"))))) 77 | ( line x1 malg-njs_x_pos y1 (- couche_malg_l H_rects) x2 malg-njs_x_pos y2 (- couche_malg_l 30) stroke-width 5 stroke N) 78 | ( line x1 malg-njs_x_pos y1 (+ couche_malg_l (/ H_rects 3)) x2 malg-njs_x_pos y2 (+ couche_malg_l 30) stroke-width 5 stroke N) 79 | (apply (list (append text_conf_big '(x malg-njs_x_pos y couche_3 (prin "pil-njs"))))) 80 | (apply (list (append text_conf_big '(x malg-njs_x_pos y couche_2 (prin "EmuLisp"))))) 81 | (apply (list (append text_conf_big '(x malg-njs_x_pos y couche_1 (prin "NodeJS"))))) 82 | ( line x1 malg-njs_x_pos y1 335 x2 malg-njs_x_pos y2 (- couche_machine 30) stroke-width 5 stroke N) 83 | # web IDE 84 | ( rect height H_rects width 130 x malg-js_cadre_browser_x_pos y (- couche_malg 30) stroke-width 5 stroke N fill W) 85 | (apply (list (append text_conf_big '(x malg-js_browser_x_pos y couche_malg (prin "web IDE"))))) 86 | ( line x1 malg-js_browser_x_pos y1 (- couche_malg_l H_rects) x2 malg-js_browser_x_pos y2 (- couche_malg_l 30) stroke-width 5 stroke N) 87 | ( line x1 malg-js_browser_x_pos y1 (+ couche_malg_l (/ H_rects 3)) x2 malg-js_browser_x_pos y2 250 stroke-width 5 stroke N) 88 | (apply (list (append text_conf_big '(x malg-js_browser_x_pos y couche_2 (prin "EmuLisp"))))) 89 | (apply (list (append text_conf_big '(x malg-js_browser_x_pos y couche_1 (prin "browser"))))) 90 | ( line x1 malg-js_browser_x_pos y1 335 x2 malg-js_browser_x_pos y2 (- couche_machine 30) stroke-width 5 stroke N) 91 | # JVM 92 | ( rect fill W stroke N stroke-width 5 x (- malg-j_x_pos 30) y (- couche_machine 80) width (+ (- malg-rjs_x_pos malg-j_x_pos) 60) height 40) 93 | (apply (list (append text_conf_big '(x (/ (+ malg-j_x_pos malg-rjs_x_pos) 2) y (- couche_machine 52) (prin "JVM"))))) 94 | # Machine 95 | ( rect fill W stroke N stroke-width 5 x malg_cadre_x_pos y (- couche_machine 30) width largeur_machine height 40) 96 | (apply (list (append text_conf_big '(x 300 y couche_machine (prin "MACHINE"))))) 97 | # Processing (java) 98 | ( line stroke N stroke-width 2 x1 p5_depart_x_pos y1 350 x2 p5_depart_x_pos y2 345) 99 | ( line stroke N stroke-width 2 x1 p5_depart_x_pos y1 345 x2 p5_arrivee_x_pos y2 345) 100 | ( line stroke N stroke-width 2 x1 p5_arrivee_x_pos y1 345 x2 p5_arrivee_x_pos y2 275) 101 | ( line stroke N stroke-width 2 x1 p5_arrivee_x_pos y1 210 x2 p5_arrivee_x_pos y2 195) 102 | ( line stroke N stroke-width 2 x1 p5_arrivee_x_pos y1 150 x2 p5_arrivee_x_pos y2 30) 103 | # Processing (js) 104 | ( line stroke N stroke-width 2 x1 p5js_depart_x_pos y1 310 x2 p5js_depart_x_pos y2 305) 105 | ( line stroke N stroke-width 2 x1 p5js_depart_x_pos y1 305 x2 p5js_arrivee_x_pos y2 305) 106 | ( line stroke N stroke-width 2 x1 p5js_arrivee_x_pos y1 305 x2 p5js_arrivee_x_pos y2 275) 107 | ( line stroke N stroke-width 2 x1 p5js_arrivee_x_pos y1 210 x2 p5js_arrivee_x_pos y2 195) 108 | ( line stroke N stroke-width 2 x1 p5js_arrivee_x_pos y1 150 x2 p5js_arrivee_x_pos y2 70) 109 | ( line stroke N stroke-width 2 x1 p5js_arrivee_x_pos y1 70 x2 (- p5js_arrivee_x_pos 40) y2 20) 110 | ( line stroke N stroke-width 2 x1 (- p5js_arrivee_x_pos 40) y1 20 x2 (- p5js_arrivee_x_pos 70) y2 20) 111 | # texte "Processing(.js)" et "FEP" 112 | (apply (list (append text_conf_big '(x 725 y couche_3 (prin "Processing"))))) 113 | (apply (list (append text_conf_big '(x 730 y (- couche_2 20) (prin "(.js)"))))) 114 | (apply (list (append text_conf_big '(x 745 y couche_resultat (prin "FEP"))))) 115 | # microalg.pde 116 | ( rect fill W stroke N stroke-width 5 x 680 y (- couche_malg_l 30) width 100 height H_rects) 117 | (apply (list (append text_conf_big '(x 730 y couche_malg_l (prin ".pde"))))) 118 | ) 119 | (bye) 120 | -------------------------------------------------------------------------------- /visuels/archi.svg: -------------------------------------------------------------------------------- 1 | résultat dans la console`malg* fichier.malg` (ou depuis éditeur)HTMLformulairemicroalg.lmalgpilPicoLispmalg-jpil-jErsatzmalg-rjspil-rjsEmuLispRhinomalg-njspil-njsEmuLispNodeJSweb IDEEmuLispbrowserJVMMACHINEProcessing(.js)FEP.pde -------------------------------------------------------------------------------- /visuels/logo_microalg.malg: -------------------------------------------------------------------------------- 1 | (load "lib/xml.l") 2 | (setq W "#FFF") # blanc 3 | (setq R "#e11d21") # rouge 4 | (setq J "#fbca04") # jaune 5 | (setq V "#009800") # vert 6 | (setq B "#0052cc") # bleu 7 | (setq N "#000") # noir 8 | (setq L/2 200) 9 | (setq L 400) 10 | (setq fond_blanc '( rect x 0 y 0 width L height L fill W)) 11 | ( svg width L height L xmlns "http://www.w3.org/2000/svg" xmlns:svg "http://www.w3.org/2000/svg" 12 | ( defs 13 | ( mask id "masque-r" maskUnits "userSpaceOnUse" x 0 y 0 width L height L 14 | (eval fond_blanc) 15 | ( ellipse cx L/2 cy L/2 rx 190 ry 125 fill N) 16 | ( ellipse cx L cy L/2 rx 150 ry 95 fill N) 17 | ( ellipse cx 0 cy L/2 rx 150 ry 95 fill N) 18 | ) 19 | ( mask id "masque-j" maskUnits "userSpaceOnUse" x 0 y 0 width L height L 20 | (eval fond_blanc) 21 | ( ellipse cx L/2 cy L/2 rx 160 ry 95 fill N) 22 | ( ellipse cx L cy L/2 rx 150 ry 75 fill N) 23 | ( ellipse cx 0 cy L/2 rx 150 ry 75 fill N) 24 | ) 25 | ( mask id "masque-v" maskUnits "userSpaceOnUse" x 0 y 0 width L height L 26 | (eval fond_blanc) 27 | ( ellipse cx L/2 cy L/2 rx 130 ry 65 fill N) 28 | ( ellipse cx L cy L/2 rx 150 ry 55 fill N) 29 | ( ellipse cx 0 cy L/2 rx 150 ry 55 fill N) 30 | ) 31 | ( mask id "masque-b" maskUnits "userSpaceOnUse" x 0 y 0 width L height L 32 | (eval fond_blanc) 33 | ( ellipse cx L/2 cy L/2 rx 95 ry 35 fill N) 34 | ( ellipse cx L cy L/2 rx 150 ry 35 fill N) 35 | ( ellipse cx 0 cy L/2 rx 150 ry 35 fill N) 36 | ) 37 | ) 38 | ( g id "logo-microalg" stroke-opacity 0 transform (pack "rotate(-45 " L/2 " " L/2 ")") 39 | ( ellipse id "rouge" fill R cx L/2 cy L/2 rx 190 ry 150 mask "url(#masque-r)") 40 | ( ellipse id "jaune" fill J cx L/2 cy L/2 rx 160 ry 120 mask "url(#masque-j)") 41 | ( ellipse id "vert" fill V cx L/2 cy L/2 rx 130 ry 90 mask "url(#masque-v)") 42 | ( ellipse id "bleu" fill B cx L/2 cy L/2 rx 100 ry 60 mask "url(#masque-b)") 43 | ) 44 | ) 45 | (bye) 46 | -------------------------------------------------------------------------------- /web/blockly/media/1x1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/web/blockly/media/1x1.gif -------------------------------------------------------------------------------- /web/blockly/media/click.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/web/blockly/media/click.mp3 -------------------------------------------------------------------------------- /web/blockly/media/click.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/web/blockly/media/click.ogg -------------------------------------------------------------------------------- /web/blockly/media/click.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/web/blockly/media/click.wav -------------------------------------------------------------------------------- /web/blockly/media/delete.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/web/blockly/media/delete.mp3 -------------------------------------------------------------------------------- /web/blockly/media/delete.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/web/blockly/media/delete.ogg -------------------------------------------------------------------------------- /web/blockly/media/delete.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/web/blockly/media/delete.wav -------------------------------------------------------------------------------- /web/blockly/media/handclosed.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/web/blockly/media/handclosed.cur -------------------------------------------------------------------------------- /web/blockly/media/handopen.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/web/blockly/media/handopen.cur -------------------------------------------------------------------------------- /web/blockly/media/quote0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/web/blockly/media/quote0.png -------------------------------------------------------------------------------- /web/blockly/media/quote1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/web/blockly/media/quote1.png -------------------------------------------------------------------------------- /web/blockly/media/sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/web/blockly/media/sprites.png -------------------------------------------------------------------------------- /web/css-ninja-tree/css-ninja-tree.css: -------------------------------------------------------------------------------- 1 | /* http://www.thecssninja.com/demo/css_tree/ */ 2 | 3 | ol.tree 4 | { 5 | padding: 0 0 0 30px; 6 | width: 300px; 7 | } 8 | ol.tree li 9 | { 10 | position: relative; 11 | margin-left: -15px; 12 | list-style: none; 13 | } 14 | ol.tree li input 15 | { 16 | position: absolute; 17 | left: 0; 18 | margin-left: 0; 19 | opacity: 0; 20 | z-index: 2; 21 | cursor: pointer; 22 | height: 1em; 23 | width: 1em; 24 | top: 0; 25 | } 26 | ol.tree li input + ol 27 | { 28 | background: url(toggle-small-expand.png) 50px -3px no-repeat; 29 | margin: -0.938em 0 0 -44px; /* 15px */ 30 | height: 1em; 31 | } 32 | ol.tree li input + ol > li { display: none; margin-left: -14px !important; padding-left: 1px; } 33 | ol.tree li label:before 34 | { 35 | content: "("; 36 | } 37 | ol.tree li label 38 | { 39 | cursor: pointer; 40 | display: block; 41 | padding-left: 24px; 42 | margin-bottom: 0; 43 | font-weight: normal; 44 | font-size: 100%; 45 | } 46 | 47 | ol.tree li input:checked + ol 48 | { 49 | background: url(toggle-small.png) 50px 0px no-repeat; 50 | margin: -1.25em 0 0 -44px; /* 20px */ 51 | padding: 1.563em 0 0 80px; 52 | height: auto; 53 | } 54 | ol.tree li input:checked + ol > li { display: block; margin: 0 0 0.125em; /* 2px */} 55 | ol.tree li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ } 56 | 57 | /* Because of Skeleton */ 58 | .tree ul ul, ul ol, ol ol, ol ul { 59 | font-size: 100%; 60 | } 61 | -------------------------------------------------------------------------------- /web/css-ninja-tree/document.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/web/css-ninja-tree/document.png -------------------------------------------------------------------------------- /web/css-ninja-tree/folder-horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/web/css-ninja-tree/folder-horizontal.png -------------------------------------------------------------------------------- /web/css-ninja-tree/toggle-small-expand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/web/css-ninja-tree/toggle-small-expand.png -------------------------------------------------------------------------------- /web/css-ninja-tree/toggle-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Microalg/microalg/0b6bc8516d6d24bbe7c45e62cdc9b6cd101d308a/web/css-ninja-tree/toggle-small.png -------------------------------------------------------------------------------- /web/jquery.terminal.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This css file is part of jquery terminal 3 | * 4 | * Licensed under GNU LGPL Version 3 license 5 | * Copyright (c) 2011-2013 Jakub Jankiewicz 6 | * 7 | */ 8 | .terminal .terminal-output .format, .cmd .format, 9 | .cmd .prompt, .cmd .prompt div, .terminal .terminal-output div div{ 10 | display: inline-block; 11 | } 12 | .cmd .clipboard { 13 | position: absolute; 14 | bottom: 0; 15 | left: 0; 16 | opacity: 0.01; 17 | filter: alpha(opacity = 0.01); 18 | filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0.01); 19 | width: 2px; 20 | } 21 | .cmd > .clipboard { 22 | position: fixed; 23 | } 24 | .terminal { 25 | padding: 10px; 26 | position: relative; 27 | overflow: hidden; 28 | } 29 | .cmd { 30 | padding: 0; 31 | margin: 0; 32 | height: 1.3em; 33 | /*margin-top: 3px; */ 34 | } 35 | .cmd .cursor.blink { 36 | -webkit-animation: blink 1s infinite steps(1, start); 37 | -moz-animation: blink 1s infinite steps(1, start); 38 | -ms-animation: blink 1s infinite steps(1, start); 39 | animation: blink 1s infinite steps(1, start); 40 | } 41 | @keyframes blink { 42 | 0%, 100% { 43 | background-color: #000; 44 | color: #aaa; 45 | } 46 | 50% { 47 | background-color: #bbb; /* not #aaa because it's seem there is Google Chrome bug */ 48 | color: #000; 49 | } 50 | } 51 | @-webkit-keyframes blink { 52 | 0%, 100% { 53 | background-color: #000; 54 | color: #aaa; 55 | } 56 | 50% { 57 | background-color: #bbb; 58 | color: #000; 59 | } 60 | } 61 | @-ms-keyframes blink { 62 | 0%, 100% { 63 | background-color: #000; 64 | color: #aaa; 65 | } 66 | 50% { 67 | background-color: #bbb; 68 | color: #000; 69 | } 70 | } 71 | @-moz-keyframes blink { 72 | 0%, 100% { 73 | background-color: #000; 74 | color: #aaa; 75 | } 76 | 50% { 77 | background-color: #bbb; 78 | color: #000; 79 | } 80 | } 81 | .terminal .terminal-output div div, .cmd .prompt { 82 | display: block; 83 | line-height: 14px; 84 | height: auto; 85 | } 86 | .cmd .prompt { 87 | float: left; 88 | } 89 | .terminal, .cmd { 90 | font-family: FreeMono, monospace; 91 | color: #aaa; 92 | background-color: #000; 93 | font-size: 12px; 94 | line-height: 14px; 95 | } 96 | .terminal-output > div { 97 | /*padding-top: 3px;*/ 98 | min-height: 14px; 99 | } 100 | .terminal .terminal-output div span { 101 | display: inline-block; 102 | } 103 | .cmd span { 104 | float: left; 105 | /*display: inline-block; */ 106 | } 107 | .terminal .inverted, .cmd .inverted, .cmd .cursor.blink { 108 | background-color: #aaa; 109 | color: #000; 110 | } 111 | .terminal .terminal-output div div::-moz-selection, 112 | .terminal .terminal-output div span::-moz-selection, 113 | .terminal .terminal-output div div a::-moz-selection { 114 | background-color: #aaa; 115 | color: #000; 116 | } 117 | .terminal .terminal-output div div::selection, 118 | .terminal .terminal-output div div a::selection, 119 | .terminal .terminal-output div span::selection, 120 | .cmd > span::selection, 121 | .cmd .prompt span::selection { 122 | background-color: #aaa; 123 | color: #000; 124 | } 125 | .terminal .terminal-output div.error, .terminal .terminal-output div.error div { 126 | color: red; 127 | } 128 | .tilda { 129 | position: fixed; 130 | top: 0; 131 | left: 0; 132 | width: 100%; 133 | z-index: 1100; 134 | } 135 | .clear { 136 | clear: both; 137 | } 138 | .terminal a { 139 | color: #0F60FF; 140 | } 141 | .terminal a:hover { 142 | color: red; 143 | } 144 | -------------------------------------------------------------------------------- /web/jquery.textcomplete.css: -------------------------------------------------------------------------------- 1 | /* Based on https://github.com/yuku-t/jquery-textcomplete/blob/master/doc/style.md */ 2 | .textcomplete-dropdown { 3 | border: 1px solid #ddd; 4 | background-color: white; 5 | padding: 0; 6 | margin: 0; 7 | } 8 | 9 | .textcomplete-dropdown li { 10 | list-style: none; 11 | border-top: 1px solid #ddd; 12 | padding: 2px 5px; 13 | margin: 0; 14 | } 15 | 16 | .textcomplete-dropdown li:first-child { 17 | border-top: none; 18 | } 19 | 20 | .textcomplete-dropdown li:hover, 21 | .textcomplete-dropdown .active { 22 | background-color: rgb(160, 223, 160); 23 | } 24 | 25 | .textcomplete-dropdown a { 26 | border-bottom: none; 27 | } 28 | 29 | .textcomplete-dropdown a:hover { 30 | cursor: pointer; 31 | } -------------------------------------------------------------------------------- /web/parenedit.css: -------------------------------------------------------------------------------- 1 | /* http://stackoverflow.com/questions/14043727/auto-resizing-textarea-is-bumpy-highlighting-parentheses */ 2 | /* http://jsfiddle.net/ACF8e/ */ 3 | 4 | .defaultEm { 5 | font-size: 1em; 6 | position: absolute; 7 | line-height: 1; 8 | padding: 0; 9 | visibility: hidden; 10 | } 11 | .richtext { 12 | display: inline-block; 13 | overflow: hidden; 14 | color: #282828; 15 | background: #fff; 16 | margin: 2px 0; 17 | padding: 0px; 18 | vertical-align: top; 19 | outline: 0; 20 | border: 1px solid #BABABA; 21 | } 22 | .richtext pre { 23 | display: inline-block; 24 | z-index: 1; 25 | position: absolute; 26 | overflow: hidden; 27 | min-height: 25; 28 | background: #fff; 29 | outline: 0; 30 | white-space: pre-wrap; 31 | word-wrap: break-word; 32 | color: transparent; 33 | } 34 | .richtext > textarea, .richtext > pre { 35 | font-family: 'Courier New', Courier, monospace; 36 | font-size: 100%; 37 | line-height: 1.5; 38 | tab-size: 4; 39 | -moz-tab-size: 4; 40 | -o-tab-size: 4; 41 | -webkit-tab-size: 4; 42 | } 43 | #test:focus, input:focus, .fake_focus { 44 | border: 1px solid #85B6DA; 45 | outline: 0; 46 | } 47 | #test:active, input:active, .richtext:active { 48 | border: 1px solid #3385C2; 49 | } 50 | 51 | /* http://jsfiddle.net/ojetot9k/ */ 52 | .unmatched { 53 | animation: blink 1s steps(1) infinite; 54 | -webkit-animation: blink 1s steps(1) infinite; 55 | } 56 | @keyframes blink { 50% { background: red; } } 57 | @-webkit-keyframes blink { 50% { background: red; } } 58 | 59 | /* paren_0 is after paren_6 */ 60 | .paren_1 { 61 | background: #fab; 62 | } 63 | .paren_2 { 64 | background: #fdb; 65 | } 66 | .paren_3 { 67 | background: #ffd; 68 | } 69 | .paren_4 { 70 | background: #dfb; 71 | } 72 | .paren_5 { 73 | background: #cef; 74 | } 75 | .paren_6 { 76 | background: #dcf; 77 | } 78 | .paren_0 { 79 | background: #bbe; 80 | } 81 | .selected_paren { 82 | background: #999 !important; 83 | } 84 | .text { 85 | border-bottom: 1px solid #aaa; 86 | } 87 | .richtext textarea, .richtext pre { 88 | resize: none !important; 89 | outline: 0 !important; 90 | margin: 0 !important; 91 | padding: 0 !important; 92 | border: 0 !important; 93 | white-space: pre-wrap !important; 94 | word-wrap: break-word !important; 95 | overflow: hidden !important; 96 | } 97 | .richtext textarea { 98 | height: 100%; 99 | } 100 | -------------------------------------------------------------------------------- /web/parenedit.js: -------------------------------------------------------------------------------- 1 | // http://stackoverflow.com/questions/14043727/auto-resizing-textarea-is-bumpy-highlighting-parentheses 2 | // http://jsfiddle.net/ACF8e/ 3 | 4 | function getDefaultFontSize(pa){ 5 | pa = pa || document.body; 6 | var who= document.createElement('span'); 7 | who.className= 'defaultEm'; 8 | who.appendChild(document.createTextNode('M')); 9 | pa.appendChild(who); 10 | var fs= [who.offsetWidth, who.offsetHeight]; 11 | pa.removeChild(who); 12 | return fs; 13 | } 14 | // Elt in parameter needs an id. 15 | function createRichInput(original) { 16 | if (typeof original == "string") original = $(original); 17 | var original_id = original.attr('id'); 18 | if (typeof original_id == "undefined") { 19 | console.log("parenedit: elt with no id!"); 20 | console.log(original); 21 | } 22 | var newId = "richtext-" + original_id; 23 | var newElement = "
    "; 24 | 25 | newId = '#' + newId; 26 | 27 | var width = original.width(); 28 | var height = original.height(); 29 | 30 | original.wrap(newElement); 31 | original.before("
    ");
     32 | 
     33 |     $(newId).width(width).css("min-height", height);
     34 |     $(newId + '> pre').width(width).css("min-height", height);
     35 | 
     36 |     original.css({
     37 |         'background': 'transparent',
     38 |         'position': 'absolute',
     39 |         'z-index': 98,
     40 |         'width': width
     41 |     });
     42 | 
     43 |     fresh = true;
     44 |     original.on('propertychange keydown keyup input paste click', function(e) {
     45 |         var code = (e.keyCode ? e.keyCode : e.which);
     46 |         var text = original.val();
     47 |         if (code == 13) text += '
    '; 48 | $(newId + " pre").html(colorize(text, original.getCursorPosition())); 49 | 50 | var newHeight = $(newId + " pre").height() + getDefaultFontSize()[1]; //adding a height of line 51 | $(this).height(newHeight); 52 | $(newId).height(newHeight); 53 | }); 54 | original.trigger(jQuery.Event("keydown")); 55 | fresh = false; 56 | } 57 | 58 | function colorize(text, pos) { 59 | var i = 0, current_times = 0; 60 | var startc = '(', endc = ')'; 61 | var current = -1; 62 | 63 | var entities = {'>': '>','<':'<'}; 64 | var p2 = 0; 65 | var regex = new RegExp(Object.keys(entities).join("|"),'g'); 66 | var converted = text.replace(regex, function(x, j) { 67 | if(pos > j) p2 += entities[x].length - 1; 68 | return entities[x]; 69 | }); 70 | 71 | pos += p2; 72 | var parens = [], indices = [], o = {}; 73 | var newText = converted.replace(/((?:\\)*)([()])/g, function(full, escape, x, idx) { 74 | var len = escape.split(/\\/g).length - 1; 75 | if (len % 2 == 0) { 76 | indices.push(idx); 77 | if (x == startc) ++i; 78 | o[idx] = { selected: false, type: x, depth: i, idx: idx, pair: -1, extra: escape }; 79 | if (idx == pos && !fresh) o[idx].selected = true; 80 | if (x == startc) parens.push(idx); 81 | else { 82 | if (parens.length > 0) { 83 | var p = parens.pop(); 84 | o[idx].pair = p; 85 | if (o[p].selected && !fresh) o[idx].selected = true; 86 | o[p].pair = idx; 87 | if (o[idx].selected && !fresh) o[p].selected = true; 88 | } 89 | --i 90 | } 91 | } 92 | }); 93 | newtext = converted; 94 | indices = indices.sort(function(x,y) { return Number(y) - Number(x); }); 95 | indices.forEach(function(i) { 96 | newtext = newtext.substr(0,i) + o[i].extra + 97 | "" + o[i].type + "" + 99 | newtext.substr(i + 1 + o[i].extra.length) 100 | }); 101 | newtext = newtext.replace( 102 | // First parens prevent catching html attributes. The rest is from 103 | // http://stackoverflow.com/questions/249791/regex-for-quoted-string-with-escaping-quotes#answer-249937 104 | /([^=])(")((?:[^"\\]|\\.)*)(")/g, 105 | function(match, prev, q1, txt, q2) { 106 | return prev + q1 + '' + txt + '' + q2; 107 | }); 108 | return newtext; 109 | } 110 | 111 | (function($) { 112 | $.fn.getCursorPosition = function() { 113 | var input = this.get(0); 114 | if (!input) return; // No (input) element found 115 | if ('selectionStart' in input) { 116 | // Standard-compliant browsers 117 | return input.selectionStart; 118 | } else if (document.selection) { 119 | // IE 120 | input.focus(); 121 | var sel = document.selection.createRange(); 122 | var selLen = document.selection.createRange().text.length; 123 | sel.moveStart('character', -input.value.length); 124 | return sel.text.length - selLen; 125 | } 126 | } 127 | })(jQuery); 128 | 129 | -------------------------------------------------------------------------------- /web/showdown.js: -------------------------------------------------------------------------------- 1 | // 2 | // showdown.js -- A javascript port of Markdown. 3 | // 4 | // Copyright (c) 2007 John Fraser. 5 | // 6 | // Original Markdown Copyright (c) 2004-2005 John Gruber 7 | // 8 | // 9 | // Redistributable under a BSD-style open source license. 10 | // See license.txt for more information. 11 | // 12 | // The full source distribution is at: 13 | // 14 | // A A L 15 | // T C A 16 | // T K B 17 | // 18 | // 19 | // 20 | // 21 | // Wherever possible, Showdown is a straight, line-by-line port 22 | // of the Perl version of Markdown. 23 | // 24 | // This is not a normal parser design; it's basically just a 25 | // series of string substitutions. It's hard to read and 26 | // maintain this way, but keeping Showdown close to the original 27 | // design makes it easier to port new features. 28 | // 29 | // More importantly, Showdown behaves like markdown.pl in most 30 | // edge cases. So web applications can do client-side preview 31 | // in Javascript, and then build identical HTML on the server. 32 | // 33 | // This port needs the new RegExp functionality of ECMA 262, 34 | // 3rd Edition (i.e. Javascript 1.5). Most modern web browsers 35 | // should do fine. Even with the new regular expression features, 36 | // We do a lot of work to emulate Perl's regex functionality. 37 | // The tricky changes in this file mostly have the "attacklab:" 38 | // label. Major or self-explanatory changes don't. 39 | // 40 | // Smart diff tools like Araxis Merge will be able to match up 41 | // this file with markdown.pl in a useful way. A little tweaking 42 | // helps: in a copy of markdown.pl, replace "#" with "//" and 43 | // replace "$text" with "text". Be sure to ignore whitespace 44 | // and line endings. 45 | // 46 | // 47 | // Showdown usage: 48 | // 49 | // var text = "Markdown *rocks*."; 50 | // 51 | // var converter = new Showdown.converter(); 52 | // var html = converter.makeHtml(text); 53 | // 54 | // alert(html); 55 | // 56 | // Note: move the sample code to the bottom of this 57 | // file before uncommenting it. 58 | // 59 | // 60 | // Showdown namespace 61 | // 62 | var Showdown={extensions:{}},forEach=Showdown.forEach=function(a,b){if(typeof a.forEach=="function")a.forEach(b);else{var c,d=a.length;for(c=0;c?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|(?=~0))/gm,function(a,d,e,f,g){return d=d.toLowerCase(),b[d]=G(e),f?f+g:(g&&(c[d]=g.replace(/"/g,""")),"")}),a=a.replace(/~0/,""),a},m=function(a){a=a.replace(/\n/g,"\n\n");var b="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del|style|section|header|footer|nav|article|aside",c="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside";return a=a.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,n),a=a.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside)\b[^\r]*?<\/\2>[ \t]*(?=\n+)\n)/gm,n),a=a.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,n),a=a.replace(/(\n\n[ ]{0,3}[ \t]*(?=\n{2,}))/g,n),a=a.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,n),a=a.replace(/\n\n/g,"\n"),a},n=function(a,b){var c=b;return c=c.replace(/\n\n/g,"\n"),c=c.replace(/^\n/,""),c=c.replace(/\n+$/g,""),c="\n\n~K"+(d.push(c)-1)+"K\n\n",c},o=function(a){a=v(a);var b=A("
    ");return a=a.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,b),a=a.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,b),a=a.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,b),a=x(a),a=y(a),a=E(a),a=m(a),a=F(a),a},p=function(a){return a=B(a),a=q(a),a=H(a),a=t(a),a=r(a),a=I(a),a=G(a),a=D(a),a=a.replace(/ +\n/g,"
    \n"),a},q=function(a){var b=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|)/gi;return a=a.replace(b,function(a){var b=a.replace(/(.)<\/?code>(?=.)/g,"$1`");return b=N(b,"\\`*_"),b}),a},r=function(a){return a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,s),a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,s),a=a.replace(/(\[([^\[\]]+)\])()()()()()/g,s),a},s=function(a,d,e,f,g,h,i,j){j==undefined&&(j="");var k=d,l=e,m=f.toLowerCase(),n=g,o=j;if(n==""){m==""&&(m=l.toLowerCase().replace(/ ?\n/g," ")),n="#"+m;if(b[m]!=undefined)n=b[m],c[m]!=undefined&&(o=c[m]);else{if(!(k.search(/\(\s*\)$/m)>-1))return k;n=""}}n=N(n,"*_");var p='",p},t=function(a){return a=a.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,u),a=a.replace(/(!\[(.*?)\]\s?\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,u),a},u=function(a,d,e,f,g,h,i,j){var k=d,l=e,m=f.toLowerCase(),n=g,o=j;o||(o="");if(n==""){m==""&&(m=l.toLowerCase().replace(/ ?\n/g," ")),n="#"+m;if(b[m]==undefined)return k;n=b[m],c[m]!=undefined&&(o=c[m])}l=l.replace(/"/g,"""),n=N(n,"*_");var p=''+l+''+p(c)+"")}),a=a.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(a,c){return A('

    '+p(c)+"

    ")}),a=a.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(a,c,d){var e=c.length;return A("'+p(d)+"")}),a},w,x=function(a){a+="~0";var b=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;return e?a=a.replace(b,function(a,b,c){var d=b,e=c.search(/[*+-]/g)>-1?"ul":"ol";d=d.replace(/\n{2,}/g,"\n\n\n");var f=w(d);return f=f.replace(/\s+$/,""),f="<"+e+">"+f+"\n",f}):(b=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g,a=a.replace(b,function(a,b,c,d){var e=b,f=c,g=d.search(/[*+-]/g)>-1?"ul":"ol",f=f.replace(/\n{2,}/g,"\n\n\n"),h=w(f);return h=e+"<"+g+">\n"+h+"\n",h})),a=a.replace(/~0/,""),a};w=function(a){return e++,a=a.replace(/\n{2,}$/,"\n"),a+="~0",a=a.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,function(a,b,c,d,e){var f=e,g=b,h=c;return g||f.search(/\n{2,}/)>-1?f=o(L(f)):(f=x(L(f)),f=f.replace(/\n$/,""),f=p(f)),"
  • "+f+"
  • \n"}),a=a.replace(/~0/g,""),e--,a};var y=function(a){return a+="~0",a=a.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(a,b,c){var d=b,e=c;return d=C(L(d)),d=M(d),d=d.replace(/^\n+/g,""),d=d.replace(/\n+$/g,""),d="
    "+d+"\n
    ",A(d)+e}),a=a.replace(/~0/,""),a},z=function(a){return a+="~0",a=a.replace(/(?:^|\n)```(.*)\n([\s\S]*?)\n```/g,function(a,b,c){var d=b,e=c;return e=C(e),e=M(e),e=e.replace(/^\n+/g,""),e=e.replace(/\n+$/g,""),e="
    "+e+"\n
    ",A(e)}),a=a.replace(/~0/,""),a},A=function(a){return a=a.replace(/(^\n+|\n+$)/g,""),"\n\n~K"+(d.push(a)-1)+"K\n\n"},B=function(a){return a=a.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(a,b,c,d,e){var f=d;return f=f.replace(/^([ \t]*)/g,""),f=f.replace(/[ \t]*$/g,""),f=C(f),b+""+f+""}),a},C=function(a){return a=a.replace(/&/g,"&"),a=a.replace(//g,">"),a=N(a,"*_{}[]\\",!1),a},D=function(a){return a=a.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"$2"),a=a.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"$2"),a},E=function(a){return a=a.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(a,b){var c=b;return c=c.replace(/^[ \t]*>[ \t]?/gm,"~0"),c=c.replace(/~0/g,""),c=c.replace(/^[ \t]+$/gm,""),c=o(c),c=c.replace(/(^|\n)/g,"$1 "),c=c.replace(/(\s*
    [^\r]+?<\/pre>)/gm,function(a,b){var c=b;return c=c.replace(/^  /mg,"~0"),c=c.replace(/~0/g,""),c}),A("
    \n"+c+"\n
    ")}),a},F=function(a){a=a.replace(/^\n+/g,""),a=a.replace(/\n+$/g,"");var b=a.split(/\n{2,}/g),c=[],e=b.length;for(var f=0;f=0?c.push(g):g.search(/\S/)>=0&&(g=p(g),g=g.replace(/^([ \t]*)/g,"

    "),g+="

    ",c.push(g))}e=c.length;for(var f=0;f=0){var h=d[RegExp.$1];h=h.replace(/\$/g,"$$$$"),c[f]=c[f].replace(/~K\d+K/,h)}return c.join("\n\n")},G=function(a){return a=a.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&"),a=a.replace(/<(?![a-z\/?\$!])/gi,"<"),a},H=function(a){return a=a.replace(/\\(\\)/g,O),a=a.replace(/\\([`*_{}\[\]()>#+-.!])/g,O),a},I=function(a){return a=a.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,'
    $1'),a=a.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,function(a,b){return J(K(b))}),a},J=function(a){var b=[function(a){return"&#"+a.charCodeAt(0)+";"},function(a){return"&#x"+a.charCodeAt(0).toString(16)+";"},function(a){return a}];return a="mailto:"+a,a=a.replace(/./g,function(a){if(a=="@")a=b[Math.floor(Math.random()*2)](a);else if(a!=":"){var c=Math.random();a=c>.9?b[2](a):c>.45?b[1](a):b[0](a)}return a}),a=''+a+"",a=a.replace(/">.+:/g,'">'),a},K=function(a){return a=a.replace(/~E(\d+)E/g,function(a,b){var c=parseInt(b);return String.fromCharCode(c)}),a},L=function(a){return a=a.replace(/^(\t|[ ]{1,4})/gm,"~0"),a=a.replace(/~0/g,""),a},M=function(a){return a=a.replace(/\t(?=\t)/g," "),a=a.replace(/\t/g,"~A~B"),a=a.replace(/~B(.+?)~A/g,function(a,b,c){var d=b,e=4-d.length%4;for(var f=0;f li > a, 52 | .navbar-short .navbar-nav > li > a { 53 | -webkit-transition: all 0.2s linear; 54 | transition: all 0.2s linear; 55 | } 56 | 57 | .navbar-short { 58 | min-height: 40px; 59 | } 60 | .navbar-short .navbar-brand { 61 | font-size: 16px; 62 | padding: 13px 15px 10px; 63 | } 64 | .navbar-short .navbar-nav > li > a { 65 | padding-top: 12px; 66 | padding-bottom: 12px; 67 | } 68 | 69 | 70 | .navbar-tall { 71 | min-height: 70px; 72 | } 73 | .navbar-tall .navbar-brand { 74 | font-size: 24px; 75 | padding: 25px 15px; 76 | } 77 | .navbar-tall .navbar-nav > li > a { 78 | padding-top: 25px; 79 | } 80 | 81 | 82 | 83 | /** 84 | * Docs Buttons 85 | */ 86 | 87 | /* Demo buttons are all