aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2026-01-19 20:51:26 -0500
committerBruce Hill <bruce@bruce-hill.com>2026-01-19 20:52:23 -0500
commitf905f1e4d1c77410931dc5ebfd8bcf466864a3e2 (patch)
tree32d52ad87f303237e451c90c1a33b12217a1c6e5
parenta36f149d0837f4424aeda1a1853f08c27aeafa44 (diff)
Allow parsing `123.foo()` as `(123).foo()`
-rw-r--r--CHANGES.md3
-rw-r--r--api/api.md48
-rw-r--r--api/integers.md48
-rw-r--r--api/integers.yaml48
-rw-r--r--man/man3/tomo-Int.choose.36
-rw-r--r--man/man3/tomo-Int.clamped.36
-rw-r--r--man/man3/tomo-Int.factorial.36
-rw-r--r--man/man3/tomo-Int.get_bit.312
-rw-r--r--man/man3/tomo-Int.hex.36
-rw-r--r--man/man3/tomo-Int.is_between.312
-rw-r--r--man/man3/tomo-Int.is_prime.38
-rw-r--r--man/man3/tomo-Int.next_prime.36
-rw-r--r--man/man3/tomo-Int.octal.36
-rw-r--r--man/man3/tomo-Int.onward.36
-rw-r--r--man/man3/tomo-Int.prev_prime.36
-rw-r--r--man/man3/tomo-Int.sqrt.38
-rw-r--r--man/man3/tomo-Int.to.312
-rw-r--r--src/parse/numbers.c1
-rw-r--r--src/parse/utils.c6
-rw-r--r--src/parse/utils.h1
-rw-r--r--test/integers.tm26
21 files changed, 145 insertions, 136 deletions
diff --git a/CHANGES.md b/CHANGES.md
index 9b6b2cb0..856abfb7 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,7 +2,8 @@
## v2025-12-31
-- Changed `is_between()` to be bidirectional so `(5).is_between(10, 1) == yes`
+- Added support for `123.foo()` parsing the same as `(123).foo()`
+- Changed `is_between()` to be bidirectional so `5.is_between(10, 1) == yes`
## v2025-12-23.2
diff --git a/api/api.md b/api/api.md
index df8386ff..9e7c553e 100644
--- a/api/api.md
+++ b/api/api.md
@@ -449,7 +449,7 @@ k | `Int` | The number of things to be chosen. | -
**Example:**
```tomo
-assert (4).choose(2) == 6
+assert 4.choose(2) == 6
```
## Int.clamped
@@ -471,7 +471,7 @@ high | `Int` | The highest value the result can take. | -
**Example:**
```tomo
-assert (2).clamped(5, 10) == 5
+assert 2.clamped(5, 10) == 5
```
## Int.factorial
@@ -491,7 +491,7 @@ n | `Int` | The integer to compute the factorial of. | -
**Example:**
```tomo
-assert (10).factorial() == 3628800
+assert 10.factorial() == 3628800
```
## Int.get_bit
@@ -514,10 +514,10 @@ bit_index | `Int` | The index of the bit to check (1-indexed). | -
**Example:**
```tomo
-assert (6).get_bit(1) == no
-assert (6).get_bit(2) == yes
-assert (6).get_bit(3) == yes
-assert (6).get_bit(4) == no
+assert 6.get_bit(1) == no
+assert 6.get_bit(2) == yes
+assert 6.get_bit(3) == yes
+assert 6.get_bit(4) == no
```
## Int.hex
@@ -540,7 +540,7 @@ prefix | `Bool` | Whether to include a "0x" prefix. | `yes`
**Example:**
```tomo
-assert (255).hex(digits=4, uppercase=yes, prefix=yes) == "0x00FF"
+assert 255.hex(digits=4, uppercase=yes, prefix=yes) == "0x00FF"
```
## Int.is_between
@@ -562,10 +562,10 @@ b | `Int` | The other end of the range to check (inclusive). | -
**Example:**
```tomo
-assert (7).is_between(1, 10) == yes
-assert (7).is_between(10, 1) == yes
-assert (7).is_between(100, 200) == no
-assert (7).is_between(1, 7) == yes
+assert 7.is_between(1, 10) == yes
+assert 7.is_between(10, 1) == yes
+assert 7.is_between(100, 200) == no
+assert 7.is_between(1, 7) == yes
```
## Int.is_prime
@@ -588,8 +588,8 @@ reps | `Int` | The number of repetitions for primality tests. | `50`
**Example:**
```tomo
-assert (7).is_prime() == yes
-assert (6).is_prime() == no
+assert 7.is_prime() == yes
+assert 6.is_prime() == no
```
## Int.next_prime
@@ -611,7 +611,7 @@ x | `Int` | The integer after which to find the next prime. | -
**Example:**
```tomo
-assert (11).next_prime() == 13
+assert 11.next_prime() == 13
```
## Int.octal
@@ -633,7 +633,7 @@ prefix | `Bool` | Whether to include a "0o" prefix. | `yes`
**Example:**
```tomo
-assert (64).octal(digits=4, prefix=yes) == "0o0100"
+assert 64.octal(digits=4, prefix=yes) == "0o0100"
```
## Int.onward
@@ -655,7 +655,7 @@ step | `Int` | The increment step size. | `1`
**Example:**
```tomo
nums : &[Int] = &[]
-for i in (5).onward()
+for i in 5.onward()
nums.insert(i)
stop if i == 10
assert nums[] == [5, 6, 7, 8, 9, 10]
@@ -716,7 +716,7 @@ x | `Int` | The integer before which to find the previous prime. | -
**Example:**
```tomo
-assert (11).prev_prime() == 7
+assert 11.prev_prime() == 7
```
## Int.sqrt
@@ -736,8 +736,8 @@ x | `Int` | The integer whose square root is to be calculated. | -
**Example:**
```tomo
-assert (16).sqrt() == 4
-assert (17).sqrt() == 4
+assert 16.sqrt() == 4
+assert 17.sqrt() == 4
```
## Int.to
@@ -759,16 +759,16 @@ step | `Int?` | An optional step size to use. If unspecified or `none`, the step
**Example:**
```tomo
-iter := (2).to(5)
+iter := 2.to(5)
assert iter() == 2
assert iter() == 3
assert iter() == 4
assert iter() == 5
assert iter() == none
-assert [x for x in (2).to(5)] == [2, 3, 4, 5]
-assert [x for x in (5).to(2)] == [5, 4, 3, 2]
-assert [x for x in (2).to(5, step=2)] == [2, 4]
+assert [x for x in 2.to(5)] == [2, 3, 4, 5]
+assert [x for x in 5.to(2)] == [5, 4, 3, 2]
+assert [x for x in 2.to(5, step=2)] == [2, 4]
```
diff --git a/api/integers.md b/api/integers.md
index 73779021..e3fc3f30 100644
--- a/api/integers.md
+++ b/api/integers.md
@@ -41,7 +41,7 @@ k | `Int` | The number of things to be chosen. | -
**Example:**
```tomo
-assert (4).choose(2) == 6
+assert 4.choose(2) == 6
```
## Int.clamped
@@ -63,7 +63,7 @@ high | `Int` | The highest value the result can take. | -
**Example:**
```tomo
-assert (2).clamped(5, 10) == 5
+assert 2.clamped(5, 10) == 5
```
## Int.factorial
@@ -83,7 +83,7 @@ n | `Int` | The integer to compute the factorial of. | -
**Example:**
```tomo
-assert (10).factorial() == 3628800
+assert 10.factorial() == 3628800
```
## Int.get_bit
@@ -106,10 +106,10 @@ bit_index | `Int` | The index of the bit to check (1-indexed). | -
**Example:**
```tomo
-assert (6).get_bit(1) == no
-assert (6).get_bit(2) == yes
-assert (6).get_bit(3) == yes
-assert (6).get_bit(4) == no
+assert 6.get_bit(1) == no
+assert 6.get_bit(2) == yes
+assert 6.get_bit(3) == yes
+assert 6.get_bit(4) == no
```
## Int.hex
@@ -132,7 +132,7 @@ prefix | `Bool` | Whether to include a "0x" prefix. | `yes`
**Example:**
```tomo
-assert (255).hex(digits=4, uppercase=yes, prefix=yes) == "0x00FF"
+assert 255.hex(digits=4, uppercase=yes, prefix=yes) == "0x00FF"
```
## Int.is_between
@@ -154,10 +154,10 @@ b | `Int` | The other end of the range to check (inclusive). | -
**Example:**
```tomo
-assert (7).is_between(1, 10) == yes
-assert (7).is_between(10, 1) == yes
-assert (7).is_between(100, 200) == no
-assert (7).is_between(1, 7) == yes
+assert 7.is_between(1, 10) == yes
+assert 7.is_between(10, 1) == yes
+assert 7.is_between(100, 200) == no
+assert 7.is_between(1, 7) == yes
```
## Int.is_prime
@@ -180,8 +180,8 @@ reps | `Int` | The number of repetitions for primality tests. | `50`
**Example:**
```tomo
-assert (7).is_prime() == yes
-assert (6).is_prime() == no
+assert 7.is_prime() == yes
+assert 6.is_prime() == no
```
## Int.next_prime
@@ -203,7 +203,7 @@ x | `Int` | The integer after which to find the next prime. | -
**Example:**
```tomo
-assert (11).next_prime() == 13
+assert 11.next_prime() == 13
```
## Int.octal
@@ -225,7 +225,7 @@ prefix | `Bool` | Whether to include a "0o" prefix. | `yes`
**Example:**
```tomo
-assert (64).octal(digits=4, prefix=yes) == "0o0100"
+assert 64.octal(digits=4, prefix=yes) == "0o0100"
```
## Int.onward
@@ -247,7 +247,7 @@ step | `Int` | The increment step size. | `1`
**Example:**
```tomo
nums : &[Int] = &[]
-for i in (5).onward()
+for i in 5.onward()
nums.insert(i)
stop if i == 10
assert nums[] == [5, 6, 7, 8, 9, 10]
@@ -308,7 +308,7 @@ x | `Int` | The integer before which to find the previous prime. | -
**Example:**
```tomo
-assert (11).prev_prime() == 7
+assert 11.prev_prime() == 7
```
## Int.sqrt
@@ -328,8 +328,8 @@ x | `Int` | The integer whose square root is to be calculated. | -
**Example:**
```tomo
-assert (16).sqrt() == 4
-assert (17).sqrt() == 4
+assert 16.sqrt() == 4
+assert 17.sqrt() == 4
```
## Int.to
@@ -351,15 +351,15 @@ step | `Int?` | An optional step size to use. If unspecified or `none`, the step
**Example:**
```tomo
-iter := (2).to(5)
+iter := 2.to(5)
assert iter() == 2
assert iter() == 3
assert iter() == 4
assert iter() == 5
assert iter() == none
-assert [x for x in (2).to(5)] == [2, 3, 4, 5]
-assert [x for x in (5).to(2)] == [5, 4, 3, 2]
-assert [x for x in (2).to(5, step=2)] == [2, 4]
+assert [x for x in 2.to(5)] == [2, 3, 4, 5]
+assert [x for x in 5.to(2)] == [5, 4, 3, 2]
+assert [x for x in 2.to(5, step=2)] == [2, 4]
```
diff --git a/api/integers.yaml b/api/integers.yaml
index bbbd395d..68a66752 100644
--- a/api/integers.yaml
+++ b/api/integers.yaml
@@ -35,7 +35,7 @@ Int.choose:
description: >
The number of things to be chosen.
example: |
- assert (4).choose(2) == 6
+ assert 4.choose(2) == 6
Int.clamped:
short: clamp an integer
@@ -60,7 +60,7 @@ Int.clamped:
description: >
The highest value the result can take.
example: |
- assert (2).clamped(5, 10) == 5
+ assert 2.clamped(5, 10) == 5
Int.factorial:
short: factorial
@@ -76,7 +76,7 @@ Int.factorial:
description: >
The integer to compute the factorial of.
example: |
- assert (10).factorial() == 3628800
+ assert 10.factorial() == 3628800
Int.get_bit:
short: check whether a bit is set
@@ -103,10 +103,10 @@ Int.get_bit:
description: >
The index of the bit to check (1-indexed).
example: |
- assert (6).get_bit(1) == no
- assert (6).get_bit(2) == yes
- assert (6).get_bit(3) == yes
- assert (6).get_bit(4) == no
+ assert 6.get_bit(1) == no
+ assert 6.get_bit(2) == yes
+ assert 6.get_bit(3) == yes
+ assert 6.get_bit(4) == no
Int.hex:
short: convert to hexidecimal
@@ -137,7 +137,7 @@ Int.hex:
description: >
Whether to include a "0x" prefix.
example: |
- assert (255).hex(digits=4, uppercase=yes, prefix=yes) == "0x00FF"
+ assert 255.hex(digits=4, uppercase=yes, prefix=yes) == "0x00FF"
Int.is_between:
short: test if an int is in a range
@@ -161,10 +161,10 @@ Int.is_between:
description: >
The other end of the range to check (inclusive).
example: |
- assert (7).is_between(1, 10) == yes
- assert (7).is_between(10, 1) == yes
- assert (7).is_between(100, 200) == no
- assert (7).is_between(1, 7) == yes
+ assert 7.is_between(1, 10) == yes
+ assert 7.is_between(10, 1) == yes
+ assert 7.is_between(100, 200) == no
+ assert 7.is_between(1, 7) == yes
Int.is_prime:
short: check if an integer is prime
@@ -190,8 +190,8 @@ Int.is_prime:
description: >
The number of repetitions for primality tests.
example: |
- assert (7).is_prime() == yes
- assert (6).is_prime() == no
+ assert 7.is_prime() == yes
+ assert 6.is_prime() == no
Int.next_prime:
short: get the next prime
@@ -212,7 +212,7 @@ Int.next_prime:
description: >
The integer after which to find the next prime.
example: |
- assert (11).next_prime() == 13
+ assert 11.next_prime() == 13
Int.octal:
short: convert to octal
@@ -238,7 +238,7 @@ Int.octal:
description: >
Whether to include a "0o" prefix.
example: |
- assert (64).octal(digits=4, prefix=yes) == "0o0100"
+ assert 64.octal(digits=4, prefix=yes) == "0o0100"
Int.onward:
short: iterate from a number onward
@@ -261,7 +261,7 @@ Int.onward:
The increment step size.
example: |
nums : &[Int] = &[]
- for i in (5).onward()
+ for i in 5.onward()
nums.insert(i)
stop if i == 10
assert nums[] == [5, 6, 7, 8, 9, 10]
@@ -334,7 +334,7 @@ Int.prev_prime:
description: >
The integer before which to find the previous prime.
example: |
- assert (11).prev_prime() == 7
+ assert 11.prev_prime() == 7
Int.sqrt:
short: square root
@@ -350,8 +350,8 @@ Int.sqrt:
description: >
The integer whose square root is to be calculated.
example: |
- assert (16).sqrt() == 4
- assert (17).sqrt() == 4
+ assert 16.sqrt() == 4
+ assert 17.sqrt() == 4
Int.to:
short: iterate a range of integers
@@ -376,14 +376,14 @@ Int.to:
description: >
An optional step size to use. If unspecified or `none`, the step will be inferred to be `+1` if `last >= first`, otherwise `-1`.
example: |
- iter := (2).to(5)
+ iter := 2.to(5)
assert iter() == 2
assert iter() == 3
assert iter() == 4
assert iter() == 5
assert iter() == none
- assert [x for x in (2).to(5)] == [2, 3, 4, 5]
- assert [x for x in (5).to(2)] == [5, 4, 3, 2]
- assert [x for x in (2).to(5, step=2)] == [2, 4]
+ assert [x for x in 2.to(5)] == [2, 3, 4, 5]
+ assert [x for x in 5.to(2)] == [5, 4, 3, 2]
+ assert [x for x in 2.to(5, step=2)] == [2, 4]
diff --git a/man/man3/tomo-Int.choose.3 b/man/man3/tomo-Int.choose.3
index 1e5c705b..f8b310e1 100644
--- a/man/man3/tomo-Int.choose.3
+++ b/man/man3/tomo-Int.choose.3
@@ -1,8 +1,8 @@
'\" t
-.\" Copyright (c) 2025 Bruce Hill
+.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
-.TH Int.choose 3 2025-11-29 "Tomo man-pages"
+.TH Int.choose 3 2026-01-19 "Tomo man-pages"
.SH NAME
Int.choose \- binomial coefficient
.SH LIBRARY
@@ -30,7 +30,7 @@ The binomial coefficient, equivalent to the number of ways to uniquely choose `k
.SH EXAMPLES
.EX
-assert (4).choose(2) == 6
+assert 4.choose(2) == 6
.EE
.SH SEE ALSO
.BR Tomo-Int (3)
diff --git a/man/man3/tomo-Int.clamped.3 b/man/man3/tomo-Int.clamped.3
index 5d846a21..5fee2f79 100644
--- a/man/man3/tomo-Int.clamped.3
+++ b/man/man3/tomo-Int.clamped.3
@@ -1,8 +1,8 @@
'\" t
-.\" Copyright (c) 2025 Bruce Hill
+.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
-.TH Int.clamped 3 2025-11-29 "Tomo man-pages"
+.TH Int.clamped 3 2026-01-19 "Tomo man-pages"
.SH NAME
Int.clamped \- clamp an integer
.SH LIBRARY
@@ -31,7 +31,7 @@ The first argument clamped between the other two arguments.
.SH EXAMPLES
.EX
-assert (2).clamped(5, 10) == 5
+assert 2.clamped(5, 10) == 5
.EE
.SH SEE ALSO
.BR Tomo-Int (3)
diff --git a/man/man3/tomo-Int.factorial.3 b/man/man3/tomo-Int.factorial.3
index e7105287..f4f0572b 100644
--- a/man/man3/tomo-Int.factorial.3
+++ b/man/man3/tomo-Int.factorial.3
@@ -1,8 +1,8 @@
'\" t
-.\" Copyright (c) 2025 Bruce Hill
+.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
-.TH Int.factorial 3 2025-11-29 "Tomo man-pages"
+.TH Int.factorial 3 2026-01-19 "Tomo man-pages"
.SH NAME
Int.factorial \- factorial
.SH LIBRARY
@@ -29,7 +29,7 @@ The factorial of the given integer.
.SH EXAMPLES
.EX
-assert (10).factorial() == 3628800
+assert 10.factorial() == 3628800
.EE
.SH SEE ALSO
.BR Tomo-Int (3)
diff --git a/man/man3/tomo-Int.get_bit.3 b/man/man3/tomo-Int.get_bit.3
index bf9f11b2..de53c38d 100644
--- a/man/man3/tomo-Int.get_bit.3
+++ b/man/man3/tomo-Int.get_bit.3
@@ -1,8 +1,8 @@
'\" t
-.\" Copyright (c) 2025 Bruce Hill
+.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
-.TH Int.get_bit 3 2025-11-29 "Tomo man-pages"
+.TH Int.get_bit 3 2026-01-19 "Tomo man-pages"
.SH NAME
Int.get_bit \- check whether a bit is set
.SH LIBRARY
@@ -33,10 +33,10 @@ For fixed-size integers, the bit index must be between 1 and the number of bits
.SH EXAMPLES
.EX
-assert (6).get_bit(1) == no
-assert (6).get_bit(2) == yes
-assert (6).get_bit(3) == yes
-assert (6).get_bit(4) == no
+assert 6.get_bit(1) == no
+assert 6.get_bit(2) == yes
+assert 6.get_bit(3) == yes
+assert 6.get_bit(4) == no
.EE
.SH SEE ALSO
.BR Tomo-Int (3)
diff --git a/man/man3/tomo-Int.hex.3 b/man/man3/tomo-Int.hex.3
index 37fe45e4..d61e363a 100644
--- a/man/man3/tomo-Int.hex.3
+++ b/man/man3/tomo-Int.hex.3
@@ -1,8 +1,8 @@
'\" t
-.\" Copyright (c) 2025 Bruce Hill
+.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
-.TH Int.hex 3 2025-11-29 "Tomo man-pages"
+.TH Int.hex 3 2026-01-19 "Tomo man-pages"
.SH NAME
Int.hex \- convert to hexidecimal
.SH LIBRARY
@@ -32,7 +32,7 @@ The hexadecimal string representation of the integer.
.SH EXAMPLES
.EX
-assert (255).hex(digits=4, uppercase=yes, prefix=yes) == "0x00FF"
+assert 255.hex(digits=4, uppercase=yes, prefix=yes) == "0x00FF"
.EE
.SH SEE ALSO
.BR Tomo-Int (3)
diff --git a/man/man3/tomo-Int.is_between.3 b/man/man3/tomo-Int.is_between.3
index fd54eb41..d902f9a6 100644
--- a/man/man3/tomo-Int.is_between.3
+++ b/man/man3/tomo-Int.is_between.3
@@ -1,8 +1,8 @@
'\" t
-.\" Copyright (c) 2025 Bruce Hill
+.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
-.TH Int.is_between 3 2025-12-31 "Tomo man-pages"
+.TH Int.is_between 3 2026-01-19 "Tomo man-pages"
.SH NAME
Int.is_between \- test if an int is in a range
.SH LIBRARY
@@ -31,10 +31,10 @@ b Int The other end of the range to check (inclusive).
.SH EXAMPLES
.EX
-assert (7).is_between(1, 10) == yes
-assert (7).is_between(10, 1) == yes
-assert (7).is_between(100, 200) == no
-assert (7).is_between(1, 7) == yes
+assert 7.is_between(1, 10) == yes
+assert 7.is_between(10, 1) == yes
+assert 7.is_between(100, 200) == no
+assert 7.is_between(1, 7) == yes
.EE
.SH SEE ALSO
.BR Tomo-Int (3)
diff --git a/man/man3/tomo-Int.is_prime.3 b/man/man3/tomo-Int.is_prime.3
index 5dc2c826..1d3d44a7 100644
--- a/man/man3/tomo-Int.is_prime.3
+++ b/man/man3/tomo-Int.is_prime.3
@@ -1,8 +1,8 @@
'\" t
-.\" Copyright (c) 2025 Bruce Hill
+.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
-.TH Int.is_prime 3 2025-11-29 "Tomo man-pages"
+.TH Int.is_prime 3 2026-01-19 "Tomo man-pages"
.SH NAME
Int.is_prime \- check if an integer is prime
.SH LIBRARY
@@ -33,8 +33,8 @@ This function is _probabilistic_. With the default arguments, the chances of get
.SH EXAMPLES
.EX
-assert (7).is_prime() == yes
-assert (6).is_prime() == no
+assert 7.is_prime() == yes
+assert 6.is_prime() == no
.EE
.SH SEE ALSO
.BR Tomo-Int (3)
diff --git a/man/man3/tomo-Int.next_prime.3 b/man/man3/tomo-Int.next_prime.3
index ab2c4307..cc577d0f 100644
--- a/man/man3/tomo-Int.next_prime.3
+++ b/man/man3/tomo-Int.next_prime.3
@@ -1,8 +1,8 @@
'\" t
-.\" Copyright (c) 2025 Bruce Hill
+.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
-.TH Int.next_prime 3 2025-11-29 "Tomo man-pages"
+.TH Int.next_prime 3 2026-01-19 "Tomo man-pages"
.SH NAME
Int.next_prime \- get the next prime
.SH LIBRARY
@@ -32,7 +32,7 @@ This function is _probabilistic_, but the chances of getting an incorrect answer
.SH EXAMPLES
.EX
-assert (11).next_prime() == 13
+assert 11.next_prime() == 13
.EE
.SH SEE ALSO
.BR Tomo-Int (3)
diff --git a/man/man3/tomo-Int.octal.3 b/man/man3/tomo-Int.octal.3
index 627a2e9f..dc8ddf92 100644
--- a/man/man3/tomo-Int.octal.3
+++ b/man/man3/tomo-Int.octal.3
@@ -1,8 +1,8 @@
'\" t
-.\" Copyright (c) 2025 Bruce Hill
+.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
-.TH Int.octal 3 2025-11-29 "Tomo man-pages"
+.TH Int.octal 3 2026-01-19 "Tomo man-pages"
.SH NAME
Int.octal \- convert to octal
.SH LIBRARY
@@ -31,7 +31,7 @@ The octal string representation of the integer.
.SH EXAMPLES
.EX
-assert (64).octal(digits=4, prefix=yes) == "0o0100"
+assert 64.octal(digits=4, prefix=yes) == "0o0100"
.EE
.SH SEE ALSO
.BR Tomo-Int (3)
diff --git a/man/man3/tomo-Int.onward.3 b/man/man3/tomo-Int.onward.3
index 596cf842..6cf9ffc8 100644
--- a/man/man3/tomo-Int.onward.3
+++ b/man/man3/tomo-Int.onward.3
@@ -1,8 +1,8 @@
'\" t
-.\" Copyright (c) 2025 Bruce Hill
+.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
-.TH Int.onward 3 2025-11-29 "Tomo man-pages"
+.TH Int.onward 3 2026-01-19 "Tomo man-pages"
.SH NAME
Int.onward \- iterate from a number onward
.SH LIBRARY
@@ -31,7 +31,7 @@ An iterator function that counts onward from the starting integer.
.SH EXAMPLES
.EX
nums : &[Int] = &[]
-for i in (5).onward()
+for i in 5.onward()
nums.insert(i)
stop if i == 10
assert nums[] == [5, 6, 7, 8, 9, 10]
diff --git a/man/man3/tomo-Int.prev_prime.3 b/man/man3/tomo-Int.prev_prime.3
index 87f7be36..6b4564df 100644
--- a/man/man3/tomo-Int.prev_prime.3
+++ b/man/man3/tomo-Int.prev_prime.3
@@ -1,8 +1,8 @@
'\" t
-.\" Copyright (c) 2025 Bruce Hill
+.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
-.TH Int.prev_prime 3 2025-11-29 "Tomo man-pages"
+.TH Int.prev_prime 3 2026-01-19 "Tomo man-pages"
.SH NAME
Int.prev_prime \- get the previous prime
.SH LIBRARY
@@ -32,7 +32,7 @@ This function is _probabilistic_, but the chances of getting an incorrect answer
.SH EXAMPLES
.EX
-assert (11).prev_prime() == 7
+assert 11.prev_prime() == 7
.EE
.SH SEE ALSO
.BR Tomo-Int (3)
diff --git a/man/man3/tomo-Int.sqrt.3 b/man/man3/tomo-Int.sqrt.3
index 6a3e7eaf..fa7013a5 100644
--- a/man/man3/tomo-Int.sqrt.3
+++ b/man/man3/tomo-Int.sqrt.3
@@ -1,8 +1,8 @@
'\" t
-.\" Copyright (c) 2025 Bruce Hill
+.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
-.TH Int.sqrt 3 2025-11-29 "Tomo man-pages"
+.TH Int.sqrt 3 2026-01-19 "Tomo man-pages"
.SH NAME
Int.sqrt \- square root
.SH LIBRARY
@@ -29,8 +29,8 @@ The integer part of the square root of `x`.
.SH EXAMPLES
.EX
-assert (16).sqrt() == 4
-assert (17).sqrt() == 4
+assert 16.sqrt() == 4
+assert 17.sqrt() == 4
.EE
.SH SEE ALSO
.BR Tomo-Int (3)
diff --git a/man/man3/tomo-Int.to.3 b/man/man3/tomo-Int.to.3
index 9c0fe4dc..e5ba9158 100644
--- a/man/man3/tomo-Int.to.3
+++ b/man/man3/tomo-Int.to.3
@@ -1,8 +1,8 @@
'\" t
-.\" Copyright (c) 2025 Bruce Hill
+.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
-.TH Int.to 3 2025-11-29 "Tomo man-pages"
+.TH Int.to 3 2026-01-19 "Tomo man-pages"
.SH NAME
Int.to \- iterate a range of integers
.SH LIBRARY
@@ -31,16 +31,16 @@ An iterator function that returns each integer in the given range (inclusive).
.SH EXAMPLES
.EX
-iter := (2).to(5)
+iter := 2.to(5)
assert iter() == 2
assert iter() == 3
assert iter() == 4
assert iter() == 5
assert iter() == none
-assert [x for x in (2).to(5)] == [2, 3, 4, 5]
-assert [x for x in (5).to(2)] == [5, 4, 3, 2]
-assert [x for x in (2).to(5, step=2)] == [2, 4]
+assert [x for x in 2.to(5)] == [2, 3, 4, 5]
+assert [x for x in 5.to(2)] == [5, 4, 3, 2]
+assert [x for x in 2.to(5, step=2)] == [2, 4]
.EE
.SH SEE ALSO
.BR Tomo-Int (3)
diff --git a/src/parse/numbers.c b/src/parse/numbers.c
index 4e746525..4e7937d9 100644
--- a/src/parse/numbers.c
+++ b/src/parse/numbers.c
@@ -57,6 +57,7 @@ ast_t *parse_num(parse_ctx_t *ctx, const char *pos) {
size_t len = strspn(pos, "0123456789_");
if (strncmp(pos + len, "..", 2) == 0) return NULL;
+ else if (pos[len] == '.' && is_xid_start_next(pos + len + 1)) return NULL;
else if (pos[len] == '.') len += 1 + strspn(pos + len + 1, "0123456789");
else if (pos[len] != 'e' && pos[len] != 'f' && pos[len] != '%') return NULL;
if (pos[len] == 'e') {
diff --git a/src/parse/utils.c b/src/parse/utils.c
index 03e0ebcd..2df3f1a9 100644
--- a/src/parse/utils.c
+++ b/src/parse/utils.c
@@ -57,6 +57,12 @@ size_t match(const char **pos, const char *target) {
return len;
}
+bool is_xid_start_next(const char *pos) {
+ ucs4_t point = 0;
+ u8_next(&point, (const uint8_t *)pos);
+ return uc_is_property_xid_start(point);
+}
+
bool is_xid_continue_next(const char *pos) {
ucs4_t point = 0;
u8_next(&point, (const uint8_t *)pos);
diff --git a/src/parse/utils.h b/src/parse/utils.h
index b8fb0756..89b1cc82 100644
--- a/src/parse/utils.h
+++ b/src/parse/utils.h
@@ -22,6 +22,7 @@ bool indent(parse_ctx_t *ctx, const char **pos);
const char *eol(const char *str);
PUREFUNC int64_t get_indent(parse_ctx_t *ctx, const char *pos);
const char *unescape(parse_ctx_t *ctx, const char **out);
+bool is_xid_start_next(const char *pos);
bool is_xid_continue_next(const char *pos);
bool newline_with_indentation(const char **out, int64_t target);
bool match_separator(parse_ctx_t *ctx, const char **pos);
diff --git a/test/integers.tm b/test/integers.tm
index 2d07beda..514acd34 100644
--- a/test/integers.tm
+++ b/test/integers.tm
@@ -59,8 +59,8 @@ func main()
for d in interesting_denominators
assert (n/d)*d + (n mod d) == n
- assert (0).next_prime() == 2
- assert (7).next_prime() == 11
+ assert 0.next_prime() == 2
+ assert 7.next_prime() == 11
assert (and: p.is_prime() for p in [
2, 3, 5, 7,
137372146048179869781170214707,
@@ -88,19 +88,19 @@ func main()
assert Int64(yes) == Int64(1)
assert Int64(no) == Int64(0)
- assert (4).choose(2) == 6
+ assert 4.choose(2) == 6
- assert (4).factorial() == 24
+ assert 4.factorial() == 24
- assert (3).is_between(1, 5) == yes
- assert (3).is_between(1, 3) == yes
- assert (3).is_between(5, 1) == yes
- assert (3).is_between(100, 200) == no
+ assert 3.is_between(1, 5) == yes
+ assert 3.is_between(1, 3) == yes
+ assert 3.is_between(5, 1) == yes
+ assert 3.is_between(100, 200) == no
- assert (6).get_bit(1) == no
- assert (6).get_bit(2) == yes
- assert (6).get_bit(3) == yes
- assert (6).get_bit(4) == no
+ assert 6.get_bit(1) == no
+ assert 6.get_bit(2) == yes
+ assert 6.get_bit(3) == yes
+ assert 6.get_bit(4) == no
assert Int64(6).get_bit(1) == no
assert Int64(6).get_bit(2) == yes
@@ -118,7 +118,7 @@ func main()
assert Int.parse("-0o10") == -8
assert Int.parse("-0b10") == -2
- for base in (2).to(36)
+ for base in 2.to(36)
assert Int.parse("10", base=base) == base
assert Int.parse("111", base=1) == 3