猫史档案馆


自制脚本编程语言GCScript(Python)

用户:__KALI____KALI__查看:6 回复:4 评论:6 创建时间:2021-03-24T20:44:44


上 图!

center_image

代码太长了,400多行,发不出来QWQ


回复

上一页1 页 / 共 1下一页
__KALI____KALI__

import time
global line

def readfile(file):
    global READ_LINES
    global line    
    files = open(file)               
    line = files.readline()     
    while line: 
        is_file = True
        scripts(line)
        line = files.readline()
    is_file = False
    files.close()   
    
     
def sys_init_start(DE=False, GU=False, NE=True):
    DEBUG = DE
    GUI = GU
    NEW = NE


#settings
global read_sct
global ids
code_in_funk = []
DEBUG = False
is_file = False
VER = "0.1"
global READ_LINES
READ_LINES = []
WHILE_TIMES = []

WAS_PACKAGE = ["GCScript"]
FUNK_NAMES = []
FUNKS = {}
FUNC_KEYWORDS = ["void"]
KEYWORDS = ["when", "if", "outprint", "saqf", "using", "setv", "/", "help", "str_input", "pause", "+", "-", "*", "/", "**", "if", "c_value", "function", "inclube", "for", "while", "!"]
Ifwords = ["then"]
VLAUETYPES = ["string", "int", "float", "boolen", "bin"]
math_types = ["/", "*", "-", "+", "**"]

value_branches = {0:"string", 1:"int", 2:"float", 3:"boolen", 4:"bin"}
helps = None
users_value = {}
#settings
global contion
def if_branch(condition):

    global contion
    n1, n2 = '', ''
    contion = None
    ctn = condition.split("==")
    if ctn[0] in users_value.keys():
        n1 = users_value[ctn[0]]
                
    if ctn[1] in users_value.keys():
        n2 = users_value[ctn[1]]
                
                
    if n1 == '':

        n1 = int(ctn[0])

    if n2 == '':

        n2 = int(ctn[1])

    if n1 == n2:
        contion = True
        del n1
        del n2
        return None
    if n1 != n2:
        contion = False
        del n1
        del n2
        return None
    else:
        print("faild:")
        return None
def help_system(help_things=None):
    try:    
        
        files = open("help.txt")               
        line = files.readline()               
        while line: 
            
            print(line)
            line = files.readline()
        files.close()   
    except:
        print("faild to open helpfile")
        files.close() 
        print("THAT 'S VERY BAD")

def branch(types=None, types2=None):
    global read_sct
    global ids
    ids = 0
    if types2 == None:
        for script_text in read_sct:
            if types in script_text:ids += 1
    elif types2 != None:
        for script_text in read_sct:
            if types in script_text or types2 in script_text:ids += 1
    else:
        return None

def sys_exit_code(mode=False):
    if mode == True:
        pass
def scripts(script=None):
    global line
    global contion
    global ids
    
    if "inclube" in script:
        if script[0] == "#":
            wayu = script.index("e")
            if script[wayu+2:] == "get_press":
                if script[wayu+2:] in WAS_PACKAGE:
                    print("Has already inclubed the package "+script[wayu+2:])
                    return None
                else:
                    WAS_PACKAGE.append(script[wayu+2:])
                    return None
    if "GCScript" in WAS_PACKAGE:
        
        if script == None:return None
        
        else:
            global read_sct
            read_sct = script
            try:
                branch("!")
                if ids == 2:
                    
                    lbs = script.split("!")
                    del lbs[1]
                    script = lbs[0]+lbs[1]
                    del lbs
                    scripts(script)
                    return None
                else:
                    st = script.split("!")
                    del st[1]
                    script = st[0]
                    del st
                    scripts(script)
                    return None
            except IndexError:
                if script == "__diction__":
                    print(users_value)
                    print(FUNKS)
                    print(FUNK_NAMES)
                for keywords in KEYWORDS:
                    if keywords in script:
                        if keywords == "for":
                            ls_va = 0
                            branch("[", "]")
                            #for Value[times] {
                            if ids == 2:
                                lz = script.index("[")+1
                                rz = script.index("]")
                                try:
                                    int(script[lz:rz])
                                except ValueError:
                                    print("Faild:You must input a number!(Not string)")
                                    return None
                                else:
                                    users_value[script[4:script.index("[")]] = ls_va
                                    if script[len(script)-1:] == "{":
                                        WHILE_TIMES = []
                                        while True:
                                            cmd_s = input("[in for whiles]>>>")
                                            if cmd_s == "}":
                                                for _ in range(int(script[lz:rz])):
                                                    ls_va += 1
                                                    users_value[script[4:script.index("[")]] = ls_va
                                                    for wt in WHILE_TIMES:      
                                                        scripts(wt)
                                                return None
                                            else:
                                                WHILE_TIMES.append(cmd_s)

点赞2


评论


白篮白篮

带编译器吗?

点赞0


评论


__KALI____KALI__

带编译器

点赞0


评论


__KALI____KALI__

开源的,有链接和文章

点赞0


评论