Debian Codegraph @

test/parse1.awk

raw
1 # Date: Fri, 06 Jan 2006 14:02:17 -0800
2 # From: Paul Eggert <[email protected]>
3 # Subject: gawk misparses $expr++ if expr ends in ++
4 # To: [email protected]
5 # Message-id: <[email protected]>
6 #
7 # Here's an example of the problem:
8 #
9 # $ gawk 'BEGIN{a=3}{print $$a++++}'
10 # gawk: {print $$a++++}
11 # gawk: ^ syntax error
12 #
13 # But it's not a syntax error, as the expression conforms to the POSIX
14 # spec: it should be treated like '$($a++)++'.
15 #
16 # Mawk, Solaris awk (old awk), and Solaris nawk all accept the
17 # expression. For example:
18 #
19 # $ echo '3 4 5 6 7 8 9' | nawk 'BEGIN{a=3}{print $$a++++}'
20 # 7
21 #
22 # This is with gawk 3.1.5 on Solaris 8 (sparc).
23 #
24 #
25 # #####################################################################################
26 # This Mail Was Scanned by 012.net AntiVirus Service1- Powered by TrendMicro Interscan
27 #
28 BEGIN { a = 3 }
29
30 {
31 print "in:", $0
32 print "a =", a
33 print $$a++++
34 print "out:", $0
35 }