{ "cells": [ { "cell_type": "markdown", "id": "3f7f66b6", "metadata": {}, "source": [ "# Import Tiger and Parse" ] }, { "cell_type": "code", "execution_count": 1, "id": "9cb3bce5", "metadata": {}, "outputs": [], "source": [ "import tc" ] }, { "cell_type": "code", "execution_count": 2, "id": "be38c5fe", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tc.has(\"parse\")" ] }, { "cell_type": "code", "execution_count": 3, "id": "9fe09a20", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import tiger_parse\n", "tiger_parse == tc.parse" ] }, { "cell_type": "markdown", "id": "3b3a7285", "metadata": {}, "source": [ "# Parse Library" ] }, { "cell_type": "code", "execution_count": 4, "id": "2be2f25d", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['MetavarChunkList',\n", " 'MetavarMap',\n", " 'MetavarNameTy',\n", " 'MetavarVar',\n", " 'TigerParser',\n", " 'YY_NULLPTR',\n", " 'location',\n", " 'parse',\n", " 'parse_chunks',\n", " 'parse_unit',\n", " 'position']" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "list(filter(lambda e: not e.startswith(\"_\") and not e.endswith(\"Tweast\") and not e.startswith(\"tiger\"), dir(tc.parse)))" ] }, { "cell_type": "markdown", "id": "c2ffa10b", "metadata": {}, "source": [ "# Parse parse" ] }, { "cell_type": "code", "execution_count": 5, "id": "0ee4cd72", "metadata": {}, "outputs": [], "source": [ "import tempfile\n", "\n", "if tc.has(\"misc\"):\n", " with tempfile.NamedTemporaryFile() as f:\n", " f.write(b\"let in end\")\n", " f.seek(0)\n", " ast = tc.parse.parse(\"builtin\", f.name, tc.misc.file_library())\n", " # do not use ast before tc2" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.1" } }, "nbformat": 4, "nbformat_minor": 5 }