Idiomatically determine all the characters that can be used for symbols: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
(→‎{{header|Lua}}: added Lua solution)
m (→‎{{header|Wren}}: Changed to Wren S/H)
(5 intermediate revisions by 5 users not shown)
Line 17:
* [[Idiomatically_determine_all_the_lowercase_and_uppercase_letters|Idiomatically determine all the lowercase and uppercase letters]].
<br><br>
 
=={{header|ALGOL 68}}==
{{works with|ALGOL 68G|Any - tested with release 2.8.3.win32}}
...should also work with other Algol 68 implementations that use upper-stropping (reserved words in upper-case).<br>
There are a number of different types of symbols that can be defined in Algol 68 (informally as follows):<br>
- identifiers used for variables, constants, structure members, procedures<br>
- monadic operators<br>
- dyadic operators<br>
- mode indicants - used for type names
<br>
Monadic and dyadic operators can be symbolic or have "bold" names. Mode indicants also have "bold" names. When upper-stropping is used, bold words are formed from upper-case letters. Algol 68G also allows underscores in bold words - other implementations of Algol 68 may also allow digits.<br>
In the output, the characters shown for monadic and dyadic operators include the upper-case letters - these can't be mixed with symbols, e.g. +A and B- are not valid operator symbols. Additionally, the only valid two character operator name where ":" is the second character is "=:" - the surlaw operator, perhaps :).<br>
Symbolic operator symbols can be one or two characters, optionally suffixed with := or =:.<br>
The following uses the same approach as the AWK sample, though due to the different symbol types, rather more possible symbols have to be checked.<br>
The sample assumes Windows/Linux is the operating system and the Algol 68 compiler/interpreter can be invoked with "a68". It should be possible to modify it for other operating systems/commands. Only 7-bit ASCII characters > space are considered
<syntaxhighlight lang="algol68">
BEGIN # determine which characters can be in identifiers, etc. by trying to #
# compile test programs #
 
STRING source name = "_tmp.a68";
STRING a68 command = "a68 " + source name + " > _tmp.err 2>&1";
 
# attenpts to compile the code with "%" substituted with id, #
# returns 0 if it compiled OK, non-zero otherwise #
PROC attempt compilation = ( STRING template, id )INT:
BEGIN
STRING code := "";
# replace "%" with the identifier in the template #
FOR t pos FROM LWB template TO UPB template DO
code +:= IF template[ t pos ] /= "%"
THEN template[ t pos ]
ELSE id
FI
OD;
# output the source file and try compiling it #
FILE source file;
BOOL open error := IF open( source file, source name, stand out channel ) = 0
THEN
# opened OK - file already exists and #
# will be overwritten #
FALSE
ELSE
# failed to open the file #
# - try creating a new file #
establish( source file, source name, stand out channel ) /= 0
FI;
IF open error
THEN # failed to open the file #
print( ( "Unable to open ", source name, newline ) );
stop
ELSE # file opened OK #
put( source file, ( code ) ); # write source #
close( source file );
system( a68 command ) # compile it #
FI
END # attempt compilation # ;
# attempt to construct all two-charaacter symbols and determine whether #
# they are valid by attempting to compile a program containing them #
# only 7-bit ASCII characters > space are considered #
PROC try = ( STRING template, legend )VOID:
BEGIN
[ 0 : 127 ]BOOL first, second;
FOR i FROM LWB first TO UPB first DO
first[ i ] := second[ i ] := FALSE
OD;
FOR f FROM ABS " " + 1 TO UPB first DO
CHAR fc = REPR f;
IF attempt compilation( template, fc ) = 0
THEN
# this character can be the first character of a symbol #
first[ f ] := TRUE;
FOR s FROM ABS " " + 1 TO UPB second DO
IF NOT second[ s ]
THEN
# haven't found this is a valid second character #
# yet #
IF attempt compilation( template, fc + REPR s ) = 0
THEN
# compiled OK #
second[ s ] := TRUE
FI
FI
OD
FI
OD;
print( ( "Characters valid for ", legend, ":", newline ) );
print( ( " as first: " ) );
FOR c pos FROM LWB first TO UPB first DO
IF first[ c pos ]
THEN print( ( REPR c pos ) )
ELIF second[ c pos ]
THEN print( ( " " ) )
FI
OD;
print( ( newline ) );
print( ( " as other: " ) );
FOR c pos FROM LWB first TO UPB first DO
IF second[ c pos ]
THEN print( ( REPR c pos ) )
ELIF first[ c pos ]
THEN print( ( " " ) )
FI
OD;
print( ( newline ) )
END # try # ;
 
