Skip to content

Commit

Permalink
that's how you do modifiers @user
Browse files Browse the repository at this point in the history
  • Loading branch information
lyxal committed Aug 13, 2021
1 parent 4d65bf7 commit 4781477
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions vyxal/elements.py
Expand Up @@ -48,3 +48,4 @@ def process_element(


elements = {}
modifiers = {}
29 changes: 25 additions & 4 deletions vyxal/transpile.py
Expand Up @@ -134,7 +134,7 @@ def transpile_structure(struct: structure.Structure, indent: int) -> str:
var = f"VAR_{var}"
return (
indent_str(f"for {var} in iterable(pop(stack)):", indent)
+ indent_str(" context_values.append({var})", indent)
+ indent_str(f" context_values.append({var})", indent)
+ transpile_ast(struct.body, indent + 1)
+ indent_str(" context_values.pop()", indent)
)
Expand Down Expand Up @@ -204,10 +204,31 @@ def _lambda_{}(parameters, arity, self, *, ctx):
temp += "stack.append(temp_List[::])"
return temp
if isinstance(struct, structure.MonadicModifier):
raise Error("I WANT A RAISE")
element_A = transpile(lambda_wrap(struct.branches[1][0]))
return element_A + "\n" + elements.modifiers.get(struct.branches[0])

if isinstance(struct, structure.DyadicModifier):
raise Error("I WANT A RAISE")
element_A = transpile(lambda_wrap(struct.branches[1][0]))
element_B = transpile(lambda_wrap(struct.branches[1][1]))
return (
element_A
+ "\n"
+ element_B
+ "\n"
+ elements.modifiers.get(struct.branches[0])
)
if isinstance(struct, structure.TriadicModifier):
raise Error("I WANT A RAISE")
element_A = transpile(lambda_wrap(struct.branches[1][0]))
element_B = transpile(lambda_wrap(struct.branches[1][1]))
element_C = transpile(lambda_wrap(struct.branches[1][2]))
return (
element_A
+ "\n"
+ element_B
+ "\n"
+ element_C
+ "\n"
+ elements.modifiers.get(struct.branches[0])
)

raise ValueError(struct)

0 comments on commit 4781477

Please sign in to comment.