def test_calendars(self): with self.get_temp() as temp: railroad = to_railroad(calendars) temp.write(railroad_to_html(railroad)) if self.railroad_debug(): print(temp.name)
def test_json(self): with self.get_temp() as temp: railroad = to_railroad(jsonObject) temp.write(railroad_to_html(railroad)) if self.railroad_debug(): print(temp.name)
def test_sql(self): with self.get_temp() as temp: railroad = to_railroad(simpleSQL) temp.write(railroad_to_html(railroad)) if self.railroad_debug(): print(temp.name)
def test_bool_expr(self): with self.get_temp() as temp: railroad = to_railroad(boolExpr) temp.write(railroad_to_html(railroad)) if self.railroad_debug(): print(temp.name)
def test_bool_expr(self): with self.get_temp() as temp: railroad = to_railroad(boolExpr) assert len(railroad) == 3 temp.write(railroad_to_html(railroad)) if self.railroad_debug(): print("bool expr:" + temp.name)
def railroad(pos): try: from pyparsing.diagram import to_railroad, railroad_to_html parser = CliParser(pos) railroad = to_railroad(parser.flags) sys.stdout.write(railroad_to_html(railroad)) except ImportError: print("You need PyParsing 3.0.0a2 or greater to use this feature", file=sys.stderr) sys.exit(1)
def test_make_railroad_diagram(): # requires pyparsing==3.0.0b2 or newer, railroad-diagrams, and jinja2 from pyparsing.diagram import to_railroad, railroad_to_html from pathlib import Path p = MathParser() p.expr.setName('MathParser') rr = to_railroad(p.expr) Path('parser_math_diagram.html').write_text(railroad_to_html(rr))
def generate_railroad( self, expr: pp.ParserElement, label: str, show_results_names: bool = False ) -> List[NamedDiagram]: """ Generate an intermediate list of NamedDiagrams from a pyparsing expression. """ with self.get_temp() as temp: railroad = to_railroad(expr, show_results_names=show_results_names) temp.write(railroad_to_html(railroad)) if self.railroad_debug(): print(f"{label}: {temp.name}") return railroad
def make_diagram(expr): with open("output.html", "w", encoding="utf-8") as fp: railroad = to_railroad(expr) fp.write(railroad_to_html(railroad))
def create_railroad_diagram() -> None: expr = query_parser() # Creating railroad diagrams with open("../docs/query_parser_railroad.html", "w") as fp: railroad = to_railroad(expr) fp.write(railroad_to_html(railroad))