File: parse1.awk

package info (click to toggle)
gawk 1%3A3.1.7.dfsg-5
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 12,908 kB
  • ctags: 4,261
  • sloc: ansic: 35,520; sh: 14,198; awk: 5,290; yacc: 2,879; makefile: 1,768; sed: 16
file content (35 lines) | stat: -rw-r--r-- 952 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Date: Fri, 06 Jan 2006 14:02:17 -0800
# From: Paul Eggert <eggert@CS.UCLA.EDU>
# Subject: gawk misparses $expr++ if expr ends in ++
# To: bug-gawk@gnu.org
# Message-id: <87irsxypzq.fsf@penguin.cs.ucla.edu>
# 
# Here's an example of the problem:
# 
# $ gawk 'BEGIN{a=3}{print $$a++++}'
# gawk: {print $$a++++}
# gawk:               ^ syntax error
# 
# But it's not a syntax error, as the expression conforms to the POSIX
# spec: it should be treated like '$($a++)++'.
# 
# Mawk, Solaris awk (old awk), and Solaris nawk all accept the
# expression.  For example:
# 
# $ echo '3 4 5 6 7 8 9' | nawk 'BEGIN{a=3}{print $$a++++}'
# 7
# 
# This is with gawk 3.1.5 on Solaris 8 (sparc).
# 
# 
# #####################################################################################
# This Mail Was Scanned by 012.net AntiVirus Service1- Powered by TrendMicro Interscan
# 
BEGIN { a = 3 }

{
	print "in:", $0
	print "a =", a
	print $$a++++
	print "out:", $0
}