try( "BEGIN INT %; % := 1 END", "identifiers" );
try( "BEGIN OP % = ( INT a )INT: a; % 1 END", "monadic operators" );
try( "BEGIN PRIO % = 5; OP % = ( INT a, b )INT: a; 1 % 1 END", "dyadic operators" );
try( "BEGIN MODE % = INT; % x; x := 1 END", "mode indicants" )
 
END
</syntaxhighlight>
{{out}}
<pre>
Characters valid for identifiers:
as first: abcdefghijklmnopqrstuvwxyz
as other: 0123456789_abcdefghijklmnopqrstuvwxyz
Characters valid for monadic operators:
as first: !%& +- ?ABCDEFGHIJKLMNOPQRSTUVWXYZ^ ~
as other: * /<=> ABCDEFGHIJKLMNOPQRSTUVWXYZ _
Characters valid for dyadic operators:
as first: !%&*+-/ <=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ^ ~
as other: * /:<=> ABCDEFGHIJKLMNOPQRSTUVWXYZ _
Characters valid for mode indicants:
as first: ABCDEFGHIJKLMNOPQRSTUVWXYZ
as other: ABCDEFGHIJKLMNOPQRSTUVWXYZ_
</pre>
 
=={{header|AWK}}==
<langsyntaxhighlight AWKlang="awk"># usage: gawk -f Idiomatically_determine_all_the_characters_that_can_be_used_for_symbols.awk
 
function is_valid_identifier(id, rc) {
Line 51 ⟶ 179:
length(bad2), length(good2), good2)
exit(0)
}</langsyntaxhighlight>
<p>output:</p>
<pre>
Line 57 ⟶ 185:
2nd..nth char: 193 bad, 63 ok: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
</pre>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
This code test the all printable ASCII characters to see if they are valid in symbols. It uses the the Delphi system call "IsValidIdent" to determine what the compiler will accept. It starts by testing single characters identifiers, which tests the first character of the identifier. Then tests the second character. This tells which characters are valid for the rest of an identifier.
 
<syntaxhighlight lang="Delphi">
 
 
procedure ShowValidSymbols(Memo: TMemo);
{Uses Delphi system tool "IsValidIndent" }
{To identify valid characters in indentifiers}
var I: integer;
var TS: string;
var Good,Bad: string;
begin
{Test first characters in a symbol}
Good:=''; Bad:='';
for I:=$21 to $7F do
begin
TS:=Char(I);
if IsValidIdent(TS) then Good:=Good+TS
else Bad:=Bad+TS;
end;
Memo.Lines.Add('First Characters Allowed');
Memo.Lines.Add('Allowed: '+Good);
Memo.Lines.Add('Not Allowed: '+Bad);
{Test remaining characters in a symbol}
Good:=''; Bad:='';
for I:=$21 to $7F do
begin
TS:='A'+Char(I);
if IsValidIdent(TS) then Good:=Good+TS[2]
else Bad:=Bad+TS[2];
end;
Memo.Lines.Add('');
Memo.Lines.Add('Remaining Characters Allowed');
Memo.Lines.Add('Allowed: '+Good);
Memo.Lines.Add('Not Allowed: '+Bad);
end;
 
 
</syntaxhighlight>
{{out}}
<pre>
First Characters Allowed
Allowed: ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
Not Allowed: !"#$%&'()*+,-./0123456789:;<=>?@[\]^`{|}~
 
Remaining Characters Allowed
Allowed: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
Not Allowed: !"#$%&'()*+,-./:;<=>?@[\]^`{|}~
 
Elapsed Time: 9.048 ms.
 
