Anonymous user
Idiomatically determine all the characters that can be used for symbols: Difference between revisions
Idiomatically determine all the characters that can be used for symbols (view source)
Revision as of 12:45, 14 March 2020
, 4 years ago→{{header|AWK}}: Clean up code to not include special rules for whitespace; also, AWK is not uppercase letter only
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
(→{{header|AWK}}: Clean up code to not include special rules for whitespace; also, AWK is not uppercase letter only) |
||
Line 17:
=={{header|AWK}}==
<lang AWK># usage: gawk -f Idiomatically_determine_all_the_characters_that_can_be_used_for_symbols.awk
fn = "is_valid_identifier.awk"
printf("BEGIN { exit(0) }\n") >>fn
close(fn)▼
rc = system("gawk -f is_valid_identifier.awk 2>errors")
}▼
BEGIN {
good1 = good1 c;
else
if (is_valid_identifier("_" c "_"))
good2 = good2 c;
else
bad2 = bad2 c;
}
printf("
length(bad1), length(good1), good1)
printf("2nd..nth char: %d bad, %d ok: %s\n",
length(bad2), length(good2), good2)
exit(0)
▲}
▲function run(c, rc) {
▲ printf("BEGIN{%s+=0}\n",c) >fn
▲ close(fn)
▲ return(rc)
}
</lang>
<p>output:</p>
<pre>
1st character: 203
2nd..nth char: 193
</pre>
|