def draw_productions_to_png(self, options, filename): productions = self.get_productions() if len(productions) == 0: raise Exception("No named productions to generate") from parcon.railroad import raildraw as _raildraw _raildraw.draw_to_png(ordered_dict.OrderedDict([(k, Then(Bullet(), v.create_railroad(options), Bullet())) for k, v in productions.items()]), options, filename) del _raildraw
def draw_railroad_to_png(self, options, filename): """ Draws a syntax diagram for this object to the specified .png image file using the specified options. For now, just pass {} (i.e. an empty dictionary) as options; I'll document what this actually does at a later date. """ # raildraw /has/ to be imported here, not at the top of the module, # because it depends on us and circular dependency issues will arise # if the import is done at the top of this module from parcon.railroad import raildraw as _raildraw diagram = Then(Bullet(), self.create_railroad(options), Bullet()) _raildraw.draw_to_png(diagram, options, filename) del _raildraw
def draw_productions_to_png(self, options, filename, tail=[]): productions = self.get_productions() if len(productions) == 0: raise Exception("No named productions to generate") # Sort the specified tail productions to the end for name in tail: if name in productions: value = productions[name] del productions[name] productions[name] = value from parcon.railroad import raildraw as _raildraw _raildraw.draw_to_png(ordered_dict.OrderedDict([(k, Then(Bullet(), v.create_railroad(options), Bullet())) for k, v in productions.items()]), options, filename) del _raildraw
def draw_productions_to_png(self, options, filename, tail=[]): productions = self.get_productions() if len(productions) == 0: raise Exception("No named productions to generate") # Sort the specified tail productions to the end for name in tail: if name in productions: value = productions[name] del productions[name] productions[name] = value from parcon.railroad import raildraw as _raildraw _raildraw.draw_to_png( ordered_dict.OrderedDict([ (k, Then(Bullet(), v.create_railroad(options), Bullet())) for k, v in productions.items() ]), options, filename) del _raildraw
def main(): if len(sys.argv) == 2: out = sys.argv[1] elif len(sys.argv) == 1: out = os.curdir else: print >>sys.stderr, "Usage: %s [output directory]" % sys.argv[0] return -1 # Tweak options to hide the title we don't need. options = {"raildraw_title_hide": True, "raildraw_title_after": 0} # Dump each diagram as a PNG. for d in DIAGRAMS: path = os.path.join(out, "%s.png" % d.keys()[0]) draw_to_png(d, options, path, True) return 0
def main(): if len(sys.argv) == 2: out = sys.argv[1] elif len(sys.argv) == 1: out = os.curdir else: sys.stderr.write('Usage: %s [output directory]\n' % sys.argv[0]) return -1 # Tweak options to hide the title we don't need. options = { 'raildraw_title_hide':True, 'raildraw_title_after':0, } # Dump each diagram as a PNG. for d in DIAGRAMS: path = os.path.join(out, '%s.png' % list(d.keys())[0]) draw_to_png(d, options, path, True) return 0
def main(): if len(sys.argv) == 2: out = sys.argv[1] elif len(sys.argv) == 1: out = os.curdir else: sys.stderr.write('Usage: %s [output directory]\n' % sys.argv[0]) return -1 # Tweak options to hide the title we don't need. options = { 'raildraw_title_hide': True, 'raildraw_title_after': 0, } # Dump each diagram as a PNG. for d in DIAGRAMS: path = os.path.join(out, '%s.png' % list(d.keys())[0]) draw_to_png(d, options, path, True) return 0
Then( Bullet(), Or(text("@"), Nothing()), Or( text("null"), Then( production("<text literal>"), Or( Then(text(".."), Or(production("<text literal>"), Nothing())), Nothing())), Then(Or(text(".."), text(">"), text("<")), production("<text literal>")), Then(Or(text("%"), Nothing()), Loop(production("<text literal>"), text("%")), Or(text("%"), Nothing())), ), Bullet())), ]) options = { "raildraw_title_before": 20, "raildraw_title_after": 30, "raildraw_scale": 2 } i = 0 for pname in productions.keys(): i += 1 draw_to_png( OrderedDict([(pname, productions[pname])]), options, 'target/filter/' + ('0' if i < 10 else '') + str(i) + '.' + pname + '.png', True)