forked from Andriamanitra/coctus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from daxida/bugfixing
Add python templates, refactor codebase and fix bugs
- Loading branch information
Showing
25 changed files
with
872 additions
and
385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{%- if debug_mode -%} | ||
---- 🇱 OOP | ||
{% endif -%} | ||
|
||
for {{ index_ident }} in range({{ count_var }}): | ||
{%- for line in inner %} | ||
{{line}} | ||
{%- endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{%- if debug_mode -%} | ||
---- 🇱 OOPLINE | ||
{%- if vars | length == 1 -%} | ||
(SINGLE_TYPE) | ||
{% else -%} | ||
(MULTIPLE_TYPE) | ||
{% endif -%} | ||
{% endif -%} | ||
|
||
{%- if vars | length == 1 -%} | ||
{# SINGLE_TYPE #} | ||
{%- set var = vars[0] -%} | ||
{# Special CG case, doesn't make much sense otherwise #} | ||
{%- if var.var_type == "Word" -%} | ||
for {{ var.ident }} in input().split(): | ||
pass | ||
|
||
{%- else -%} | ||
|
||
for {{ index_ident }} in input().split(): | ||
{%- if var.var_type == "String" -%} | ||
{%- set fn = index_ident -%} | ||
{%- else -%} | ||
{%- set fn = type_tokens[var.var_type] ~ "(" ~ index_ident ~ ")" -%} | ||
{%- endif %} | ||
{{ var.ident }} = {{ fn }} | ||
|
||
{%- endif -%} | ||
{# MULTIPLE_TYPE #} | ||
{%- else -%} | ||
|
||
inputs = input().split() | ||
for {{ index_ident }} in range({{ count_var }}): | ||
{%- for var in vars %} | ||
{%- if loop.index0 == 0 -%} | ||
{%- set idx = "" -%} | ||
{%- else -%} | ||
{%- set idx = "+" ~ loop.index0 -%} | ||
{%- endif -%} | ||
{%- if var.var_type == "String" or var.var_type == "Word" -%} | ||
{%- set fn = "inputs[2*" ~ index_ident ~ idx ~ "]" -%} | ||
{%- else -%} | ||
{%- set fn = type_tokens[var.var_type] ~ "(inputs[2*" ~ index_ident ~ idx ~ "])" -%} | ||
{%- endif %} | ||
{{ var.ident }} = {{ fn }} | ||
{%- endfor %} | ||
|
||
{%- endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% if debug_mode %} | ||
---- 🇲 AIN | ||
{% endif -%} | ||
{% if debug_mode -%} | ||
---- 🇸 TATEMENT | ||
{% endif -%} | ||
|
||
{%- for line in statement -%} | ||
# {{ line }} | ||
{% endfor %} | ||
{%- for line in code_lines %} | ||
{{ line }} | ||
{%- endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{%- if debug_mode -%} | ||
---- 🇷 EAD_MANY | ||
{%- if single_type -%} | ||
(SINGLE_TYPE) | ||
{% else -%} | ||
(MULTIPLE_TYPE) | ||
{% endif -%} | ||
{% endif -%} | ||
|
||
{%- set_global names = vars | map(attribute="ident") | join(sep=", ") -%} | ||
|
||
{%- if single_type -%} | ||
|
||
{%- for var in vars %} | ||
{%- if var.input_comment -%}# {{ var.ident }}: {{ var.input_comment }} | ||
{% endif -%} | ||
{% endfor -%} | ||
|
||
{%- set_global type = vars[0].var_type -%} | ||
{%- if type == "String" or type == "Word" -%} | ||
{%- set assign = "input().split()" -%} | ||
{%- else -%} | ||
{%- set assign = "[" ~ type_tokens[type] ~ "(i) for i in input().split()]" -%} | ||
{%- endif -%} | ||
{{ names }} = {{ assign }} | ||
|
||
{%- else -%} | ||
|
||
inputs = input().split() | ||
{%- for var in vars %} | ||
{% if var.var_type == "String" or var.var_type == "Word" -%} | ||
{%- set assign = "inputs[" ~ loop.index0 ~ "]" -%} | ||
{% else -%} | ||
{%- set assign = type_tokens[var.var_type] ~ "(inputs[" ~ loop.index0 ~ "])" -%} | ||
{% endif -%} | ||
{{ var.ident }} = {{ assign }}{%- if var.input_comment %} # {{ var.input_comment }}{% endif %} | ||
{%- endfor -%} | ||
|
||
{%- endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% if debug_mode -%} | ||
---- 🇷 EAD_ONE: {{ var.var_type }} | ||
{% endif %} | ||
|
||
{%- if var.var_type == "String" or var.var_type == "Word" -%} | ||
{%- set fn = "input()" -%} | ||
{%- elif var.var_type == "Bool" -%} | ||
{%- set fn = "input()" ~ type_tokens[var.var_type] -%} | ||
{%- else -%} | ||
{%- set fn = type_tokens[var.var_type] ~ "(input())" -%} | ||
{%- endif -%} | ||
|
||
{{ var.ident }} = {{ fn }}{%- if var.input_comment %} # {{ var.input_comment }}{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name = "python" | ||
variable_format = "snake_case" | ||
source_file_ext = "py" | ||
allow_uppercase_vars = false | ||
keywords = [ | ||
"for" | ||
] | ||
aliases = ["py"] | ||
|
||
[type_tokens] | ||
Int = "int" | ||
Long = "int" | ||
Float = "float" | ||
Bool = " != \"0\"" | ||
String = "UNUSED" | ||
Word = "UNUSED" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{%- if debug_mode -%} | ||
---- 🇼 RITE | ||
{% endif -%} | ||
|
||
{%- for line in output_comments -%} | ||
# {{ line }} | ||
{% endfor %} | ||
{%- for line in messages -%} | ||
print("{{line}}") | ||
{% endfor -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{%- if debug_mode -%} | ||
---- 🇼 RITE_JOIN | ||
{% endif -%} | ||
|
||
{%- set_global out = "" -%} | ||
{%- for term in terms -%} | ||
{%- if term.term_type == "Variable" -%} | ||
{%- set_global out = out ~ "str(" ~ term.name ~ ")" -%} | ||
{%- else -%} | ||
{%- set_global out = out ~ '"' ~ term.name ~ '"' -%} | ||
{%- endif -%} | ||
{%- if loop.last == false %} | ||
{%- set_global out = out ~ ' + " " + ' -%} | ||
{% endif %} | ||
{%- endfor -%} | ||
|
||
{%- for line in output_comments %} | ||
# {{ line }} | ||
{%- endfor -%} | ||
print({{ out | replace(from='" + "', to="") }}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.