加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
util.py 1.18 KB
一键复制 编辑 原始数据 按行查看 历史
天命昭昭 提交于 2021-04-28 15:28 . wyz
class Production(object):
def __init__(self, left, right, select=None):
self.left = left
self.right = right
self.select = set()
def __str__(self):
return self.left + " -> " + str(self.right) + " Select: " + str(self.select)
class Symbol(object):
def __init__(self, symbol, first_set=None, follow_set=None, sym_type="N"):
self.symbol = symbol
self.first_set = first_set
self.follow_set = follow_set
self.sym_type = sym_type
self.is_nullable = False
self.attr = {}
self.father = None
self.children = []
self.lexical_value = None
def __str__(self):
return (
self.symbol
+ " Derive_empty:"
+ str(self.is_nullable)
+ " First:"
+ str(self.first_set)
+ " Follow:"
+ str(self.follow_set)
)
def is_terminal(self):
return self.sym_type == "T"
class Entry(object):
def __init__(self, type, length, name):
self.type = type
self.length = length
self.name = name
def __str__(self):
return self.name + " " + self.type + " " + str(self.length)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化