Example #1
0
			string += '\n\t\t],\n'

		for k in self.set_required_pre:
			string += '\t\t"%s": [\n' %(dico[k + "Adjust"])  #ici
			for c in self.alphabet:
				fmt = '\t\t\t{ "read" : "%s", "to_state": "%s", "write": "%s", "action": "%s"},\n'
				string += fmt %(c, dico[k], c, 'RIGHT')  #ici
			string = string[:-2]
			string += '\n\t\t],\n'


		string = string[:-2]
		string += '\n\t}\n'
		string += "}\n"
		with open("lol.json", "w") as stream:
			stream.write(string)
		# print string


if __name__ == "__main__":
	tk = get_tokens()
	p = Prog(tk)
	print p.name
	print p.alphabet
	print p.blank
	print p.set_lb
	for st in p.lst_st:
		print str(st)
	resolve(p)
	p.tojson()
Example #2
0
            string = string[:-2]
            string += '\n\t\t],\n'

        for k in self.set_required_pre:
            string += '\t\t"%s": [\n' % (dico[k + "Adjust"])  #ici
            for c in self.alphabet:
                fmt = '\t\t\t{ "read" : "%s", "to_state": "%s", "write": "%s", "action": "%s"},\n'
                string += fmt % (c, dico[k], c, 'RIGHT')  #ici
            string = string[:-2]
            string += '\n\t\t],\n'

        string = string[:-2]
        string += '\n\t}\n'
        string += "}\n"
        with open("lol.json", "w") as stream:
            stream.write(string)
        # print string


if __name__ == "__main__":
    tk = get_tokens()
    p = Prog(tk)
    print p.name
    print p.alphabet
    print p.blank
    print p.set_lb
    for st in p.lst_st:
        print str(st)
    resolve(p)
    p.tojson()
Example #3
0
				string += fmt %(c, k, c, 'RIGHT')
			string = string[:-2]
			string += '\n\t\t],\n'


		string = string[:-2]
		string += '\n\t}\n'
		string += "}\n"
		with open(self.dstpath, "w") as stream:
			stream.write(string)
		print "Created file:", self.dstpath
		print


if __name__ == "__main__":

	for filepath in argv[1:]:
		print "Compiling file:", filepath
		if re.match(".*\.s$", filepath) == None:
			raise Exception("Bad input file extension");
		tk = get_tokens(filepath)
		p = Prog(filepath, tk)
		print "p.name", p.name
		print "p.alphabet", p.alphabet
		print "p.blank", p.blank
		# print p.set_lb
		# for st in p.lst_st:
		# 	print str(st)
		resolve(p)
		p.tojson()