diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-06-02 11:24:02 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-06-02 11:24:02 -0300 |
commit | cab8cf970c09ea465d30e11eb356e2e5d37dc544 (patch) | |
tree | 5d274c892e4d53f5e976ae8f6f58aba030785e02 /scripts/finddeclarations.pl | |
parent | 52a9a5b0b0c53a1481d901f39ed0d1e7e86c3853 (diff) | |
parent | 4aecb71b0e819aa84a430dacdab2146229c410a5 (diff) | |
download | rneovim-cab8cf970c09ea465d30e11eb356e2e5d37dc544.tar.gz rneovim-cab8cf970c09ea465d30e11eb356e2e5d37dc544.tar.bz2 rneovim-cab8cf970c09ea465d30e11eb356e2e5d37dc544.zip |
Merge pull request #710 'Automatically generate declarations'
Diffstat (limited to 'scripts/finddeclarations.pl')
-rwxr-xr-x | scripts/finddeclarations.pl | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/scripts/finddeclarations.pl b/scripts/finddeclarations.pl new file mode 100755 index 0000000000..1b1a57b9b7 --- /dev/null +++ b/scripts/finddeclarations.pl @@ -0,0 +1,50 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +if ($ARGV[0] eq '--help') { + print << "EOF"; +Usage: + + $0 definitions.c +EOF + exit; +} + +my ($cfname, $sfname, $gfname, $cpp) = @ARGV; + +my $F; + +open $F, "<", $cfname; + +my $text = join "", <$F>; + +close $F; + +my $s = qr/(?>\s*)/aso; +my $w = qr/(?>\w+)/aso; +my $argname = qr/$w(?:\[(?>\w+)\])?/aso; +my $type_regex = qr/(?:$w$s\**$s)+/aso; +my $arg_regex = qr/(?:$type_regex$s$argname)/aso; + +while ($text =~ / + (?<=\n) # Definition starts at the start of line + $type_regex # Return type + $s$w # Function name + $s\($s + (?: + $arg_regex(?:$s,$s$arg_regex)*+ + ($s,$s\.\.\.)? # varargs function + |void + )? + $s\) + (?:$s FUNC_ATTR_$w(?:\((?>[^)]*)\))?)*+ # Optional attributes + (?=$s;) # Ending semicolon + /axsogp) { + my $match = "${^MATCH}"; + my $s = "${^PREMATCH}"; + $s =~ s/[^\n]++//g; + my $line = 1 + length $s; + print "${cfname}:${line}: $match\n"; +} |