Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
fix: Fixed chandra bugs discovered 2
Browse files Browse the repository at this point in the history
  • Loading branch information
marsninja committed Jan 30, 2024
1 parent 01f440b commit 4894705
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
4 changes: 2 additions & 2 deletions jaclang/compiler/jac.lark
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,9 @@ builtin_type: TYP_TYPE

// Lexer Tokens
FLOAT: /(\d+(\.\d*)|\.\d+)([eE][+-]?\d+)?/
DOC_STRING: /"""(.|\n|\r)*?"""|'''(.|\n|\r)*?'''/
DOC_STRING.1: /"""(.|\n|\r)*?"""|'''(.|\n|\r)*?'''/
PYNLINE: /::py::(.|\n|\r)*?::py::/
STRING: /(r?b?|b?r?)"[^"\r\n]*"|'[^'\r\n]*'/
STRING: /(r?b?|b?r?)"[^"\r\n]*"|(r?b?|b?r?)'[^'\r\n]*'/
BOOL.1: /True|False/
KW_NIN.1: /\bnot\s+in\b/
KW_ISN.1: /\bis\s+not\b/
Expand Down
2 changes: 1 addition & 1 deletion jaclang/compiler/passes/main/pyast_gen_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ def exit_assignment(self, node: ast.Assignment) -> None:
if node.type_tag:
node.gen.py_ast = self.sync(
ast3.AnnAssign(
target=node.target.gen.py_ast,
target=node.target.items[0].gen.py_ast,
annotation=node.type_tag.gen.py_ast,
value=node.value.gen.py_ast if node.value else None,
simple=int(isinstance(node.target.gen.py_ast, ast3.Name)),
Expand Down
16 changes: 16 additions & 0 deletions jaclang/tests/fixtures/chandra_bugs2.jac
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import:py re;

glob a:int =5;

with entry {
arguments = {x:None for x in re.findall(r'\{([A-Za-z0-9_]+)\}', "Apple {apple} pineapple {pineapple}")};
a: int=5;
if False {
with open(f"Apple{apple}.txt") as f { # Fix syntax highlighting
print(f.read());
}
}
print (arguments);
}

# Use before def error would be nice
12 changes: 12 additions & 0 deletions jaclang/tests/test_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ def test_chandra_bugs(self) -> None:
"<link href='{'new_val': 3, 'where': 'from_foo'} rel='stylesheet'\nTrue\n",
)

def test_chandra_bugs2(self) -> None:
"""Parse micro jac file."""
captured_output = io.StringIO()
sys.stdout = captured_output
jac_import("chandra_bugs2", self.fixture_abs_path("./"))
sys.stdout = sys.__stdout__
stdout_value = captured_output.getvalue()
self.assertEqual(
stdout_value,
"{'apple': None, 'pineapple': None}\n",
)

def test_ignore(self) -> None:
"""Parse micro jac file."""
construct.root._jac_.edges[construct.EdgeDir.OUT].clear()
Expand Down

0 comments on commit 4894705

Please sign in to comment.