</pre>
 
 
=={{header|F_Sharp|F#}}==
Well, if the purpose of this task is to determine what can be used as an identifier then in F# anything so long as you enclose it in double backticks so:
<langsyntaxhighlight lang="fsharp">
let ``+`` = 5
printfn "%d" ``+``
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 73 ⟶ 258:
{{output?}}
 
<langsyntaxhighlight lang="factor">USING: parser see ;
\ scan-word-name see</langsyntaxhighlight>
{{out}}
<pre>
Line 83 ⟶ 268:
From this code we can see that any characters may be used in an identifier unless it parses as a string or a number.
 
=={{header|GoFreeBASIC}}==
<syntaxhighlight lang="vb">Dim As String*1 C1
Dim As Integer C
Print "First character set: ";
For C = 0 To 255
If (Chr(C) >= "A" And Chr(C) <="Z") Or Chr(C)="_" Then Print Chr(C);
Next
 
Print !"\nNext characters set: ";
For C = 0 To 255
C1 = Chr(C)
If (C1 >= "A" And C1 <= "Z") Or (C1 >= "0" And C1 <= "9") Or C1 = "_" Or (C1 >= "a" And C1 <= "z") Then Print C1;
Next C
 
Sleep</syntaxhighlight>
{{out}}
<pre>First character set: ABCDEFGHIJKLMNOPQRSTUVWXYZ_
Next characters set: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz</pre>
 
=={{header|Go}}==
This program uses the Go parser to check whether an identifier is indeed valid.
It checks separately which Unicode code points may appear at the beginning of an identifier, or in the remaining name.
Line 90 ⟶ 293:
or of length 2 starting with the underscore.
 
<langsyntaxhighlight lang="go">package main
 
import (
Line 173 ⟶ 376:
_, _ = fmt.Println("Valid follow:", validFollow.String())
_, _ = fmt.Println("Only follow:", validOnlyFollow.String())
}</langsyntaxhighlight>
{{out}}
<pre>
Line 209 ⟶ 412:
 
According to the specification we may give predicates for valid symbols and identifiers in Haskell:
<langsyntaxhighlight lang="haskell">import Data.Char
 
-- predicate for valid symbol
Line 229 ⟶ 432:
, "else", "foreign", "if", "import", "in", "infix "
, "infixl", "infixr", "instance", "let", "module "
, "newtype", "of", "then", "type", "where", "_"</langsyntaxhighlight>
 
=={{header|J}}==
Line 235 ⟶ 438:
J is defined in terms of ascii, but that would not prevent it from being ported to other environments. But we can still use J's parser to determine if a specific character combination is a single, legal word:
 
<langsyntaxhighlight Jlang="j"> a.#~1=#@;: ::0:"1 'b',.a.,.'c'
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz</langsyntaxhighlight>
 
Here, [http://www.jsoftware.com/help/dictionary/dadot.htm a.] is the set of chararacters we are testing. We prefix each of these with an arbitrary letter, and suffix each with an arbitrary character and then try counting how many parsed tokens are formed by the result. If the token count is 1, then that character was a legal word-forming character.
Line 244 ⟶ 447:
=={{header|Java}}==
{{works with|Java|8}}
<langsyntaxhighlight lang="java">import java.util.function.IntPredicate;
import java.util.stream.IntStream;
 
Line 275 ⟶ 478:
System.out.println("...");
}
}</langsyntaxhighlight>
 
<pre>Java Identifier start: $ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz¢£¤¥ªµºÀÁÂÃÄÅÆÇÈÉÊ...
Line 291 ⟶ 494:
 
To generate a string of such characters idiomatically:
<langsyntaxhighlight lang="jq">[range(0;128) | [.] | implode | select(test("[A-Za-z0-9$_]"))] | add</langsyntaxhighlight>
 
jq 1.5 also allows ":" as a joining character in the form "module::name".
Line 303 ⟶ 506:
Therefore, assuming the availability in jq of the test/1 builtin, the test
in jq for whether a character can appear literally in a jq identifier or key is:
<langsyntaxhighlight lang="jq">test("[^\u0000-\u0007F]")</langsyntaxhighlight>
 
===Symbols===
The following function screens for characters by "\p" class:
<langsyntaxhighlight lang="jq">def is_character(class):
test( "\\p{" + class + "}" );</langsyntaxhighlight>
For example, to test whether a character is a Unicode letter, symbol or numeric character:
<langsyntaxhighlight lang="jq">is_character("L") or is_character("S") or is_character("N")</langsyntaxhighlight>
 
An efficient way to count the number of Unicode characters within a character class is
to use the technique illustrated by the following function:
<langsyntaxhighlight lang="jq">def count(class; m; n):
reduce (range(m;n) | [.] | implode | select( test( "\\p{" + class + "}" ))) as $i
(0; . + 1);</langsyntaxhighlight>
 
For example the number of Unicode "symbol" characters can be obtained by evaluating:
<langsyntaxhighlight lang="jq">count("S"; 0; 1114112)</langsyntaxhighlight>
The result is 3958.
 
Line 327 ⟶ 530:
 
For example, x2 is a valid identifier, but 2x is not-- it is interpreted as 2 times the identifier x. In Julia, the Symbol() function turns a string into a symbolic token. So, for example:
<langsyntaxhighlight lang="julia">
for i in 1:0x200000 - 1
Symbol("x" * Char(i))
end
</syntaxhighlight>
</lang>
 
When run, this loop runs without error up to 0x200000 but not at Unicode symbol numbered 0x200000.
Line 350 ⟶ 553:
 
A Kotlin label name is a valid identifier followed by an @ symbol and an annotation name is an identifier preceded by an @ symbol.
<langsyntaxhighlight lang="scala">// version 1.1.4-3
 
typealias CharPredicate = (Char) -> Boolean
Line 372 ⟶ 575:
printChars("Kotlin Identifier ignorable: ", 0, 0x10FFFF, 25,
Character::isIdentifierIgnorable, true)
}</langsyntaxhighlight>
 
