diff options
| author | Pascal Rigaux <pixel@mandriva.com> | 2003-04-10 19:08:33 +0000 | 
|---|---|---|
| committer | Pascal Rigaux <pixel@mandriva.com> | 2003-04-10 19:08:33 +0000 | 
| commit | 46c3e5570a14d47c55c04f71c65ea9f01b806d76 (patch) | |
| tree | 175d6e09a26c700de6e221f5f511469596eec350 | |
| parent | 9dc403e0f6777f48eccc28d033b32881df57c521 (diff) | |
| download | perl-MDK-Common-46c3e5570a14d47c55c04f71c65ea9f01b806d76.tar perl-MDK-Common-46c3e5570a14d47c55c04f71c65ea9f01b806d76.tar.gz perl-MDK-Common-46c3e5570a14d47c55c04f71c65ea9f01b806d76.tar.bz2 perl-MDK-Common-46c3e5570a14d47c55c04f71c65ea9f01b806d76.tar.xz perl-MDK-Common-46c3e5570a14d47c55c04f71c65ea9f01b806d76.zip | |
correctly (in Perl way) handle priority for some special unary functions (length, exists, ref)
| -rw-r--r-- | perl_checker.src/lexer.mll | 5 | ||||
| -rw-r--r-- | perl_checker.src/parser.mly | 18 | ||||
| -rw-r--r-- | perl_checker.src/parser_helper.ml | 9 | 
3 files changed, 15 insertions, 17 deletions
| diff --git a/perl_checker.src/lexer.mll b/perl_checker.src/lexer.mll index 9f230a4..aef34a8 100644 --- a/perl_checker.src/lexer.mll +++ b/perl_checker.src/lexer.mll @@ -431,7 +431,10 @@ rule token = parse  | "printf"   { PRINT(lexeme lexbuf, pos lexbuf) }  | "new"      { NEW(pos lexbuf) }  | "format"   { let _ = raw_here_doc_next_line "." in FORMAT(pos lexbuf) } -| "defined"  { ONE_SCALAR_PARA(lexeme lexbuf, pos lexbuf) } +| "defined" +| "length"  +| "exists"  +| "ref"      { ONE_SCALAR_PARA(lexeme lexbuf, pos lexbuf) }  | "split"  | "grep"  { (* ok_for_match! *) BAREWORD(lexeme lexbuf, pos lexbuf) } diff --git a/perl_checker.src/parser.mly b/perl_checker.src/parser.mly index 86856ec..8340feb 100644 --- a/perl_checker.src/parser.mly +++ b/perl_checker.src/parser.mly @@ -261,14 +261,6 @@ term:  | term DECR    {sp_0($2); to_Call_op_(P_tight, "-- post", [sndfst $1]) (sp_pos_range $1 $2)}  | NOT argexpr  {warn_rule "don't use \"not\", use \"!\" instead"; to_Call_op_(P_and, "not", sndfst $2) (sp_pos_range $1 $2)} -| ONE_SCALAR_PARA RAW_STRING               {call_one_scalar_para $1 [to_Raw_string $2], sp_pos_range $1 $2} -| ONE_SCALAR_PARA STRING                   {call_one_scalar_para $1 [to_String true $2], sp_pos_range $1 $2} -| ONE_SCALAR_PARA variable                 {call_one_scalar_para $1 [fst $2], sp_pos_range $1 $2} -| ONE_SCALAR_PARA restricted_subscripted   {call_one_scalar_para $1 [fst $2], sp_pos_range $1 $2} -| ONE_SCALAR_PARA parenthesized            {call_one_scalar_para $1 (sndfst $2), sp_pos_range $1 $2} -| ONE_SCALAR_PARA word_paren parenthesized {call_one_scalar_para $1 [call(Deref(I_func, fst $2), sndfst $3)], sp_pos_range $1 $3} -| ONE_SCALAR_PARA {call_one_scalar_para $1 [], snd $1} -  /* Constructors for anonymous data */  | ARRAYREF ARRAYREF_END {sp_0($2); (P_expr, Ref(I_array, List[])), sp_pos_range $1 $2} @@ -296,8 +288,16 @@ term:  | array arrayref {(P_expr, to_Deref_with(I_array, I_array, from_array $1, List(fst $2))), sp_pos_range $1 $2} /* array slice: @array[vals] */  | array BRACKET expr BRACKET_END {sp_0($2); sp_0($3); sp_0($4); (P_expr, to_Deref_with(I_hash, I_array, from_array $1, sndfst $3)), sp_pos_range $1 $4} /* hash slice: @hash{@keys} */ -  /* function_calls */ +| ONE_SCALAR_PARA RAW_STRING               {call_one_scalar_para $1 [to_Raw_string $2], sp_pos_range $1 $2} +| ONE_SCALAR_PARA STRING                   {call_one_scalar_para $1 [to_String true $2], sp_pos_range $1 $2} +| ONE_SCALAR_PARA variable                 {call_one_scalar_para $1 [fst $2], sp_pos_range $1 $2} +| ONE_SCALAR_PARA restricted_subscripted   {call_one_scalar_para $1 [fst $2], sp_pos_range $1 $2} +| ONE_SCALAR_PARA parenthesized            {call_one_scalar_para $1 (sndfst $2), sp_pos_range $1 $2} +| ONE_SCALAR_PARA word_paren parenthesized {call_one_scalar_para $1 [call(Deref(I_func, fst $2), sndfst $3)], sp_pos_range $1 $3} +| ONE_SCALAR_PARA {call_one_scalar_para $1 [], snd $1} +| ONE_SCALAR_PARA word argexpr {check_parenthesized_first_argexpr_with_Ident (fst $2) $3; call_one_scalar_para $1 [call(Deref(I_func, fst $2), sndfst $3)], sp_pos_range $1 $3} /* ref foo $a, $b */ +  | func parenthesized {sp_0($2); (P_tok, call_func true (fst $1, sndfst $2)), sp_pos_range $1 $2} /* &foo(@args) */  | word argexpr {check_parenthesized_first_argexpr_with_Ident (fst $1) $2; (P_call_no_paren, call(Deref(I_func, fst $1), sndfst $2)), sp_pos_range $1 $2} /* foo $a, $b */  | word_paren parenthesized {sp_0($2); (P_tok, call(Deref(I_func, fst $1), sndfst $2)), sp_pos_range $1 $2} /* foo(@args) */ diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml index 0c817ad..9b5269f 100644 --- a/perl_checker.src/parser_helper.ml +++ b/perl_checker.src/parser_helper.ml @@ -723,16 +723,11 @@ let call_one_scalar_para (e, (_, pos)) para =    let para =      match para with      | [] -> -	  warn_rule (sprintf "please use \"%s $_\" instead of \"%s\"" e e) ; +	  if not (List.mem e [ "length" ]) then warn_rule (sprintf "please use \"%s $_\" instead of \"%s\"" e e) ;  	  [var_dollar_ (raw_pos2pos pos)]      | _ -> para    in -  let pri = -    match e with -    | "defined" -> P_expr -    | _ -> P_add -  in -  pri, call(Deref(I_func, Ident(None, e, raw_pos2pos pos)), para) +  P_mul, call(Deref(I_func, Ident(None, e, raw_pos2pos pos)), para)  let call_op_if_infix left right (sp, pos) = | 
