Skip to content

Commit adc8734

Browse files
Merge branch 'main' into heroku
2 parents 805c956 + 8a3139c commit adc8734

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

compiler/elixir.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import re
2+
import sys
3+
import json
4+
from typing import Tuple, List
5+
6+
def run(cmd: str, cwd: str) -> dict:
7+
# For simplicity, we'll just analyze the passed command
8+
# In a real scenario, you'd use subprocess to actually run the command
9+
problems = find_all(cmd)
10+
return {
11+
"ok": len(problems) == 0,
12+
"message": f"Analyzed command: {cmd}",
13+
"problems": formatting(problems, "error")
14+
}
15+
16+
def find_all(output: str) -> List[Tuple[str, str, str]]:
17+
return re.findall(r"File \"./([^\"]+)\", line (\d+)\n.*\n.*\n(.*)", output)
18+
19+
def formatting(problems: List[Tuple[str, str, str]], kind: str) -> List[dict]:
20+
result = []
21+
for (file, row, msg) in problems:
22+
result.append({
23+
"file": file,
24+
"type": kind,
25+
"row": int(row) - 1,
26+
"col": 0,
27+
"text": msg
28+
})
29+
return result
30+
31+
if __name__ == "__main__":
32+
cmd = sys.argv[1] if len(sys.argv) > 1 else ""
33+
result = run(cmd, ".")
34+
print(json.dumps(result))

0 commit comments

Comments
 (0)