Idiomatically determine all the characters that can be used for symbols: Difference between revisions
Content deleted Content added
Thundergnat (talk | contribs) m syntax highlighting fixup automation |
Added FreeBasic |
||
Line 83: | Line 83: | ||
From this code we can see that any characters may be used in an identifier unless it parses as a string or a number. |
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| |
=={{header|FreeBASIC}}== |
||
<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. |
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. |
It checks separately which Unicode code points may appear at the beginning of an identifier, or in the remaining name. |