我正在尝试使用子例程将一行转换为a, f_1(b, c, f_2(d, e))
带有 lisp 样式函数调用的行
:a (f_1 b c (f_2 d e))
Text::Balanced
函数调用的形式为 f(arglist)
, arglist 中可以有一个或多个函数调用,也可以有层次调用;
我尝试的方式 -
my $text = q|a, f_1(a, b, f_2(c, d))|;
my ($match, $remainder) = extract_bracketed($text); # defaults to '()'
# $match is not containing the text i want which is : a, b, f_2(c,d) because "(" is preceded by a string;
my ($d_match, $d_remainder) = extract_delimited($remainder,",");
# $d_match doesnt contain the the first string
# planning to use remainder texts from the bracketed and delimited operations in a loop to translate.
甚至尝试了 sub extract_tagged with start tag as/^[\w_0-9]+\(/
和 end tag as /\)/
,但在那里也不起作用。
Parse::RecDescent
很难在短时间内理解和使用。