Skip to content

Commit

Permalink
Python tree-sitter to CAST Porting: Imports (#826)
Browse files Browse the repository at this point in the history
This PR introduces support for generating CAST import statements. This
is using tree sitter, as part of the ongoing effort to port over the
Python AST to CAST generation to use tree-sitter.

### Summary of Changes

- Adds handlers to python/ts2cast.py to support CAST generation for
import statements.
- Adds basic CAST generation for the attribute idiom. In order to
support function calls from imports.
- Adds test script test_import_cast.py with unit tests to maintain
consistency.
- Added 'support' for yields and assert statements. The current
generation is to passthrough them, so nothing important gets generated
from these.

### Related issues
-

Resolves #804

---------

Co-authored-by: Vincent Raymond <vincent@lum.ai> 102dd72
  • Loading branch information
github-actions[bot] committed Mar 4, 2024
1 parent 0e4a801 commit 7d60fc5
Show file tree
Hide file tree
Showing 2,487 changed files with 243,144 additions and 218,931 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ <h3>Instance variables</h3>
<h3>Methods</h3>
<dl>
<dt id="skema.img2mml.models.decoders.xfmer_decoder.Transformer_Decoder.create_pad_mask"><code class="name flex">
<span>def <span class="ident">create_pad_mask</span></span>(<span>self, matrix: <built-in method tensor of type object at 0x7fe9c655b500>, pad_token: int) ‑> <built-in method tensor of type object at 0x7fe9c655b500></span>
<span>def <span class="ident">create_pad_mask</span></span>(<span>self, matrix: <built-in method tensor of type object at 0x7f93e855b500>, pad_token: int) ‑> <built-in method tensor of type object at 0x7f93e855b500></span>
</code></dt>
<dd>
<div class="desc"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ <h3>Class variables</h3>
<h3>Methods</h3>
<dl>
<dt id="skema.img2mml.models.encoding.positional_encoding_for_xfmer.PositionalEncoding.forward"><code class="name flex">
<span>def <span class="ident">forward</span></span>(<span>self, x: <built-in method tensor of type object at 0x7fe9c655b500>) ‑> <built-in method tensor of type object at 0x7fe9c655b500></span>
<span>def <span class="ident">forward</span></span>(<span>self, x: <built-in method tensor of type object at 0x7f93e855b500>) ‑> <built-in method tensor of type object at 0x7f93e855b500></span>
</code></dt>
<dd>
<div class="desc"><p>Defines the computation performed at every call.</p>
Expand Down
508 changes: 490 additions & 18 deletions api/python/skema/program_analysis/CAST/python/ts2cast.html

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions api/python/skema/program_analysis/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
<dd>
<div class="desc"></div>
</dd>
<dt><code class="name"><a title="skema.program_analysis.tests.test_import_cast" href="test_import_cast.html">skema.program_analysis.tests.test_import_cast</a></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt><code class="name"><a title="skema.program_analysis.tests.test_import_method" href="test_import_method.html">skema.program_analysis.tests.test_import_method</a></code></dt>
<dd>
<div class="desc"></div>
Expand Down Expand Up @@ -169,6 +173,7 @@ <h1>Index</h1>
<li><code><a title="skema.program_analysis.tests.test_goto_basic" href="test_goto_basic.html">skema.program_analysis.tests.test_goto_basic</a></code></li>
<li><code><a title="skema.program_analysis.tests.test_goto_computed" href="test_goto_computed.html">skema.program_analysis.tests.test_goto_computed</a></code></li>
<li><code><a title="skema.program_analysis.tests.test_identifier" href="test_identifier.html">skema.program_analysis.tests.test_identifier</a></code></li>
<li><code><a title="skema.program_analysis.tests.test_import_cast" href="test_import_cast.html">skema.program_analysis.tests.test_import_cast</a></code></li>
<li><code><a title="skema.program_analysis.tests.test_import_method" href="test_import_method.html">skema.program_analysis.tests.test_import_method</a></code></li>
<li><code><a title="skema.program_analysis.tests.test_literal_returns" href="test_literal_returns.html">skema.program_analysis.tests.test_literal_returns</a></code></li>
<li><code><a title="skema.program_analysis.tests.test_loops" href="test_loops.html">skema.program_analysis.tests.test_loops</a></code></li>
Expand Down
Loading

0 comments on commit 7d60fc5

Please sign in to comment.