Unverified Commit b5cbab32 authored by Kevin Lyda's avatar Kevin Lyda
Browse files

Graph's a bit too big for mermaid though.

parent 83d9d261
Loading
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
#!/bin/bash

grep -E '^[^C].*(CALL|SUBROUTINE)' bulletin*.for \
  | sed 's/ *! .*//;s/:.*\(CALL\|SUBROUTINE\) / \1 /;s/(.*//' \
  | awk '
        BEGIN {
          e="flowchart LR"
        }
        {
          if ($1 != f) {
            print e;
            sg=$1; gsub(".for", "", sg);
            print "  subgraph " sg;
            print "    direction LR";
            e="  end";
          }
        }
        $2 == "SUBROUTINE" {
          f=$1; s=$3;
          print "    " s "(" s ")";
        }
        $2 == "CALL" {
          if ($1 != f) {
            f=$1; s="main";
            print "    " s "(" s ")";
          }
          print "    " s " --> " $3;
          
        }
        END {
          print e;
        }
        ' \
  | sed 's/\$/__/g'