Beta Shell
v2.0 ยท web2.us.cloudlogin.co
[FM]
[CMD]
[PHP]
[DB]
[INFO]
[SEC]
File Manager
~
/
usr
/
share
/
perl5
/
vendor_perl
/
Inline
/
C
/
Parser
/
Pegex
Upload
4 items
Name
Size
Perms
Modified
Actions
[ .. / .. ]
AST.pm
1 KB
-rw-r--r--
2022-03-02 15:38:00
Edit
Del
Grammar.pm
3.34 KB
-rw-r--r--
2022-03-02 15:38:00
Edit
Del
Editing: AST.pm
(1 KB)
Path: /usr/share/perl5/vendor_perl/Inline/C/Parser/Pegex/AST.pm
Back
use strict; use warnings; package Inline::C::Parser::Pegex::AST; use Pegex::Base; extends 'Pegex::Tree'; has data => {}; sub initial { my ($self) = @_; my $data = { functions => [], function => {}, done => {}, }; $self->data($data); } sub final { my ($self, $got) = @_; return $self->{data}; } sub got_function_definition { my ($self, $ast) = @_; my ($rtype, $name, $args) = @$ast; my ($rname, $rstars) = @$rtype; my $data = $self->data; my $def = $data->{function}{$name} = {}; push @{$data->{functions}}, $name; $def->{return_type} = $rname . ($rstars ? " $rstars" : ''); $def->{arg_names} = []; $def->{arg_types} = []; for my $arg (@$args) { my ($type, $stars, $name) = @$arg; push @{$def->{arg_names}}, $name; push @{$def->{arg_types}}, $type . ($stars ? " $stars" : ''); } $data->{done}{$name} = 1; return; } sub got_arg { my ($self, $ast) = @_; pop @$ast; return $ast; } 1;