当前位置: 首页>>代码示例>>Python>>正文


Python Grammar.convertGtoAF方法代码示例

本文整理汇总了Python中grammar.Grammar.convertGtoAF方法的典型用法代码示例。如果您正苦于以下问题:Python Grammar.convertGtoAF方法的具体用法?Python Grammar.convertGtoAF怎么用?Python Grammar.convertGtoAF使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在grammar.Grammar的用法示例。


在下文中一共展示了Grammar.convertGtoAF方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: inicia

# 需要导入模块: from grammar import Grammar [as 别名]
# 或者: from grammar.Grammar import convertGtoAF [as 别名]
	def inicia(self):
		case = 0
		lex = Lex()

		# # 1 ER PALAVRAS RESERVADAS
		a1 = lex.lexer('reservado', case)
		dict = a1.getDictAutomato()
		case += len(dict)

		# # 2 ER IDENTIFICADORES
		a2 = lex.lexer('identificadores', case)

		# # 3 GRAMATICA DE SESPECIAL
		terminais = ['+', '-', '=', '/', '*', '>', '<', '!']
		nTerminais = ['S']
		producoes = {'S': ['+', '-', '=', '/', '*', '>', '<', '!']}
		inicial = 'S'
		g = Grammar(producoes,terminais, nTerminais, inicial)
		s, i, f = g.convertGtoAF()
		a3 = Automato(s, i, f)
		a3.determina()
		a3.printAtomato()
		print("\n")

		dict = a2.getDictAutomato()
		case += len(dict)
		a3 = lex.renameState(a3, case)

		# # 4 GRAMATICA SEPARADORES
		terminais2 = [':',';', ' ', '(', ')', '[', ']', ',', '\n']
		nTerminais2 = ['S']
		producoes2 = {'S': [':',';', ' ', '(', ')', '[', ']', ',', '\n']}
		inicial2 = 'S'
		g = Grammar(producoes2,terminais2, nTerminais2, inicial2)
		s2, i2, f2 = g.convertGtoAF()
		a4 = Automato(s2, i2, f2)
		a4.determina()
		a4.printAtomato()
		print("\n")

		dict = a3.getDictAutomato()
		case += len(dict)
		a4 = lex.renameState(a4, case)

		# ER CONSTANTES
		dict = a4.getDictAutomato()
		case += len(dict)
		a5 = lex.lexer('constantes', case)
		r = a5

		r = a1.oU([a2, a3, a4, a5])
		print ("\n")
		r.determina()
		r.printAtomato()

		with open('automato.pkl', 'wb') as output:
		    pickle.dump(r, output, pickle.HIGHEST_PROTOCOL)
开发者ID:lucasmpalma,项目名称:formais,代码行数:59,代码来源:automatoBD.py

示例2: gramaticaAutomato

# 需要导入模块: from grammar import Grammar [as 别名]
# 或者: from grammar.Grammar import convertGtoAF [as 别名]
def gramaticaAutomato(input):
    input = entrytext.get()
    l = LeitorG(input)
    dict, termi,nonter,ini = l.ler()
    g = Grammar(dict,termi,nonter,ini)
    s, inicial, final = g.convertGtoAF()
    a = Automato(s,inicial,final)
    a.printAtomato()
    a.writeAutomataToFile(input)

    input = input.replace('.in', '')
    data_file = open('../testes/'+input+'.out')
    data = data_file.read()
    data_file.close()
    test = Tk.Tk()
    Results = Tk.Label(test, text = data)
    Results.grid(row = 20, column = 3, sticky= Tk.W)
开发者ID:luizurias1,项目名称:formais,代码行数:19,代码来源:gui.py


注:本文中的grammar.Grammar.convertGtoAF方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。