デフォルトアクション
ルールを書かないと「{ $_[1] }」と同じ
確認用のコード
%% input: #empty | input line ; line: '\n' { $_[1] } | x '\n' { print "$_[1]\n"; } | error '\n' { $_[0]->YYErrok } ; x: 'a' 'b' 'c' ; %% sub _Error { exists $_[0]->YYData->{ERRMSG} and do { print $_[0]->YYData->{ERRMSG}; delete $_[0]->YYData->{ERRMSG}; return; }; print "Syntax error.\n"; } sub _Lexer { my($parser)=shift; $parser->YYData->{INPUT} or $parser->YYData->{INPUT} = <STDIN> or return('',undef); $parser->YYData->{INPUT}=~s/^[ \t]//; for ($parser->YYData->{INPUT}) { s/^(.)//s and return($1,$1); } } sub Run { my($self)=shift; $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error ); } my($t)=new Test; $t->Run;
で、
abc a