is Ascii Alnum Code(cp: int) - > bool- Module
- std.
parser - Receiver
- Not applicable
- Minimum arity
- 1
- Maximum arity
- 1
Declaration and parameters
LinkAvailability
Included by default: Pending
Import std.parser in language mode 5.21.
The current compiler selects std/parser.tpz for this language mode. Availability in other released editions and inclusion in each installed distribution are Pending.
Source evidence
- compiler/crates/topaz_resolve/src/stdlib.rs at
b48527d0a174· 316 - compiler/crates/topaz_resolve/src/stdlib.rs at
b48527d0a174· 72
Receiver
Parameter constraints
is returns true for integers from 48 through 57, inclusive. These are the ASCII digits from 0 through 9.
is returns true for integers from 65 through 90 or from 97 through 122, inclusive. These are ASCII uppercase and lowercase letters.
is returns true when the digit predicate or the letter predicate returns true.
is returns true for 9, 10, 11, 12, 13, and 32. These represent tab, line feed, vertical tab, form feed, carriage return, and space.
Every other int returns false. Negative values, surrogate code values, non ASCII characters, and integers above the Unicode range do not cause a diagnostic.
Each call evaluates its input once. Classification has no side effects and does not consult a locale, normalize text, or fold case.
Related rule: Classify integer ASCII codesResult
Effects
Failures
Result and effects
LinkClassify the integer with the exact ASCII set in the integer classification contract. Values outside that set return false.
Related entries
LinkClassify integer ASCII codes
LinkClassify integer ASCII codes
is returns true for integers from 48 through 57, inclusive. These are the ASCII digits from 0 through 9.
is returns true for integers from 65 through 90 or from 97 through 122, inclusive. These are ASCII uppercase and lowercase letters.
is returns true when the digit predicate or the letter predicate returns true.
is returns true for 9, 10, 11, 12, 13, and 32. These represent tab, line feed, vertical tab, form feed, carriage return, and space.
Every other int returns false. Negative values, surrogate code values, non ASCII characters, and integers above the Unicode range do not cause a diagnostic.
Each call evaluates its input once. Classification has no side effects and does not consult a locale, normalize text, or fold case.
Why
Exact integer sets make ASCII parsing independent of host text rules. A false result handles a value outside the class without introducing an error channel.
Source evidence
- compiler/crates/topaz_resolve/src/stdlib.rs at
912a5e86e1f9· 72 - compiler/crates/topaz_resolve/src/stdlib.rs at
912a5e86e1f9· 307 -
topaz.stdlib.contract.parser-ascii-codesatworking-tree - topaz.decision.parser-scalar-ascii.1 at
topaz.decisi
Include each ASCII endpoint and exclude its neighbors
Linkimport std.parserimport std.iofor cp in ([47, 48, 57, 58, 64, 65, 90, 91, 96, 97, 122, 123, 8, 9, 10, 11, 12, 13, 14, 31, 32, 33]) {let digit = parser.isAsciiDigitCode(cp)let alpha = parser.isAsciiAlphaCode(cp)let alnum = parser.isAsciiAlnumCode(cp)let space = parser.isAsciiWhitespaceCode(cp)io.writeLine("{digit}/{alpha}/{alnum}/{space}")}
false/false/false/false true/false/true/false true/false/true/false false/false/false/false false/false/false/false false/true/true/false false/true/true/false false/false/false/false false/false/false/false false/true/true/false false/true/true/false false/false/false/false false/false/false/false false/false/false/true false/false/false/true false/false/false/true false/false/false/true false/false/false/true false/false/false/false false/false/false/false false/false/false/true false/false/false/false
Expected result
Expected result
Execution completes. Exit code 0.
false/false/false/falsetrue/false/true/falsetrue/false/true/falsefalse/false/false/falsefalse/false/false/falsefalse/true/true/falsefalse/true/true/falsefalse/false/false/falsefalse/false/false/falsefalse/true/true/falsefalse/true/true/falsefalse/false/false/falsefalse/false/false/falsefalse/false/false/truefalse/false/false/truefalse/false/false/truefalse/false/false/truefalse/false/false/truefalse/false/false/falsefalse/false/false/falsefalse/false/false/truefalse/false/false/false
Source evidence
- compiler/crates/topaz_resolve/src/stdlib.rs at
912a5e86e1f9· 72 - compiler/crates/topaz_resolve/src/stdlib.rs at
912a5e86e1f9· 307 -
topaz.stdlib.contract.parser-ascii-codesatworking-tree - topaz.decision.parser-scalar-ascii.1 at
topaz.decisi
Return false for invalid code points and non ASCII values
Linkimport std.parserimport std.iofor cp in ([-1, 128, 233, 55296, 1114112, 9223372036854775807]) {let digit = parser.isAsciiDigitCode(cp)let alpha = parser.isAsciiAlphaCode(cp)let alnum = parser.isAsciiAlnumCode(cp)let space = parser.isAsciiWhitespaceCode(cp)io.writeLine("{digit}/{alpha}/{alnum}/{space}")}
false/false/false/false false/false/false/false false/false/false/false false/false/false/false false/false/false/false false/false/false/false
Expected result
Expected result
Execution completes. Exit code 0.
false/false/false/falsefalse/false/false/falsefalse/false/false/falsefalse/false/false/falsefalse/false/false/falsefalse/false/false/false
Source evidence
- compiler/crates/topaz_resolve/src/stdlib.rs at
912a5e86e1f9· 72 - compiler/crates/topaz_resolve/src/stdlib.rs at
912a5e86e1f9· 307 -
topaz.stdlib.contract.parser-ascii-codesatworking-tree - topaz.decision.parser-scalar-ascii.1 at
topaz.decisi