-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
137 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(dotimes [{{ index_ident }} {{ 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,36 @@ | ||
{%- set vars_length = vars | length -%} | ||
|
||
{# SINGLE_TYPE #} | ||
{%- if vars_length == 1 -%} | ||
{%- set var = vars[0] -%} | ||
{%- if var.var_type == "String" or var.var_type == "Word" -%} | ||
{%- set fn = "" -%} | ||
{%- else -%} | ||
{%- set fn = "(map# " ~ type_tokens[var.var_type] ~ ") " -%} | ||
{%- endif -%} | ||
|
||
(doseq | ||
[{{ var.ident }} {{ fn }}(filter #(not-empty %) (str/split (read-line) #" "))] | ||
( )) | ||
{# MULTIPLE_TYPE #} | ||
{%- else -%} | ||
{%- set idents = vars | map(attribute="ident") | join(sep=" ") -%} | ||
{%- set idents = "[" ~ idents ~ "]" -%} | ||
|
||
{%- set_global fns = [] %} | ||
{%- for var in vars %} | ||
{%- if var.var_type == "String" or var.var_type == "Word" -%} | ||
{%- set fn = var.ident -%} | ||
{%- else -%} | ||
{%- set fn = "(" ~ type_tokens[var.var_type] ~ " " ~ var.ident ~ ")" -%} | ||
{%- endif %} | ||
{%- set_global fns = fns | concat(with=fn) -%} | ||
{%- endfor -%} | ||
|
||
(doseq | ||
[{{ idents }} (map (fn [{{ idents }}] [{{ fns | join(sep=" ") }}]) | ||
(partition {{ vars_length }} (filter #(not-empty %) (str/split (read-line) #" "))) | ||
] | ||
( )) | ||
|
||
{%- 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,15 @@ | ||
(ns Solution | ||
(:require [clojure.string :as str]) | ||
(:gen-class)) | ||
|
||
(defn output [msg] (println msg) (flush)) | ||
(defn debug [msg] (binding [*out* *err*] (println msg) (flush))) | ||
{% for line in statement %} | ||
; {{ line }} | ||
{%- endfor %} | ||
|
||
(defn -main [& args] | ||
{%- 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,27 @@ | ||
{%- set clj_split = '(filter #(not-empty %) (str/split (read-line) #" "))' -%} | ||
{%- set idents = vars | map(attribute="ident") | join(sep=" ")-%} | ||
|
||
{%- for var in vars %} | ||
{%- if var.input_comment -%}; {{ var.ident }}: {{ var.input_comment }} | ||
{% endif -%} | ||
{% endfor -%} | ||
|
||
{%- if single_type -%} | ||
{%- set var = vars[0] -%} | ||
{%- if var.var_type == "String" or var.var_type == "Word" -%} | ||
{%- set fn = "" -%} | ||
{%- else -%} | ||
{%- set fn = "(map #(" ~ type_tokens[var.var_type] ~ " %) " -%} | ||
{%- endif -%} | ||
|
||
(def [[{{ idents }}] {{ fn }}{{ clj_split }})] | ||
{% else -%} | ||
|
||
(let [{{ idents }}] {{ clj_split }} | ||
{% for var in vars -%} | ||
{%- if var.var_type != "String" and var.var_type != "Word" -%} | ||
(let {{ var.ident }} ({{type_tokens[var.var_type]}} {{var.ident}})) | ||
{% 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,10 @@ | ||
{%- set sym = format_symbols[var.var_type] -%} | ||
{%- if var.var_type == "String" or var.var_type == "Word" -%} | ||
{%- set fn = "(read-line)" -%} | ||
{%- else -%} | ||
{%- set fn = "(" ~ type_tokens[var.var_type] ~ " (read-line))" -%} | ||
{%- endif -%} | ||
|
||
{%- if var.input_comment %}; {{ var.input_comment }} | ||
{% endif -%} | ||
(let [{{ var.ident }} {{ fn }}]) |
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,24 @@ | ||
name = "clojure" | ||
source_file_ext = "clj" | ||
|
||
[type_tokens] | ||
Int = "Integer/parseInt" | ||
Long = "Long/parseLong" | ||
Float = "Float/parseFloat" | ||
Bool = "not= \"0\"" | ||
String = "NONE" | ||
Word = "NONE" | ||
|
||
[variable_name_options] | ||
casing = "camel_case" | ||
allow_uppercase_vars = false | ||
keywords = [ | ||
"auto", "break", "case", "char", | ||
"const", "continue", "default", "do", | ||
"double", "else", "enum", "extern", | ||
"float", "for", "goto", "if", | ||
"int", "register", "return", | ||
"short", "signed", "sizeof", "static", | ||
"struct", "switch", "typedef", "union", | ||
"unsigned", "void", "volatile", "while" | ||
] |
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,6 @@ | ||
{%- for line in output_comments %} | ||
; {{ line }} | ||
{% endfor %} | ||
{%- for line in messages -%} | ||
(output "{{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,16 @@ | ||
{%- set_global out = "" -%} | ||
{%- for term in terms -%} | ||
{%- if term.is_variable -%} | ||
{%- set_global out = out ~ term.ident -%} | ||
{%- else -%} | ||
{%- set_global out = out ~ '"' ~ term.ident ~ '"' -%} | ||
{%- endif -%} | ||
{%- if loop.last == false -%} | ||
{%- set_global out = out ~ ' + " " + ' -%} | ||
{%- endif -%} | ||
{%- endfor -%} | ||
|
||
{%- for line in output_comments -%} # {{ line }} | ||
{% endfor -%} | ||
(print {{ out | replace(from='" + "', to="") | replace(from=' +', to="") }}) | ||
(output "") |