import itertoolsdef generate_tokens(tokens):numbers = itertools.count(0)for line in tokens:line = line.strip()if not line:continueif line.strip().startswith('#'):continuename = line.split()[0]yield (name, next(numbers))yield ('N_TOKENS', next(numbers))yield ('NT_OFFSET', 256)def generate_opmap(tokens):for line in tokens:line = line.strip()if not line:continueif line.strip().startswith('#'):continuepieces = line.split()if len(pieces) != 2:continuename, op = piecesyield (op.strip("'"), name)# Yield independently <>. This is needed so it does not collide# with the token generation in "generate_tokens" because if this# symbol is included in Grammar/Tokens, it will collide with !=# as it has the same name (NOTEQUAL).yield ('<>', 'NOTEQUAL')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。