From: Michael G. Schwern Date: Tue, 17 Aug 1999 18:35:45 +0000 (-0400) Subject: More descriptive names for operators. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=42d382189339e56f3bd13a71933349bc8b7e8b42;p=p5sagit%2Fp5-mst-13.2.git More descriptive names for operators. To: Ilya Zakharevich Cc: perl5-porters@perl.org Subject: Re: [ID 19990817.009] [BUG 5.005_60 & 5.005_03] == reported as eq in Date: Tue, 17 Aug 1999 18:35:45 -0400 Message-ID: <19990817183545.A23073@toldyouso.com> From: Michael G Schwern To: perl5-porters@perl.org Subject: [PATCH 5.005_60 opcode.pl and friends] Improved opcode descriptions Date: Wed, 18 Aug 1999 03:53:38 -0400 Message-ID: <19990818035337.A31505@athens.aocn.com> p4raw-id: //depot/cfgperl@4177 --- diff --git a/opcode.h b/opcode.h index 9527638..b754adf 100644 --- a/opcode.h +++ b/opcode.h @@ -397,18 +397,18 @@ EXT char *PL_op_desc[] = { "single ref constructor", "reference-type operator", "bless", - "backticks", + "quoted execution (``, qx)", "glob", "", "append I/O operator", "regexp comp once", "regexp reset interpolation flag", "regexp compilation", - "pattern match", - "pattern quote", - "substitution", + "pattern match (m//)", + "pattern quote (qr//)", + "substitution (s///)", "substitution cont", - "character translation", + "character translation (tr///)", "scalar assignment", "list assignment", "chop", @@ -419,58 +419,58 @@ EXT char *PL_op_desc[] = { "undef operator", "study", "match position", - "preincrement", - "integer preincrement", - "predecrement", - "integer predecrement", - "postincrement", - "integer postincrement", - "postdecrement", - "integer postdecrement", - "exponentiation", - "multiplication", - "integer multiplication", - "division", - "integer division", - "modulus", - "integer modulus", - "repeat", - "addition", - "integer addition", - "subtraction", - "integer subtraction", - "concatenation", + "preincrement (++)", + "integer preincrement (++)", + "predecrement (--)", + "integer predecrement (--)", + "postincrement (++)", + "integer postincrement (++)", + "postdecrement (--)", + "integer postdecrement (--)", + "exponentiation (**)", + "multiplication (*)", + "integer multiplication (*)", + "division (/)", + "integer division (/)", + "modulus (%)", + "integer modulus (%)", + "repeat (x)", + "addition (+)", + "integer addition (+)", + "subtraction (-)", + "integer subtraction (-)", + "concatenation (.)", "string", - "left bitshift", - "right bitshift", - "numeric lt", - "integer lt", - "numeric gt", - "integer gt", - "numeric le", - "integer le", - "numeric ge", - "integer ge", - "numeric eq", - "integer eq", - "numeric ne", - "integer ne", - "spaceship operator", - "integer spaceship", + "left bitshift (<<)", + "right bitshift (>>)", + "numeric lt (<)", + "integer lt (<)", + "numeric gt (>)", + "integer gt (>)", + "numeric le (<=)", + "integer le (<=)", + "numeric ge (>=)", + "integer ge (>=)", + "numeric eq (==)", + "integer eq (==)", + "numeric ne (!=)", + "integer ne (!=)", + "numeric comparison (<=>)", + "integer comparison (<=>)", "string lt", "string gt", "string le", "string ge", "string eq", "string ne", - "string comparison", - "bitwise and", - "bitwise xor", - "bitwise or", - "negate", - "integer negate", + "string comparison (cmp)", + "bitwise and (&)", + "bitwise xor (^)", + "bitwise or (|)", + "negate (-)", + "integer negate (-)", "not", - "1's complement", + "1's complement (~)", "atan2", "sin", "cos", @@ -493,11 +493,11 @@ EXT char *PL_op_desc[] = { "ord", "chr", "crypt", - "upper case first", - "lower case first", - "upper case", - "lower case", - "quote metachars", + "ucfirst", + "lcfirst", + "uc", + "lc", + "quotemeta", "array deref", "known array element", "array element", @@ -506,7 +506,7 @@ EXT char *PL_op_desc[] = { "values", "keys", "delete", - "exists operator", + "exists", "hash deref", "hash elem", "hash slice", @@ -516,8 +516,8 @@ EXT char *PL_op_desc[] = { "join", "list", "list slice", - "anonymous list", - "anonymous hash", + "anonymous list ([])", + "anonymous hash ({})", "splice", "push", "pop", @@ -532,12 +532,12 @@ EXT char *PL_op_desc[] = { "flipflop", "range (or flip)", "range (or flop)", - "logical and", - "logical or", + "logical and (&&)", + "logical or (||)", "logical xor", - "conditional expression", - "logical and assignment", - "logical or assignment", + "conditional operator (?:)", + "logical and assignment (&&=)", + "logical or assignment (||=)", "method lookup", "subroutine entry", "subroutine exit", @@ -684,9 +684,9 @@ EXT char *PL_op_desc[] = { "semop", "require", "do 'file'", - "eval string", + "eval \"string\"", "eval exit", - "eval block", + "eval {block}", "eval block exit", "gethostbyname", "gethostbyaddr", diff --git a/opcode.pl b/opcode.pl index 8eadbe7..ed458fa 100755 --- a/opcode.pl +++ b/opcode.pl @@ -88,7 +88,12 @@ EXT char *PL_op_desc[] = { END for (@ops) { - print qq(\t"$desc{$_}",\n); + my($safe_desc) = $desc{$_}; + + # Have to escape double quotes and escape characters. + $safe_desc =~ s/(^|[^\\])([\\"])/$1\\$2/g; + + print qq(\t"$safe_desc",\n); } print < ck_null t% @@ -360,14 +365,14 @@ rcatline append I/O operator ck_null t% # Bindable operators. -regcmaybe regexp comp once ck_fun s1 S +regcmaybe regexp comp once ck_fun s1 S regcreset regexp reset interpolation flag ck_fun s1 S -regcomp regexp compilation ck_null s| S -match pattern match ck_match d/ -qr pattern quote ck_match s/ -subst substitution ck_null dis/ S -substcont substitution cont ck_null dis| -trans character translation ck_null is" S +regcomp regexp compilation ck_null s| S +match pattern match (m//) ck_match d/ +qr pattern quote (qr//) ck_match s/ +subst substitution (s///) ck_null dis/ S +substcont substitution cont ck_null dis| +trans character translation (tr///) ck_null is" S # Lvalue operators. # sassign is special-cased for op class @@ -384,51 +389,51 @@ undef undef operator ck_lfun s% S? study study ck_fun su% S? pos match position ck_lfun stu% S? -preinc preincrement ck_lfun dIs1 S -i_preinc integer preincrement ck_lfun dis1 S -predec predecrement ck_lfun dIs1 S -i_predec integer predecrement ck_lfun dis1 S -postinc postincrement ck_lfun dIsT1 S -i_postinc integer postincrement ck_lfun disT1 S -postdec postdecrement ck_lfun dIsT1 S -i_postdec integer postdecrement ck_lfun disT1 S +preinc preincrement (++) ck_lfun dIs1 S +i_preinc integer preincrement (++) ck_lfun dis1 S +predec predecrement (--) ck_lfun dIs1 S +i_predec integer predecrement (--) ck_lfun dis1 S +postinc postincrement (++) ck_lfun dIsT1 S +i_postinc integer postincrement (++) ck_lfun disT1 S +postdec postdecrement (--) ck_lfun dIsT1 S +i_postdec integer postdecrement (--) ck_lfun disT1 S # Ordinary operators. -pow exponentiation ck_null fsT2 S S - -multiply multiplication ck_null IfsT2 S S -i_multiply integer multiplication ck_null ifsT2 S S -divide division ck_null IfsT2 S S -i_divide integer division ck_null ifsT2 S S -modulo modulus ck_null IifsT2 S S -i_modulo integer modulus ck_null ifsT2 S S -repeat repeat ck_repeat mt2 L S - -add addition ck_null IfsT2 S S -i_add integer addition ck_null ifsT2 S S -subtract subtraction ck_null IfsT2 S S -i_subtract integer subtraction ck_null ifsT2 S S -concat concatenation ck_concat fsT2 S S +pow exponentiation (**) ck_null fsT2 S S + +multiply multiplication (*) ck_null IfsT2 S S +i_multiply integer multiplication (*) ck_null ifsT2 S S +divide division (/) ck_null IfsT2 S S +i_divide integer division (/) ck_null ifsT2 S S +modulo modulus (%) ck_null IifsT2 S S +i_modulo integer modulus (%) ck_null ifsT2 S S +repeat repeat (x) ck_repeat mt2 L S + +add addition (+) ck_null IfsT2 S S +i_add integer addition (+) ck_null ifsT2 S S +subtract subtraction (-) ck_null IfsT2 S S +i_subtract integer subtraction (-) ck_null ifsT2 S S +concat concatenation (.) ck_concat fsT2 S S stringify string ck_fun fsT@ S -left_shift left bitshift ck_bitop fsT2 S S -right_shift right bitshift ck_bitop fsT2 S S - -lt numeric lt ck_null Iifs2 S S -i_lt integer lt ck_null ifs2 S S -gt numeric gt ck_null Iifs2 S S -i_gt integer gt ck_null ifs2 S S -le numeric le ck_null Iifs2 S S -i_le integer le ck_null ifs2 S S -ge numeric ge ck_null Iifs2 S S -i_ge integer ge ck_null ifs2 S S -eq numeric eq ck_null Iifs2 S S -i_eq integer eq ck_null ifs2 S S -ne numeric ne ck_null Iifs2 S S -i_ne integer ne ck_null ifs2 S S -ncmp spaceship operator ck_null Iifst2 S S -i_ncmp integer spaceship ck_null ifst2 S S +left_shift left bitshift (<<) ck_bitop fsT2 S S +right_shift right bitshift (>>) ck_bitop fsT2 S S + +lt numeric lt (<) ck_null Iifs2 S S +i_lt integer lt (<) ck_null ifs2 S S +gt numeric gt (>) ck_null Iifs2 S S +i_gt integer gt (>) ck_null ifs2 S S +le numeric le (<=) ck_null Iifs2 S S +i_le integer le (<=) ck_null ifs2 S S +ge numeric ge (>=) ck_null Iifs2 S S +i_ge integer ge (>=) ck_null ifs2 S S +eq numeric eq (==) ck_null Iifs2 S S +i_eq integer eq (==) ck_null ifs2 S S +ne numeric ne (!=) ck_null Iifs2 S S +i_ne integer ne (!=) ck_null ifs2 S S +ncmp numeric comparison (<=>) ck_null Iifst2 S S +i_ncmp integer comparison (<=>) ck_null ifst2 S S slt string lt ck_scmp ifs2 S S sgt string gt ck_scmp ifs2 S S @@ -436,27 +441,27 @@ sle string le ck_scmp ifs2 S S sge string ge ck_scmp ifs2 S S seq string eq ck_null ifs2 S S sne string ne ck_null ifs2 S S -scmp string comparison ck_scmp ifst2 S S +scmp string comparison (cmp) ck_scmp ifst2 S S -bit_and bitwise and ck_bitop fsT2 S S -bit_xor bitwise xor ck_bitop fsT2 S S -bit_or bitwise or ck_bitop fsT2 S S +bit_and bitwise and (&) ck_bitop fsT2 S S +bit_xor bitwise xor (^) ck_bitop fsT2 S S +bit_or bitwise or (|) ck_bitop fsT2 S S -negate negate ck_null IfsT1 S -i_negate integer negate ck_null ifsT1 S +negate negate (-) ck_null IfsT1 S +i_negate integer negate (-) ck_null ifsT1 S not not ck_null ifs1 S -complement 1's complement ck_bitop fsT1 S +complement 1's complement (~) ck_bitop fsT1 S # High falutin' math. -atan2 atan2 ck_fun fsT@ S S -sin sin ck_fun fsTu% S? -cos cos ck_fun fsTu% S? -rand rand ck_fun sT% S? -srand srand ck_fun s% S? -exp exp ck_fun fsTu% S? -log log ck_fun fsTu% S? -sqrt sqrt ck_fun fsTu% S? +atan2 atan2 ck_fun fsT@ S S +sin sin ck_fun fsTu% S? +cos cos ck_fun fsTu% S? +rand rand ck_fun sT% S? +srand srand ck_fun s% S? +exp exp ck_fun fsTu% S? +log log ck_fun fsTu% S? +sqrt sqrt ck_fun fsTu% S? # Lowbrow math. @@ -479,11 +484,11 @@ formline formline ck_fun ms@ S L ord ord ck_fun ifsTu% S? chr chr ck_fun fsTu% S? crypt crypt ck_fun fsT@ S S -ucfirst upper case first ck_fun_locale fstu% S? -lcfirst lower case first ck_fun_locale fstu% S? -uc upper case ck_fun_locale fstu% S? -lc lower case ck_fun_locale fstu% S? -quotemeta quote metachars ck_fun fsTu% S? +ucfirst ucfirst ck_fun_locale fstu% S? +lcfirst lcfirst ck_fun_locale fstu% S? +uc uc ck_fun_locale fstu% S? +lc lc ck_fun_locale fstu% S? +quotemeta quotemeta ck_fun fsTu% S? # Arrays. @@ -498,7 +503,7 @@ each each ck_fun % H values values ck_fun t% H keys keys ck_fun t% H delete delete ck_delete % S -exists exists operator ck_exists is% S +exists exists ck_exists is% S rv2hv hash deref ck_rvconst dt1 helem hash elem ck_null s2@ H S hslice hash slice ck_null m@ H L @@ -514,8 +519,8 @@ join join ck_join msT@ S L list list ck_null m@ L lslice list slice ck_null 2 H L L -anonlist anonymous list ck_fun ms@ L -anonhash anonymous hash ck_fun ms@ L +anonlist anonymous list ([]) ck_fun ms@ L +anonhash anonymous hash ({}) ck_fun ms@ L splice splice ck_fun m@ A S? S? L push push ck_fun imsT@ A L @@ -525,11 +530,11 @@ unshift unshift ck_fun imsT@ A L sort sort ck_sort m@ C? L reverse reverse ck_fun mt@ L -grepstart grep ck_grep dm@ C L -grepwhile grep iterator ck_null dt| +grepstart grep ck_grep dm@ C L +grepwhile grep iterator ck_null dt| -mapstart map ck_grep dm@ C L -mapwhile map iterator ck_null dt| +mapstart map ck_grep dm@ C L +mapwhile map iterator ck_null dt| # Range stuff. @@ -539,12 +544,12 @@ flop range (or flop) ck_null 1 # Control. -and logical and ck_null | -or logical or ck_null | +and logical and (&&) ck_null | +or logical or (||) ck_null | xor logical xor ck_null fs2 S S -cond_expr conditional expression ck_null d| -andassign logical and assignment ck_null s| -orassign logical or assignment ck_null s| +cond_expr conditional operator (?:) ck_null d| +andassign logical and assignment (&&=) ck_null s| +orassign logical or assignment (||=) ck_null s| method method lookup ck_method d1 entersub subroutine entry ck_subr dmt1 L @@ -743,10 +748,10 @@ semop semop ck_fun imst@ S S require require ck_require du% S? dofile do 'file' ck_fun d1 S -entereval eval string ck_eval d% S +entereval eval "string" ck_eval d% S leaveeval eval exit ck_null 1 S #evalonce eval constant string ck_null d1 S -entertry eval block ck_null | +entertry eval {block} ck_null | leavetry eval block exit ck_null @ # Get system info. diff --git a/sv.c b/sv.c index 4ba864c..6327ef0 100644 --- a/sv.c +++ b/sv.c @@ -1034,10 +1034,12 @@ S_not_a_number(pTHX_ SV *sv) *d = '\0'; if (PL_op) - Perl_warner(aTHX_ WARN_NUMERIC, "Argument \"%s\" isn't numeric in %s", tmpbuf, - PL_op_name[PL_op->op_type]); + Perl_warner(aTHX_ WARN_NUMERIC, + "Argument \"%s\" isn't numeric in %s", tmpbuf, + PL_op_desc[PL_op->op_type]); else - Perl_warner(aTHX_ WARN_NUMERIC, "Argument \"%s\" isn't numeric", tmpbuf); + Perl_warner(aTHX_ WARN_NUMERIC, + "Argument \"%s\" isn't numeric", tmpbuf); } /* the number can be converted to integer with atol() or atoll() */ diff --git a/t/op/misc.t b/t/op/misc.t index 926c7f3..f8a44ec 100755 --- a/t/op/misc.t +++ b/t/op/misc.t @@ -104,7 +104,7 @@ EXPECT ######## %@x=0; EXPECT -Can't modify hash deref in repeat at - line 1, near "0;" +Can't modify hash deref in repeat (x) at - line 1, near "0;" Execution of - aborted due to compilation errors. ######## $_="foo"; diff --git a/t/pragma/warn/op b/t/pragma/warn/op index e50420a..a726140 100644 --- a/t/pragma/warn/op +++ b/t/pragma/warn/op @@ -247,7 +247,7 @@ eval { getgrgid 1 }; # OP_GGRGID eval { getpwnam 1 }; # OP_GPWNAM eval { getpwuid 1 }; # OP_GPWUID EXPECT -Useless use of repeat in void context at - line 3. +Useless use of repeat (x) in void context at - line 3. Useless use of wantarray in void context at - line 5. Useless use of reference-type operator in void context at - line 12. Useless use of reference constructor in void context at - line 13. @@ -590,19 +590,19 @@ my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ; %$c =~ tr/a/b/ ; } EXPECT -Applying pattern match to @array will act on scalar(@array) at - line 5. -Applying substitution to @array will act on scalar(@array) at - line 6. -Can't modify private array in substitution at - line 6, near "s/a/b/ ;" -Applying character translation to @array will act on scalar(@array) at - line 7. -Applying pattern match to @array will act on scalar(@array) at - line 8. -Applying substitution to @array will act on scalar(@array) at - line 9. -Applying character translation to @array will act on scalar(@array) at - line 10. -Applying pattern match to %hash will act on scalar(%hash) at - line 11. -Applying substitution to %hash will act on scalar(%hash) at - line 12. -Applying character translation to %hash will act on scalar(%hash) at - line 13. -Applying pattern match to %hash will act on scalar(%hash) at - line 14. -Applying substitution to %hash will act on scalar(%hash) at - line 15. -Applying character translation to %hash will act on scalar(%hash) at - line 16. +Applying pattern match (m//) to @array will act on scalar(@array) at - line 5. +Applying substitution (s///) to @array will act on scalar(@array) at - line 6. +Can't modify private array in substitution (s///) at - line 6, near "s/a/b/ ;" +Applying character translation (tr///) to @array will act on scalar(@array) at - line 7. +Applying pattern match (m//) to @array will act on scalar(@array) at - line 8. +Applying substitution (s///) to @array will act on scalar(@array) at - line 9. +Applying character translation (tr///) to @array will act on scalar(@array) at - line 10. +Applying pattern match (m//) to %hash will act on scalar(%hash) at - line 11. +Applying substitution (s///) to %hash will act on scalar(%hash) at - line 12. +Applying character translation (tr///) to %hash will act on scalar(%hash) at - line 13. +Applying pattern match (m//) to %hash will act on scalar(%hash) at - line 14. +Applying substitution (s///) to %hash will act on scalar(%hash) at - line 15. +Applying character translation (tr///) to %hash will act on scalar(%hash) at - line 16. BEGIN not safe after errors--compilation aborted at - line 18. ######## # op.c @@ -627,7 +627,7 @@ print (ABC || 1) ; no warnings 'syntax' ; print (ABC || 1) ; EXPECT -Probable precedence problem on logical or at - line 3. +Probable precedence problem on logical or (||) at - line 3. ######## --FILE-- abc diff --git a/t/pragma/warn/sv b/t/pragma/warn/sv index 7af8fb1..c02ff01 100644 --- a/t/pragma/warn/sv +++ b/t/pragma/warn/sv @@ -189,7 +189,7 @@ my $b = 1 + $a; no warnings 'numeric' ; my $c = 1 + $a; EXPECT -Argument "def" isn't numeric in add at - line 6. +Argument "def" isn't numeric in addition (+) at - line 6. ######## # sv.c use warnings 'numeric' ; @@ -197,7 +197,7 @@ my $x = 1 + "def" ; no warnings 'numeric' ; my $z = 1 + "def" ; EXPECT -Argument "def" isn't numeric in add at - line 3. +Argument "def" isn't numeric in addition (+) at - line 3. ######## # sv.c use warnings 'numeric' ; @@ -206,7 +206,7 @@ my $x = 1 + $a ; no warnings 'numeric' ; my $y = 1 + $a ; EXPECT -Argument "def" isn't numeric in add at - line 4. +Argument "def" isn't numeric in addition (+) at - line 4. ######## # sv.c use warnings 'numeric' ; use integer ; @@ -215,7 +215,7 @@ my $x = 1 + $a ; no warnings 'numeric' ; my $z = 1 + $a ; EXPECT -Argument "def" isn't numeric in i_add at - line 4. +Argument "def" isn't numeric in integer addition (+) at - line 4. ######## # sv.c use warnings 'numeric' ; @@ -223,7 +223,7 @@ my $x = 1 & "def" ; no warnings 'numeric' ; my $z = 1 & "def" ; EXPECT -Argument "def" isn't numeric in bit_and at - line 3. +Argument "def" isn't numeric in bitwise and (&) at - line 3. ######## # sv.c use warnings 'redefine' ;