这是一个DFA简化和生成LL(1)分析表的程序,自动生成表格及图形

源代码在线查看: leftop.pm.tt.svn-base

软件大小: 892 K
上传用户: maige49
关键词: DFA LL 程序
下载地址: 免注册下载 普通下载 VIP

相关代码

				[% DEFAULT				    parent = "expression"				    child  = "term"				    op = 'yes'				    key = "__DIRECTIVE1__"				-%]				#: Kid/AST/[% parent %].pm - generated from [% template.name %]								package [% parent %];								use strict;				use warnings;				#use Data::Dumper::Simple;								sub [% parent %] {				    my $self = shift;				    if (!exists $self->{[% parent %]}) {				        my $rlist = $self->{'[% key %]'};				        return nil->new if not $rlist;				        my @[% child %]s = @$rlist;				        my $[% child %] = pop @[% child %]s;				    [%- IF op == 'yes' %]				        my $op = pop @[% child %]s;				    [%- END %]				        my $[% parent %];				        if (@[% child %]s) {				            $[% parent %] = bless {'[% key %]' => \@[% child %]s}, ref $self;				        } else {				            $[% parent %] = nil->new;				        }				        $self->{[% parent %]} = $[% parent %];				        $self->{[% child %]} = $[% child %];				    [%- IF op == 'yes' %]				        $self->{op} = $op;				    [%- END %]				        #delete $self->{'[% key %]'};				        #warn Dumper($self);				    }				    return $self->{[% parent %]};				}								sub [% child %] {				    my $self = shift;				    if (!exists $self->{[% child %]}) {				        $self->[% parent %];				    }				    if (@_) {				        $self->{[% child %]} = shift;				    } else {				        $self->{[% child %]} || nil->new;				    }				}								sub get_all {				    my $list = shift;				    my @elems;				    while (ref $list eq '[% parent %]') {				        unshift @elems, $list->[% child %];				        $list = $list->[% parent %];				    }				    @elems;				}								[%- IF op == 'yes' %]				sub op {				    my $self = shift;				    if (!exists $self->{op}) {				        $self->[% parent %];				    }				    if (@_) {				        $self->{op} = shift;				    } else {				        $self->{op};				    }				}				[%- END %]								1;							

相关资源