logo       

Re: [jruby-user] What does nested repeat operator + and ? was replaced with: msg#00209

lang.jruby.user

Subject: Re: [jruby-user] What does nested repeat operator + and ? was replaced with '*' mean?

Hi,

It's a warning issued when Oniguruma finds nested quantifier within a quantifier (not an enclose) and the quantifies are not quantified by ranges:

if (!isByNumber() && !qnt.isByNumber() && env.syntax.warnReduntantNestedRepeat()) { ...

for example:

/(?:a+)?/ ( which is equivalent to: /(:?a)*/ )

then it does:

QuantifierNode qnt = (QuantifierNode)target;
int nestQNum = popularNum();
int targetQNum = qnt.popularNum();

where popular number is a number assigned to different types of quantifiers:
from Oniguruma comment: ?:0, *:1, +:2, ??:3, *?:4, +?:5

so nested (+) is 2:
nesting (?) is 0:

then the following reduction table is used:

enum ReduceType {
ASIS, /* as is */
DEL, /* delete parent */
A, /* to '*' */
AQ, /* to '*?' */
QQ, /* to '??' */
P_QQ, /* to '+)??' */
PQ_Q, /* to '+?)?' */
}

final ReduceType[][]REDUCE_TABLE = {
{DEL, A, A, QQ, AQ, ASIS}, /* '?' */
{DEL, DEL, DEL, P_QQ, P_QQ, DEL}, /* '*' */
{A, A, DEL, ASIS, P_QQ, DEL}, /* '+' */
{DEL, AQ, AQ, DEL, AQ, AQ}, /* '??' */
{DEL, DEL, DEL, DEL, DEL, DEL}, /* '*?' */
{ASIS, PQ_Q, DEL, AQ, AQ, DEL} /* '+?' */ };

so: ReduceType[2, 0] == A (the asterisk)

the implementation for this case is:

case A:
setTarget(other.target); // steal the nested target's target
// and set * characteristics
lower = 0;
upper = REPEAT_INFINITE;
greedy = true;
break;

The other thing is that 1.9 has this warning turned off by default (which we also should have, will fix that)

lopex



James Moore wrote:
Tried to run the tests for my rails app using trunk jruby (r5081), and
I'm getting these error messages:

run test/unit/asterisk_call_file_test.rb
/home/james/jruby/lib/ruby/gems/1.8/gems/actionpack-1.99.0.8178/lib/action_view/helpers/text_helper.rb:425
warning:
( # leading text
<\w+.*?>| # leading HTML tag, or
[^=!:'"/]| # leading punctuation, or
^ # beginning of line
)
(
(?:https?://)| # protocol spec, or
(?:www\.) # www.*
)
(
[-\w]+ # subdomain or domain
(?:\.[-\w]+)* # remaining
subdomains or domain
(?::\d+)? # port
(?:/(?:(?:[~\w\+@%-]|(?:[,.;:][^\s$]))+)?)* # path
(?:\?[\w\+@%&=.;-]+)? # query string
(?:\#[\w\-]*)? # trailing anchor
)
([[:punct:]]|\s|<|$) # trailing text
nested repeat operator + and ? was replaced with '*'


I'm not sure what that error message means (and I'm definitely sure I
don't want to understand that regex...).



---------------------------------------------------------------------
To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise