-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cool-lsp.py
40 lines (35 loc) · 1.01 KB
/
Cool-lsp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
##################### ##################### ###############
# COOL INTERPRETOR IN PY
# Author: Li Linhan
# Date: 7/10/2021
# Dependency:
# numpy(Int32)
# PLY
# Known issue:
# check parser and interpreter for details.
##################### ##################### ###############
import argparse
import os
from sys import argv
from functools import reduce
from io import StringIO
from utils.env import Cool_value
from Lexer.lexer import get_toks_stream
from Parser.parser import get_ast_stream
from Typechecker.typechecker import get_type_checked_ast
from Interpreter.interpreter import evaluate_cl_type
stages = [ get_toks_stream,
get_ast_stream,
get_type_checked_ast,
evaluate_cl_type
]
file_ext= [ "",
".cl-lex",
".cl-ast",
".cl-type"
]
inStream = sys.stdin
outStream= reduce( lambda val, ele : ele(val),
stages[0:3],
inStream
)