{{out}}
Line 383 ⟶ 586:
=={{header|Lua}}==
From the 5.4 reference manual: "Names (also called identifiers) in Lua can be any string of Latin letters, Arabic-Indic digits, and underscores, not beginning with a digit and not being a reserved word."
<langsyntaxhighlight lang="lua">function isValidIdentifier(id)
local reserved = {
["and"]=true, ["break"]=true, ["do"]=true, ["end"]=true, ["else"]=true, ["elseif"]=true, ["end"]=true,
Line 398 ⟶ 601:
end
print("Valid First Characters: " .. table.concat(vfc))
print("Valid Subsequent Characters: " .. table.concat(vsc))</langsyntaxhighlight>
{{out}}
<pre>Valid First Characters: ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
Line 404 ⟶ 607:
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">chars = Characters[FromCharacterCode[Range[0, 1114111]]];
out = Reap[Do[
If[Quiet[Length[Symbol[c]] == 0],
Line 420 ⟶ 623:
{c, chars}
]][[2, 1]];
Print["Possible 2nd-nth characters: ", out // Length]</langsyntaxhighlight>
{{out}}
In Wolfram Language almost all characters (there are 1114112 characters defined) can be used in variable/function names. I can't show all valid characters as there are over a million that are allowed. I do not show the list of characters 'out' but rather their length for practical purposes:
Line 429 ⟶ 632:
As regards identifiers, there exists a general rule which describes how they can be formed. For this rule, the following program prints the allowed starting characters and the allowed characters:
 
<langsyntaxhighlight Nimlang="nim">import sequtils, strutils
 
echo "Allowed starting characters for identifiers:"
Line 435 ⟶ 638:
echo ""
echo "Allowed characters in identifiers:"
echo toSeq(IdentChars).join()</langsyntaxhighlight>
 
{{out}}
Line 446 ⟶ 649:
But Nim is a lot more flexible and allows using Unicode symbols in identifiers provided these are letters and digits. Thus, the following program is valid:
 
<langsyntaxhighlight Nimlang="nim">var à⁷ = 3
echo à⁷</langsyntaxhighlight>
 
Using escape character <code>`</code>, it is possible to override the rules and to include any character in an identifier and even to use a keyword as identifier. Here is an example of the possibilities:
 
<langsyntaxhighlight Nimlang="nim">var `const`= 3
echo `const`
 
Line 468 ⟶ 671:
var `1` = 2
echo `1`
</syntaxhighlight>
</lang>
 
=={{header|Ol}}==
Line 482 ⟶ 685:
Although this program does not use any feature that is not in Classic Rexx,
it is included here to show what characters are valid for symbols in ooRexx.
<langsyntaxhighlight lang="oorexx">/*REXX program determines what characters are valid for REXX symbols.*/
/* copied from REXX version 2 */
Parse Version v
Line 492 ⟶ 695:
symbol_characters=symbol_characters || c /* add to list. */
end
say 'symbol characters:' symbol_characters /*display all */</langsyntaxhighlight>
{{out}}
<pre>REXX-ooRexx_4.2.0(MT)_32-bit 6.04 22 Feb 2014
Line 499 ⟶ 702:
=={{header|PARI/GP}}==
The only symbols that can be used in variable names (including function names as a special case) are a-z, A-Z, 0-9, and the underscore. Additionally, the first character must be a letter. (That is, they must match this regex: <code>[a-zA-Z][a-zA-Z0-9_]*</code>.)
<langsyntaxhighlight lang="parigp">v=concat(concat([48..57],[65..90]),concat([97..122],95));
apply(Strchr,v)</langsyntaxhighlight>
{{out}}
<pre>%1 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "_"]</pre>
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl"># When not using the <code>use utf8</code> pragma, any word character in the ASCII range is allowed.
# the loop below returns: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
for $i (0..0x7f) {
Line 519 ⟶ 722:
$c = chr($_);
print $c if $c =~ /\p{Word}/;
}</langsyntaxhighlight>
 
=={{header|Phix}}==
Translation of AWK, extended with separation of ansi and utf8 handling
<!--<langsyntaxhighlight Phixlang="phix">(notonline)-->
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- file i/o, system_exec, \t and \r chars</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">run</span><span style="color: #0000FF;">(</span><span style="color: #004080;">string</span> <span style="color: #000000;">ident</span><span style="color: #0000FF;">)</span>
Line 580 ⟶ 783:
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"utf8 characters: \n===============\n"</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"bad:%,d, good:%,d\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">ng8</span><span style="color: #0000FF;">,</span><span style="color: #000000;">ok8</span><span style="color: #0000FF;">})</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 604 ⟶ 807:
=={{header|Quackery}}==
 
<langsyntaxhighlight Quackerylang="quackery">[ $ "0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrS"
$ QsTtUuVvWwXxYyZz()[]{}<>~=+-*/^\|_.,:;?!'"`%@&#$Q
join ] constant is tokenchars ( --> $ )
Line 640 ⟶ 843:
[ i^ validtoken if [ i^ emit ] ] ] is alltokens ( --> )
alltokens</langsyntaxhighlight>
 
'''Output:'''
Line 662 ⟶ 865:
That's too much to be printing out here... call <code>(main)</code> yourself, at home.
 
<langsyntaxhighlight lang="racket">#lang racket
;; Symbols that don't need to be specially quoted:
(printf "~s~%" '(a a-z 3rd ...---... .hidden-files-look-like-this))
Line 687 ⟶ 890:
(when (zero? (modulo i 80)) (newline))
(display (list->string (list c)))))
</syntaxhighlight>
</lang>
 
