code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(43 lines)
1 '\" t
2 .\" Copyright (c) 2026 Bruce Hill
3 .\" All rights reserved.
4 .\"
5 .TH Byte.parse 3 2026-03-08 "Tomo man-pages"
6 .SH NAME
7 Byte.parse \- convert text to a byte
8 .SH LIBRARY
9 Tomo Standard Library
10 .SH SYNOPSIS
11 .nf
12 .BI Byte.parse\ :\ func(text:\ Text,\ base:\ Int?\ =\ none,\ remainder:\ &Text?\ =\ none\ ->\ Byte?)
13 .fi
14 .SH DESCRIPTION
15 Parse a byte literal from text.
18 .SH ARGUMENTS
20 .TS
21 allbox;
22 lb lb lbx lb
23 l l l l.
24 Name Type Description Default
25 text Text The text to parse. -
26 base Int? The numeric base to use when parsing the byte. If unspecified, the byte's base will be inferred from the text prefix. After any "+" or "-" sign, if the text begins with "0x", the base will be assumed to be 16, "0o" will assume base 8, "0b" will assume base 2, otherwise the base will be assumed to be 10. none
27 remainder &Text? If non-none, this argument will be set to the remainder of the text after the matching part. If none, parsing will only succeed if the entire text matches. none
28 .TE
29 .SH RETURN
30 The byte parsed from the text, if successful, otherwise `none`.
32 .SH EXAMPLES
33 .EX
34 assert Byte.parse("5") == Byte(5)
35 assert Byte.parse("asdf") == none
36 assert Byte.parse("123xyz") == none
38 remainder : Text
39 assert Byte.parse("123xyz", remainder=&remainder) == Byte(123)
40 assert remainder == "xyz"
41 .EE
42 .SH SEE ALSO
43 .BR Tomo-Byte (3)