📄 idl.pm
字号:
GOTOS => { 'array_len' => 206 } }, {#State 205 DEFAULT => -25 }, {#State 206 DEFAULT => -71 }], yyrules =>[ [#Rule 0 '$start', 2, undef ], [#Rule 1 'idl', 0, undef ], [#Rule 2 'idl', 2,sub#line 19 "pidl/idl.yp"{ push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 3 'idl', 2,sub#line 20 "pidl/idl.yp"{ push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 4 'idl', 2,sub#line 21 "pidl/idl.yp"{ push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 5 'idl', 2,sub#line 22 "pidl/idl.yp"{ push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 6 'idl', 2,sub#line 23 "pidl/idl.yp"{ push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 7 'idl', 2,sub#line 24 "pidl/idl.yp"{ push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 8 'import', 3,sub#line 27 "pidl/idl.yp"{{ "TYPE" => "IMPORT", "PATHS" => $_[2], "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE} }} ], [#Rule 9 'include', 3,sub#line 34 "pidl/idl.yp"{{ "TYPE" => "INCLUDE", "PATHS" => $_[2], "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE} }} ], [#Rule 10 'importlib', 3,sub#line 41 "pidl/idl.yp"{{ "TYPE" => "IMPORTLIB", "PATHS" => $_[2], "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE} }} ], [#Rule 11 'commalist', 1,sub#line 50 "pidl/idl.yp"{ [ $_[1] ] } ], [#Rule 12 'commalist', 3,sub#line 51 "pidl/idl.yp"{ push(@{$_[1]}, $_[3]); $_[1] } ], [#Rule 13 'coclass', 7,sub#line 55 "pidl/idl.yp"{{ "TYPE" => "COCLASS", "PROPERTIES" => $_[1], "NAME" => $_[3], "DATA" => $_[5], "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ], [#Rule 14 'interface_names', 0, undef ], [#Rule 15 'interface_names', 4,sub#line 67 "pidl/idl.yp"{ push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 16 'interface', 7,sub#line 71 "pidl/idl.yp"{{ "TYPE" => "INTERFACE", "PROPERTIES" => $_[1], "NAME" => $_[3], "DATA" => $_[5], "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ], [#Rule 17 'cpp_quote', 4,sub#line 82 "pidl/idl.yp"{{ "TYPE" => "CPP_QUOTE", "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, "DATA" => $_[3] }} ], [#Rule 18 'definitions', 1,sub#line 91 "pidl/idl.yp"{ [ $_[1] ] } ], [#Rule 19 'definitions', 2,sub#line 92 "pidl/idl.yp"{ push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 20 'definition', 1, undef ], [#Rule 21 'definition', 1, undef ], [#Rule 22 'definition', 1, undef ], [#Rule 23 'definition', 1, undef ], [#Rule 24 'const', 7,sub#line 100 "pidl/idl.yp"{{ "TYPE" => "CONST", "DTYPE" => $_[2], "POINTERS" => $_[3], "NAME" => $_[4], "VALUE" => $_[6], "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ], [#Rule 25 'const', 8,sub#line 110 "pidl/idl.yp"{{ "TYPE" => "CONST", "DTYPE" => $_[2], "POINTERS" => $_[3], "NAME" => $_[4], "ARRAY_LEN" => $_[5], "VALUE" => $_[7], "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ], [#Rule 26 'function', 7,sub#line 124 "pidl/idl.yp"{{ "TYPE" => "FUNCTION", "NAME" => $_[3], "RETURN_TYPE" => $_[2], "PROPERTIES" => $_[1], "ELEMENTS" => $_[5], "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ], [#Rule 27 'typedef', 6,sub#line 136 "pidl/idl.yp"{{ "TYPE" => "TYPEDEF", "PROPERTIES" => $_[1], "NAME" => $_[4], "DATA" => $_[3], "ARRAY_LEN" => $_[5], "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ], [#Rule 28 'usertype', 1, undef ], [#Rule 29 'usertype', 1, undef ], [#Rule 30 'usertype', 1, undef ], [#Rule 31 'usertype', 1, undef ], [#Rule 32 'typedecl', 2,sub#line 149 "pidl/idl.yp"{ $_[1] } ], [#Rule 33 'sign', 1, undef ], [#Rule 34 'sign', 1, undef ], [#Rule 35 'existingtype', 2,sub#line 154 "pidl/idl.yp"{ ($_[1]?$_[1]:"signed") ." $_[2]" } ], [#Rule 36 'existingtype', 1, undef ], [#Rule 37 'type', 1, undef ], [#Rule 38 'type', 1, undef ], [#Rule 39 'type', 1,sub#line 158 "pidl/idl.yp"{ "void" } ], [#Rule 40 'enum_body', 3,sub#line 160 "pidl/idl.yp"{ $_[2] } ], [#Rule 41 'opt_enum_body', 0, undef ], [#Rule 42 'opt_enum_body', 1, undef ], [#Rule 43 'enum', 4,sub#line 163 "pidl/idl.yp"{{ "TYPE" => "ENUM", "PROPERTIES" => $_[1], "NAME" => $_[3], "ELEMENTS" => $_[4] }} ], [#Rule 44 'enum_elements', 1,sub#line 172 "pidl/idl.yp"{ [ $_[1] ] } ], [#Rule 45 'enum_elements', 3,sub#line 173 "pidl/idl.yp"{ push(@{$_[1]}, $_[3]); $_[1] } ], [#Rule 46 'enum_element', 1, undef ], [#Rule 47 'enum_element', 3,sub#line 177 "pidl/idl.yp"{ "$_[1]$_[2]$_[3]" } ], [#Rule 48 'bitmap_body', 3,sub#line 180 "pidl/idl.yp"{ $_[2] } ], [#Rule 49 'opt_bitmap_body', 0, undef ], [#Rule 50 'opt_bitmap_body', 1, undef ], [#Rule 51 'bitmap', 4,sub#line 183 "pidl/idl.yp"{{ "TYPE" => "BITMAP", "PROPERTIES" => $_[1], "NAME" => $_[3], "ELEMENTS" => $_[4] }} ], [#Rule 52 'bitmap_elements', 1,sub#line 192 "pidl/idl.yp"{ [ $_[1] ] } ], [#Rule 53 'bitmap_elements', 3,sub#line 193 "pidl/idl.yp"{ push(@{$_[1]}, $_[3]); $_[1] } ], [#Rule 54 'opt_bitmap_elements', 0, undef ], [#Rule 55 'opt_bitmap_elements', 1, undef ], [#Rule 56 'bitmap_element', 3,sub#line 198 "pidl/idl.yp"{ "$_[1] ( $_[3] )" } ], [#Rule 57 'struct_body', 3,sub#line 201 "pidl/idl.yp"{ $_[2] } ], [#Rule 58 'opt_struct_body', 0, undef ], [#Rule 59 'opt_struct_body', 1, undef ], [#Rule 60 'struct', 4,sub#line 205 "pidl/idl.yp"{{ "TYPE" => "STRUCT", "PROPERTIES" => $_[1], "NAME" => $_[3], "ELEMENTS" => $_[4] }} ], [#Rule 61 'empty_element', 2,sub#line 214 "pidl/idl.yp"{{ "NAME" => "", "TYPE" => "EMPTY", "PROPERTIES" => $_[1], "POINTERS" => 0, "ARRAY_LEN" => [], "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ], [#Rule 62 'base_or_empty', 2, undef ], [#Rule 63 'base_or_empty', 1, undef ], [#Rule 64 'optional_base_element', 2,sub#line 228 "pidl/idl.yp"{ $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] } ], [#Rule 65 'union_elements', 0, undef ], [#Rule 66 'union_elements', 2,sub#line 233 "pidl/idl.yp"{ push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 67 'union_body', 3,sub#line 236 "pidl/idl.yp"{ $_[2] } ], [#Rule 68 'opt_union_body', 0, undef ], [#Rule 69 'opt_union_body', 1, undef ], [#Rule 70 'union', 4,sub#line 240 "pidl/idl.yp"{{ "TYPE" => "UNION", "PROPERTIES" => $_[1], "NAME" => $_[3], "ELEMENTS" => $_[4] }} ], [#Rule 71 'base_element', 5,sub#line 249 "pidl/idl.yp"{{ "NAME" => $_[4], "TYPE" => $_[2], "PROPERTIES" => $_[1], "POINTERS" => $_[3], "ARRAY_LEN" => $_[5], "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ], [#Rule 72 'pointers', 0,sub#line 263 "pidl/idl.yp"{ 0 } ], [#Rule 73 'pointers', 2,sub#line 264 "pidl/idl.yp"{ $_[1]+1 } ], [#Rule 74 'element_list1', 0,sub#line 268 "pidl/idl.yp"{ [] } ], [#Rule 75 'element_list1', 3,sub#line 269 "pidl/idl.yp"{ push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 76 'element_list2', 0, undef ], [#Rule 77 'element_list2', 1, undef ], [#Rule 78 'element_list2', 1,sub#line 275 "pidl/idl.yp"{ [ $_[1] ] } ], [#Rule 79 'element_list2', 3,sub#line 276 "pidl/idl.yp"{ push(@{$_[1]}, $_[3]); $_[1] } ], [#Rule 80 'array_len', 0, undef ], [#Rule 81 'array_len', 3,sub#line 281 "pidl/idl.yp"{ push(@{$_[3]}, "*"); $_[3] } ], [#Rule 82 'array_len', 4,sub#line 282 "pidl/idl.yp"{ push(@{$_[4]}, "$_[2]"); $_[4] } ], [#Rule 83 'property_list', 0, undef ], [#Rule 84 'property_list', 4,sub#line 288 "pidl/idl.yp"{ FlattenHash([$_[1],$_[3]]); } ], [#Rule 85 'properties', 1,sub#line 291 "pidl/idl.yp"{ $_[1] } ], [#Rule 86 'properties', 3,sub#line 292 "pidl/idl.yp"{ FlattenHash([$_[1], $_[3]]); } ], [#Rule 87 'property', 1,sub#line 295 "pidl/idl.yp"{{ "$_[1]" => "1" }} ], [#Rule 88 'property', 4,sub#line 296 "pidl/idl.yp"{{ "$_[1]" => "$_[3]" }} ], [#Rule 89 'commalisttext', 1, undef ], [#Rule 90 'commalisttext', 3,sub#line 301 "pidl/idl.yp"{ "$_[1],$_[3]" } ], [#Rule 91 'anytext', 0,sub#line 305 "pidl/idl.yp"{ "" } ], [#Rule 92 'anytext', 1, undef ], [#Rule 93 'anytext', 1, undef ], [#Rule 94 'anytext', 1, undef ], [#Rule 95 'anytext', 3,sub#line 307 "pidl/idl.yp"{ "$_[1]$_[2]$_[3]" } ], [#Rule 96 'anytext', 3,sub#line 308 "pidl/idl.yp"{ "$_[1]$_[2]$_[3]" } ], [#Rule 97 'anytext', 3,sub#line 309 "pidl/idl.yp"{ "$_[1]$_[2]$_[3]" } ], [#Rule 98 'anytext', 3,sub#line 310 "pidl/idl.yp"{ "$_[1]$_[2]$_[3]" } ], [#Rule 99 'anytext', 3,sub#line 311 "pidl/idl.yp"{ "$_[1]$_[2]$_[3]" } ], [#Rule 100 'anytext', 3,sub#line 312 "pidl/idl.yp"{ "$_[1]$_[2]$_[3]" } ], [#Rule 101 'anytext', 3,sub#line 313 "pidl/idl.yp"{ "$_[1]$_[2]$_[3]" } ], [#Rule 102 'anytext', 3,sub#line 314 "pidl/idl.yp"{ "$_[1]$_[2]$_[3]" } ], [#Rule 103 'anytext', 3,sub#line 315 "pidl/idl.yp"{ "$_[1]$_[2]$_[3]" } ], [#Rule 104 'anytext', 3,sub#line 316 "pidl/idl.yp"{ "$_[1]$_[2]$_[3]" } ], [#Rule 105 'anytext', 3,sub#line 317 "pidl/idl.yp"{ "$_[1]$_[2]$_[3]" } ], [#Rule 106 'anytext', 3,sub#line 318 "pidl/idl.yp"{ "$_[1]$_[2]$_[3]" } ], [#Rule 107 'anytext', 3,sub#line 319 "pidl/idl.yp"{ "$_[1]$_[2]$_[3]" } ], [#Rule 108 'anytext', 5,sub#line 320 "pidl/idl.yp"{ "$_[1]$_[2]$_[3]$_[4]$_[5]" } ], [#Rule 109 'anytext', 5,sub#line 321 "pidl/idl.yp"{ "$_[1]$_[2]$_[3]$_[4]$_[5]" } ], [#Rule 110 'identifier', 1, undef ], [#Rule 111 'optional_identifier', 1, undef ], [#Rule 112 'optional_identifier', 0, undef ], [#Rule 113 'constant', 1, undef ], [#Rule 114 'text', 1,sub#line 335 "pidl/idl.yp"{ "\"$_[1]\"" } ], [#Rule 115 'optional_semicolon', 0, undef ], [#Rule 116 'optional_semicolon', 1, undef ]], @_); bless($self,$class);}#line 346 "pidl/idl.yp"use Parse::Pidl qw(error);###################################################################### flatten an array of hashes into a single hashsub FlattenHash($) { my $a = shift; my %b; for my $d (@{$a}) { for my $k (keys %{$d}) { $b{$k} = $d->{$k}; } } return \%b;}###################################################################### traverse a perl data structure removing any empty arrays or# hashes and any hash elements that map to undefsub CleanData($){ sub CleanData($); my($v) = shift; return undef if (not defined($v)); if (ref($v) eq "ARRAY") { foreach my $i (0 .. $#{$v}) { CleanData($v->[$i]); } # this removes any undefined elements from the array @{$v} = grep { defined $_ } @{$v}; } elsif (ref($v) eq "HASH") { foreach my $x (keys %{$v}) { CleanData($v->{$x}); if (!defined $v->{$x}) { delete($v->{$x}); next; } } } return $v;}sub _Error { if (exists $_[0]->YYData->{ERRMSG}) { error($_[0]->YYData, $_[0]->YYData->{ERRMSG}); delete $_[0]->YYData->{ERRMSG}; return; } my $last_token = $_[0]->YYData->{LAST_TOKEN}; error($_[0]->YYData, "Syntax error near '$last_token'");}sub _Lexer($){ my($parser)=shift; $parser->YYData->{INPUT} or return('',undef);again: $parser->YYData->{INPUT} =~ s/^[ \t]*//; for ($parser->YYData->{INPUT}) { if (/^\#/) { if (s/^\# (\d+) \"(.*?)\"( \d+|)//) { $parser->YYData->{LINE} = $1-1; $parser->YYData->{FILE} = $2; goto again; } if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) { $parser->YYData->{LINE} = $1-1; $parser->YYData->{FILE} = $2; goto again; } if (s/^(\#.*)$//m) { goto again; } } if (s/^(\n)//) { $parser->YYData->{LINE}++; goto again; } if (s/^\"(.*?)\"//) { $parser->YYData->{LAST_TOKEN} = $1; return('TEXT',$1); } if (s/^(\d+)(\W|$)/$2/) { $parser->YYData->{LAST_TOKEN} = $1; return('CONSTANT',$1); } if (s/^([\w_]+)//) { $parser->YYData->{LAST_TOKEN} = $1; if ($1 =~ /^(coclass|interface|const|typedef|union|cpp_quote |struct|enum|bitmap|void|unsigned|signed|import|include |importlib)$/x) { return $1; } return('IDENTIFIER',$1); } if (s/^(.)//s) { $parser->YYData->{LAST_TOKEN} = $1; return($1,$1); } }}sub parse_string{ my ($data,$filename) = @_; my $self = new Parse::Pidl::IDL; $self->YYData->{FILE} = $filename; $self->YYData->{INPUT} = $data; $self->YYData->{LINE} = 0; $self->YYData->{LAST_TOKEN} = "NONE"; my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error ); return CleanData($idl);}sub parse_file($$){ my ($filename,$incdirs) = @_; my $saved_delim = $/; undef $/; my $cpp = $ENV{CPP}; if (! defined $cpp) { $cpp = "cpp"; } my $includes = join('',map { " -I$_" } @$incdirs); my $data = `$cpp -D__PIDL__$includes -xc $filename`; $/ = $saved_delim; return parse_string($data, $filename);}1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -