{ "info": { "author": "Todd Iverson", "author_email": "tiverson@smumn.edu", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha" ], "description": "ParselTongue Magic\n==================\n\nThis python module adds ipython magic for the ParselTongue language that\nis part of the `online programming languages\nclass `__ run at\nBrown.\n\nYou can install this module using ``pip`` as follows pip install\npslmagic\n\nNotes for Windows Users\n-----------------------\n\nIf you intend to use this module on Windows, you will need the do the\nfollowing\n\n1) install and have ``bash`` on your PATH. An acceptable version of bash\n is included in the Git for Windows installer, make sure to select\n **Use Git and optional Unix tools for the Windows Command Prompt**\n\n2) Use relative addresses when registering the executable and specifying\n the test file base (see below).\n\nUsing ``pslmagic``\n------------------\n\nThe first step when using ``pslmagic`` is to start the ipython notebook,\npreferably from the command line in the test folder.\n\n::\n\n ipython notebook\n\nLoad the magic\n~~~~~~~~~~~~~~\n\nStart a new notebook and run the following command to load ``palmagic``\n\n.. code:: python\n\n %reload_ext pslmagic\n\n.. parsed-literal::\n\n WARNING:Please register the address of the ParselTongue executable using %psl_exe
\n\n\nRegister the ParselTongue interpreter(s)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYou need to download the parseltongue interpreter from the `Brown CS1730\npage `__\n\nThen, call the ``psl_exe`` to register the address for the execuable\n(*Use a relative address for Windows*)\n\n.. code:: python\n\n %psl_exe /Users/tiverson/Desktop/osx-dist/bin/assignment1-osx\n\nLine magic to evaluate short commands\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYou can evaluate a single line of ParselTongue using the ``psl`` magic.\nA single % indicates *line* magic\n\n.. code:: python\n\n %psl +(40, 2)\n\n.. parsed-literal::\n\n 42\n \n\n\nErrors are thrown as python exceptions\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n\n.. code:: python\n\n %psl 5;7\n\n::\n\n\n File \"\", line unknown\n SyntaxError: Encountered error while parsing, near: \"\" [line=#f, column=#f, position=#f]\n \n\n\n\nUse cell magic to evaluate longer programs\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYou can type a whole cell of ParselTongue using the ``%%psl`` cell\nmagic. The double % are used to indicate cell magic, and the remainder\nof the current cell will be considered ParselTongue.\n\n.. code:: python\n\n %%psl\n # deffun defines a recursive function\n deffun fib(n)\n # operators like + and == are prefix\n if <(n, 1) then 0 else\n if ==(n, 1) then 1 else\n +(fib(-(n, 1)), fib(-(n, 2)))\n # The in ends the function body in a deffun, which can be followed by\n # another deffun, a defvar, or a braced expression\n in\n # defvar creates a new variable with an initial value, bound inside the\n # body of the defvar\n defvar x = 0 in {\n # For loops have an initialization, a test, an update, and a body\n for(x = 0; <(x,10); x++) {\n # print takes any value and displays it\n print(fib(x));\n print(\" \");\n };\n # The result of the program is the value of the last expression\n # evaluated. It is printed, so we avoid printing it by terminating the\n # program with a \"\"\n \"\";\n }\n\n \n.. parsed-literal::\n\n 0 1 1 2 3 5 8 13 21 34 \n \n\n\nCreate tests for the test suite\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYou can create a test for your test suite using the\n``%%psl_create_test`` magic. The first argument (on the\n``%%psl_create_test line``) is the base file name. Three files will be\ncreated\n\n1) base.psl - contains the code in the cell\n\n2) base.psl.expected - creates the output when running the code vs. the\n correct interpreter.\n\n3) base.psl.error - contains any errors generated when running vs. the\n correct interpreter\n\n\n\n.. code:: python\n\n %%psl_create_test test_case\n # deffun defines a recursive function\n deffun fib(n)\n # operators like + and == are prefix\n if <(n, 1) then 0 else\n if ==(n, 1) then 1 else\n +(fib(-(n, 1)), fib(-(n, 2)))\n # The in ends the function body in a deffun, which can be followed by\n # another deffun, a defvar, or a braced expression\n in\n # defvar creates a new variable with an initial value, bound inside the\n # body of the defvar\n defvar x = 0 in {\n # For loops have an initialization, a test, an update, and a body\n for(x = 0; <(x,10); x++) {\n # print takes any value and displays it\n print(fib(x));\n print(\" \");\n };\n # The result of the program is the value of the last expression\n # evaluated. It is printed, so we avoid printing it by terminating the\n # program with a \"\"\n \"\";\n }\n\n\nTo inspect the resulting files, run the following commands\n\n.. code:: python\n\n %%bash\n echo \"*******PSL FILE*******\"\n less test_case.psl\n echo \"*******EXPECTED RESULTS FILE*******\"\n less test_case.psl.expected\n echo \"*******ERROR FILE*******\"\n less test_case.psl.error\n\n.. parsed-literal::\n\n *******PSL FILE*******\n # deffun defines a recursive function\n deffun fib(n)\n # operators like + and == are prefix\n if <(n, 1) then 0 else\n if ==(n, 1) then 1 else\n +(fib(-(n, 1)), fib(-(n, 2)))\n # The in ends the function body in a deffun, which can be followed by\n # another deffun, a defvar, or a braced expression\n in\n # defvar creates a new variable with an initial value, bound inside the\n # body of the defvar\n defvar x = 0 in {\n # For loops have an initialization, a test, an update, and a body\n for(x = 0; <(x,10); x++) {\n # print takes any value and displays it\n print(fib(x));\n print(\" \");\n };\n # The result of the program is the value of the last expression\n # evaluated. It is printed, so we avoid printing it by terminating the\n # program with a \"\"\n \"\";\n }*******EXPECTED RESULTS FILE*******\n 0 1 1 2 3 5 8 13 21 34 \n *******ERROR FILE*******\n\n\nRun the test suite versus the 25 incorrect interpreters\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYou can run your test suite versus the 25 incorrect interpreters using\nthe ``%psl_run_tests`` magic. The first argument is the address of the\nexecuable (again using relative addresses on Windows)\n\n.. code:: python\n\n %psl_run_tests /Users/tiverson/Desktop/sample-test-suite/\n\n.. parsed-literal::\n\n bindings1:\n Bug not found!\n bindings2:\n Differences in:\n /Users/tiverson/Desktop/sample-test-suite/test_case.psl\n \n bindings3:\n Differences in:\n /Users/tiverson/Desktop/sample-test-suite/test_case.psl\n /Users/tiverson/Desktop/sample-test-suite/functions/func5.psl\n \n bindings4:\n Bug not found!\n functions1:\n Differences in:\n /Users/tiverson/Desktop/sample-test-suite/functions/func5.psl\n \n functions2:\n Bug not found!\n functions3:\n Differences in:\n /Users/tiverson/Desktop/sample-test-suite/test_case.psl\n \n if-then-else1:\n Bug not found!\n if-then-else2:\n Bug not found!\n if-then-else3:\n Differences in:\n /Users/tiverson/Desktop/sample-test-suite/if1.psl\n /Users/tiverson/Desktop/sample-test-suite/test_case.psl\n \n loops1:\n Bug not found!\n loops2:\n Differences in:\n /Users/tiverson/Desktop/sample-test-suite/test_case.psl\n \n loops3:\n Bug not found!\n loops4:\n Differences in:\n /Users/tiverson/Desktop/sample-test-suite/test_case.psl\n \n loops5:\n Bug not found!\n objects1:\n Bug not found!\n objects2:\n Bug not found!\n objects3:\n Bug not found!\n objects4:\n Bug not found!\n operators1:\n Differences in:\n /Users/tiverson/Desktop/sample-test-suite/test_case.psl\n \n operators2:\n Bug not found!\n operators2:\n Bug not found!\n operators3:\n Bug not found!\n sequence1:\n Differences in:\n /Users/tiverson/Desktop/sample-test-suite/test_case.psl\n \n sequence2:\n Differences in:\n /Users/tiverson/Desktop/sample-test-suite/test_case.psl\n \n You found bugs in 10/25 interpreters.\n \n \n\n\nRun versus a single interpreter with ``psl_run_single``\n-------------------------------------------------------\n\nYou can use the line magic ``psl_run_single`` to run a test suite\nagainst just one interpreter. The two arguments for this magic are the\ninterpreter name (see ``psl_run_tests`` output) and the directory\n\n::\n\n %psl_run_single \n\n\n.. code:: python\n\n %psl_run_single if-then-else3 /Users/tiverson/Desktop/sample-test-suite/\n\n.. parsed-literal::\n\n if-then-else3:\n 2 tests succeeded.\n 2 tests failed.\n == Output of failed tests ==\n =====================================================\n = Results for /Users/tiverson/Desktop/sample-test-suite/if1.psl =\n =====================================================\n === Expected stdout ===\n passed\n passed\n passed\n passed\n \n \n === Actual stdout ===\n failed\n passed\n failed\n failed\n \n \n === Expected stderr ===\n \n === Actual stderr ===\n \n =====================================================\n = Results for /Users/tiverson/Desktop/sample-test-suite/test_case.psl =\n =====================================================\n === Expected stdout ===\n 0 1 1 2 3 5 8 13 21 34 \n \n === Actual stdout ===\n \n \n === Expected stderr ===\n \n === Actual stderr ===\n \n \n You found bugs in 1/1 interpreters.", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/yardsale8/pslmagic/tarball/0.5", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/yardsale8/pslmagic", "keywords": "ParselTongue,IPython extension,IPython magic", "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "pslmagic", "package_url": "https://pypi.org/project/pslmagic/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pslmagic/", "project_urls": { "Download": "https://github.com/yardsale8/pslmagic/tarball/0.5", "Homepage": "https://github.com/yardsale8/pslmagic" }, "release_url": "https://pypi.org/project/pslmagic/0.5/", "requires_dist": null, "requires_python": null, "summary": "IPython magic for ParselTongue", "version": "0.5" }, "last_serial": 1236866, "releases": { "0.4": [ { "comment_text": "", "digests": { "md5": "41e72bc593ea579cbb667f323b9ed5b2", "sha256": "321fab934d9149896fb6e24d451f59e7ff041f7c0710920a4dca02cc3bf9a7f7" }, "downloads": -1, "filename": "pslmagic-0.4.tar.gz", "has_sig": false, "md5_digest": "41e72bc593ea579cbb667f323b9ed5b2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4704, "upload_time": "2014-09-22T11:21:08", "url": "https://files.pythonhosted.org/packages/ae/2b/11a261532d4816d400a6c5dfedaa07e2f449f1ad32aad7d3fa179d95cf2f/pslmagic-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "e892e1d1958653bd7c8af5b858587a7c", "sha256": "f7c58ac7d819ef23eb55875a77d11be209684cb46cbe361eeeee1e217112b4a2" }, "downloads": -1, "filename": "pslmagic-0.5.tar.gz", "has_sig": false, "md5_digest": "e892e1d1958653bd7c8af5b858587a7c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5023, "upload_time": "2014-09-24T19:29:10", "url": "https://files.pythonhosted.org/packages/47/a0/c19c264effbf14052cdecf73001a5f958493c6d4299b8f73707cea62e39f/pslmagic-0.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e892e1d1958653bd7c8af5b858587a7c", "sha256": "f7c58ac7d819ef23eb55875a77d11be209684cb46cbe361eeeee1e217112b4a2" }, "downloads": -1, "filename": "pslmagic-0.5.tar.gz", "has_sig": false, "md5_digest": "e892e1d1958653bd7c8af5b858587a7c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5023, "upload_time": "2014-09-24T19:29:10", "url": "https://files.pythonhosted.org/packages/47/a0/c19c264effbf14052cdecf73001a5f958493c6d4299b8f73707cea62e39f/pslmagic-0.5.tar.gz" } ] }