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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
|
# comments/for.awk
BEGIN {
for (i = 1; i <= 10; i++) print i
for (i = 1; i <= 10; i++) # comment 0
print i
for (i = 1; # comment 1a
i <= 10; i++) print i
for (i = 1; i <= 10; # comment 2a
i++) print i
for (i = 1; # comment 1b
i <= 10; # comment 2b
i++) print i
for (i = 1; # comment 1c
i <= 10; # comment 2c
i++) # comment 3c
print i
}
# comments/for0.awk
BEGIN {
for (iggy in foo) # comment 5
# comment 6
;
}
# comments/for1.awk
BEGIN {
for (iggy in foo) # comment 1
# comment 2
{
print iggy
}
for (iggy in foo) # comment 3
# comment 4
print iggy
for (iggy in foo) # comment 5
# comment 6
;
}
# comments/for2.awk
BEGIN {
for (;;) print i
for (;;) # comment 0
print i
for (; # comment 1a
;) print i
for (; ; # comment 2a
) print i
for (; # comment 1b
; # comment 2b
) print i
for (; # comment 1c
; # comment 2c
) # comment 3c
print i
}
# comments/for_del.awk
BEGIN { for (iggy in foo) delete foo[iggy] }
# comments/do.awk
BEGIN {
do # DO comment
{ # LBRACE comment
# block comment
print 42
} # rbrace comment
while (0) # WHILE comment
}
# comments/do2.awk
BEGIN {
do # DO comment
{ # LBRACE comment
# block comment
print 42
} # rbrace comment
while (0)
}
# comments2/do.awk
BEGIN {
do # do comment
{ # lbrace comment
# block comment
print 42
} # rbace EOL comment
# rbrace block comment
while (1) # while comment
}
# comments2/if.awk
BEGIN {
if (a) # IF comment
print "foo" # print comment
if (a) # IF comment 2
{ # lbrace comment
print "bar"
}
else # ELSE comment
print "baz"
}
# comments/if0.awk
BEGIN {
if (a)
; # nothing
else
print "b"
}
# comments/switch.awk
BEGIN {
a = 5
switch (a) # switch EOL comment
# switch block comment
{ # lbrace EOL comment
# lbrace block comment
case 5: # comment after case
print "five!"
break
# block comment after case
default: # comment after default
print "default" # print comment
break
} # rbrace EOL comment
# rbrace block comment
}
# comments2/switch.awk
BEGIN {
a = 5
switch (a) # switch EOL comment
# switch block comment
{ # lbrace EOL comment
# lbrace block comment
case 5:
print "five!"
break;
# block comment after case
} # rbrace EOL comment
# rbrace block comment
}
# comments2/switch0.awk
BEGIN {
a = 5
switch (a)
{
case 5: # case comment
print "five!"
break
default: # default comment
print "default"
break
}
}
# comments2/switch1.awk
BEGIN {
a = 5
switch (a)
{
case 5:
# case comment
print "five!"
break
default: # default comment
print "default"
break
}
}
# comments2/while.awk
BEGIN {
while (1) # while comment
{ # lbrace comment
# block comment
print 42
}
}
# comments2/while2.awk
BEGIN {
while (1) # while comment
{ # lbrace comment
# block comment
}
}
# comments2/f.awk
function bar(p1,
p2)
{
print "foo"
} # rbrace eol bar
# rbrace block bar
# comments2/function.awk
function baz(p1, # comment
p2)
# comment before braces
{ # lbrace eol
# lbrace block
print "foo"
} # rbrace eol baz
# rbrace block baz
# comments/function.awk
function funny(param1, # param comment 1
param2, param3, # param comment 2
param4)
# Comment between header and body
{ # lbrace EOL comment
# lbrace block comment
print "funny"
} # rbrace EOL comment funny
# rbrace block comment funny
# comments/function2.awk
function funnyhaha(param1,
param2, param3,
param4)
{ # lbrace EOL comment
# lbrace block comment
print "funny"
} # rbrace EOL comment funnyhaha
# rbrace block comment funnyhaha
# comments/callcoma.awk
function callme(a, b, c)
{
printf("a = %s, b = %s, c = %s\n", # format comment
a, # a2 comment
b, # b2 comment
c)
}
BEGIN {
callme(1, # 1 comment
2, # 2 comment
3)
}
# comments/exp.awk
/foo/, # range comment
# range comment 2
# range comment b
# range comment c
/bar/ { print }
# comments/load.awk
@load "filefuncs" # get file functions
BEGIN {
stat("/etc/passwd", data)
for (i in data)
print i, data[i]
}
# comments/andor.awk
BEGIN {
if (a && # and comment
b || # or comment
c)
print "foo"
}
# comments/qmcol-qm.awk
BEGIN {
a = 1 ? # qm comment
2 :
3
print a
}
# comments/qmcol-colon.awk
BEGIN {
a = 1 ?
2 : # colon comment
3
print a
}
# comments/qmcolboth.awk
BEGIN {
a = 1 ? # qm comment
2 : # colon comment
3
print a
}
# test beginning of line block comments (com2.awk)
BEGIN {
print "hi" # comment 1
# comment 2
print "there"
if (foo) {
print "hello" # comment 3
# comment 4
print "world"
}
}
|