lexer.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Essential 作者: V1Soft 项目源码 文件源码
def lex(parsedScript):
    lexedScript = parsedScript
    functions = []
    index = 0
    for structure in parsedScript:
        if structure[0] == 'use':
            proto = ''
            pkg = ''
            if structure[1].startswith('.'):
                proto = structure[1][1:]
            else:
                proto = '/' + structure[1]
            for char in proto:
                if char == '.':
                    pkg += '/'
                elif char == '/':
                    print('Error: Invalid Syntax.')
                    sys.exit(1)
                else:
                    pkg += char
            lex(parser.parse(open(pkg + '.essl', 'r+').read()))
        elif structure[0][0] == 'subroutine':
            functions.append(classes.Variable(structure[0][1], structure[1:]))
            lexedScript[index].remove(structure[0])
        index += 1
    return functions
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号