{{out}}
Line 698 ⟶ 901:
(formerly Perl 6)
Any Unicode character or combination of characters can be used for symbols in Raku. Here's some counting rods and some cuneiform:
<syntaxhighlight lang="raku" perl6line>sub postfix:<𒋦>($n) { say "$n trilobites" }
 
sub term:<𝍧> { unival('𝍧') }
 
𝍧𒋦</langsyntaxhighlight>
{{out}}
<pre>8 trilobites</pre>
Line 708 ⟶ 911:
And here is a Zalgo-text symbol:
 
<syntaxhighlight lang="raku" perl6line>sub Z̧̔ͩ͌͑̉̎A̢̲̙̮̹̮͍̎L̔ͧ́͆G̰̬͎͔̱̅ͣͫO͙̔ͣ̈́̈̽̎ͣ ($n) { say "$n COMES" }
 
 
Z̧̔ͩ͌͑̉̎A̢̲̙̮̹̮͍̎L̔ͧ́͆G̰̬͎͔̱̅ͣͫO͙̔ͣ̈́̈̽̎ͣ 'HE'</langsyntaxhighlight>
{{out}}
<pre>HE COMES</pre>
Line 718 ⟶ 921:
 
Actually, the above is a slight prevarication. The syntactic category notation does not allow you to use whitespace in the definition of a new symbol. But that leaves many more characters allowed than not allowed. Hence, it is much easier to enumerate the characters that <em>cannot</em> be used in symbols:
<syntaxhighlight lang="raku" perl6line>say .fmt("%4x"),"\t", uniname($_)
if uniprop($_,'Z')
for 0..0x1ffff;</langsyntaxhighlight>
{{out}}
<pre> 20 SPACE
Line 746 ⟶ 949:
=={{header|REXX}}==
===version 1===
<langsyntaxhighlight lang="rexx">/*REXX program determines what characters are valid for REXX symbols. */
@= /*set symbol characters " " */
do j=0 for 2**8 /*traipse through all the chars. */
Line 754 ⟶ 957:
 
