# # Raw Game Engine # Copyright (C) 2023 Ernest Deak # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # use strict; use warnings FATAL => qw(all); my @files = @ARGV; for my $f(@files){ open my $fh, "<", $f or die "Failed to open file $f: $!"; my $curfunc = ""; my $nextfunc = 0; my $doc = ""; my $type = ""; my @params = (); my @return = (); print "File: $f\n\n"; while(<$fh>){ /^\s*section\s?(.*)/ and do { if($1 =~ /\.bss|\.data/){ $type = "Variable"; }elsif($1 =~ /\.text|\.code|code_section/){ $type = "Function"; }elsif($1 =~ /\.rodata|ro_section/){ $type = "Constant"; } }; /^\s*;;\s?(.*)/ and do { $nextfunc = 1; my $r = $1; chomp $r; $doc .= " ".$r . "\n"; if($r =~ /\@param(.*)/){ push @params, $1 } }; if($nextfunc){ if($_ =~ /^\%(?:macro|define|xdefine)\s(\S+)\s/){ $curfunc = $1; print "Macro: $curfunc\n$doc\n"; print "Params:\n".join("\n",@params)."\n\n"; $curfunc = ""; $nextfunc = 0; $doc = ""; @params=(); @return=(); } elsif($_ =~ /^(.+?):/){ $curfunc = $1; print "$type: $curfunc\n$doc\n"; print "Params:\n".join("\n",@params)."\n\n" if @params; $curfunc = ""; $nextfunc = 0; $doc = ""; @params=(); @return=(); } } } close $fh; } .