make-bytecode-docs.pl 1012 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/perl -w
  2. use strict;
  3. open MACHINE, "<" . $ARGV[0];
  4. open OUTPUT, ">" . $ARGV[1];
  5. my @undocumented = ();
  6. print OUTPUT "<!-- Generated from Interpreter.cpp by make-bytecode-docs.pl. -->\n";
  7. print OUTPUT "<style>p code \{ font-size: 14px; \}</style>\n";
  8. while (<MACHINE>) {
  9. if (/^ *DEFINE_OPCODE/) {
  10. chomp;
  11. s/^ *DEFINE_OPCODE\(op_//;
  12. s/\).*$//;
  13. my $opcode = $_;
  14. $_ = <MACHINE>;
  15. chomp;
  16. if (m|/\* |) {
  17. my $format = $_;
  18. $format =~ s|.* /\* ||;
  19. my $doc = "";
  20. while (<MACHINE>) {
  21. if (m|\*/|) {
  22. last;
  23. }
  24. $doc .= $_ . " ";
  25. }
  26. print OUTPUT "<h2><code>${opcode}</code></h2>\n<p><b>Format: </b><code>\n${format}\n</code></p>\n<p>\n${doc}\n</p>\n";
  27. } else {
  28. push @undocumented, $opcode;
  29. }
  30. }
  31. }
  32. close OUTPUT;
  33. for my $undoc (@undocumented) {
  34. print "UNDOCUMENTED: ${undoc}\n";
  35. }