say ' symbol characters: ' @ /*display all symbol characters.*/
/*stick a fork in it, we're done.*/</langsyntaxhighlight>
Programming note: &nbsp; REXX allows any symbol to begin a (statement) label, but variables can't begin with a period ('''.''') or a numeric digit.
<br><br>All examples below were executed on a (ASCII) PC using Windows/XP and Windows/7 with code page 437 in a DOS window.
Line 786 ⟶ 989:
</pre>
I've added version 2 which should work correctly for all Rexx interpreters and compilers
<langsyntaxhighlight lang="rexx">/*REXX program determines what characters are valid for REXX symbols.*/
/* version 1 adapted for general acceptance */
Parse Version v
Line 797 ⟶ 1,000:
end
say 'symbol characters:' symbol_characters /*display all */
</syntaxhighlight>
</lang>
{{out}} for some interpreters
Note that $#@ are not valid symbol characters for ooRexx.
Line 805 ⟶ 1,008:
REXX-Regina_3.8.2(MT) 5.00 22 Jun 2014
symbol characters: !#$.0123456789?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
</pre>
 
=={{header|RPL}}==
The RPL character set is an 8-bit character set, sometimes referred to simply as "ECMA-94" in documentation, although it is for the most part a variant of ISO/IEC 8859-1 / ECMA-94. See the related [https://en.wikipedia.org/wiki/RPL_character_set Wikipedia entry] for more details.
≪ "" "'A '"
1 255 '''FOR''' c
3 c CHR REPL
'''IFERR''' DUP STR→ '''THEN''' DROP
'''ELSE'''
'''IF''' 'A' SAME NOT '''THEN''' SWAP c CHR + SWAP '''END'''
'''END'''
'''NEXT''' DROP
≫ '<span style="color:blue">SYMBOLS</span>' STO
{{out}}
<pre>
1: "!$%&.0123456789?ABCDEFGHIJKLMNOPQRSTUVWXYZ\abcdefghijklmnopqrstuvwxyz~∇∑▶πα→←↓↑γδεηθλρστωΔΠΩ▬∞ ¡¢£¤¥¦§¨©ª¬­®¯°±²³´µ¶·¸¹º¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ"
</pre>
 
=={{header|Scala}}==
{{Out}}Best seen running in your browser either by [https://scalafiddle.io/sf/ZyPkGW8/0 ScalaFiddle (ES aka JavaScript, non JVM)] or [https://scastie.scala-lang.org/4XdxscWGTtyw9MDQXCtRdg Scastie (remote JVM)].
<langsyntaxhighlight Scalalang="scala">object IdiomaticallyDetermineSymbols extends App {
 
private def print(msg: String, limit: Int, p: Int => Boolean, fmt: String) =
Line 820 ⟶ 1,039:
print("Unicode Identifier part : ", 25, cp => Character.isUnicodeIdentifierPart(cp), "[%d]")
 
}</langsyntaxhighlight>
 
=={{header|Tcl}}==
Tcl permits ''any'' character to be used in a variable or command name (subject to the restriction that <code>::</code> is a namespace separator and, for variables only, a <code>(…)</code> sequence is an array reference). The set of characters that can be used after <code>$</code> is more restricted, excluding many non-letter-like symbols, but still large. It is ''recommended practice'' to only use ASCII characters for variable names as this makes scripts more resistant to the majority of encoding problems when transporting them between systems, but the language does not itself impose such a restriction.
<langsyntaxhighlight lang="tcl">for {set c 0;set printed 0;set special {}} {$c <= 0xffff} {incr c} {
set ch [format "%c" $c]
set v "_${ch}_"
Line 838 ⟶ 1,057:
puts "All Unicode characters legal in names"
}
puts "Characters legal after \$: $special"</langsyntaxhighlight>
{{out}}
Only the first 256 characters are displayed:
Line 848 ⟶ 1,067:
 
Identifiers which begin with underscores can only be used as instance field names (one underscore) or static field names (two or more underscores).
<langsyntaxhighlight ecmascriptlang="wren">for (i in 97..122) System.write(String.fromByte(i))
for (i in 65..90) System.write(String.fromByte(i))
System.print("_")</langsyntaxhighlight>
 
{{out}}
Line 859 ⟶ 1,078:
=={{header|XPL0}}==
Paraphrasing code from the compiler's parser:
<langsyntaxhighlight XPL0lang="xpl0">char C, C1;
[Text(0, "First character set: ");
for C:= 0 to 255 do
Line 875 ⟶ 1,094:
];
CrLf(0);
]</langsyntaxhighlight>
 
{{out}}
Line 885 ⟶ 1,104:
=={{header|zkl}}==
zkl only supports ASCII, although other character sets might be finessed.
<langsyntaxhighlight lang="zkl">[0..255].filter(fcn(n){
try{ Compiler.Compiler.compileText("var "+n.text) }
catch{ False }
}).apply("text").concat()</langsyntaxhighlight>
{{out}}
<pre>
9,482

edits