goscript 0.0.25 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/cmd/goscript/cmd_compile.go +0 -3
- package/cmd/goscript/deps.go +11 -0
- package/compiler/analysis.go +259 -55
- package/compiler/assignment.go +2 -2
- package/compiler/builtin_test.go +1 -1
- package/compiler/compiler.go +201 -49
- package/compiler/compiler_test.go +53 -0
- package/compiler/composite-lit.go +32 -8
- package/compiler/decl.go +6 -6
- package/compiler/expr-call.go +83 -0
- package/compiler/expr.go +1 -1
- package/compiler/protobuf.go +557 -0
- package/compiler/spec-struct.go +4 -0
- package/compiler/spec-value.go +11 -3
- package/compiler/spec.go +18 -1
- package/compiler/stmt-assign.go +35 -0
- package/compiler/type-assert.go +87 -0
- package/compiler/type.go +5 -2
- package/dist/gs/builtin/builtin.d.ts +19 -1
- package/dist/gs/builtin/builtin.js +85 -5
- package/dist/gs/builtin/builtin.js.map +1 -1
- package/dist/gs/builtin/channel.js.map +1 -1
- package/dist/gs/builtin/slice.d.ts +1 -1
- package/dist/gs/builtin/slice.js +59 -26
- package/dist/gs/builtin/slice.js.map +1 -1
- package/dist/gs/cmp/index.js.map +1 -1
- package/dist/gs/context/context.d.ts +1 -1
- package/dist/gs/context/context.js +20 -11
- package/dist/gs/context/context.js.map +1 -1
- package/dist/gs/errors/errors.d.ts +7 -0
- package/dist/gs/errors/errors.js +190 -0
- package/dist/gs/errors/errors.js.map +1 -0
- package/dist/gs/errors/index.d.ts +1 -0
- package/dist/gs/errors/index.js +2 -0
- package/dist/gs/errors/index.js.map +1 -0
- package/dist/gs/internal/goarch/index.js +1 -1
- package/dist/gs/internal/goarch/index.js.map +1 -1
- package/dist/gs/io/index.d.ts +1 -0
- package/dist/gs/io/index.js +2 -0
- package/dist/gs/io/index.js.map +1 -0
- package/dist/gs/io/io.d.ts +107 -0
- package/dist/gs/io/io.js +385 -0
- package/dist/gs/io/io.js.map +1 -0
- package/dist/gs/iter/iter.js.map +1 -1
- package/dist/gs/math/bits/index.js +34 -32
- package/dist/gs/math/bits/index.js.map +1 -1
- package/dist/gs/runtime/runtime.d.ts +1 -0
- package/dist/gs/runtime/runtime.js +15 -18
- package/dist/gs/runtime/runtime.js.map +1 -1
- package/dist/gs/slices/slices.d.ts +1 -1
- package/dist/gs/slices/slices.js +1 -1
- package/dist/gs/slices/slices.js.map +1 -1
- package/dist/gs/strings/builder.d.ts +18 -0
- package/dist/gs/strings/builder.js +205 -0
- package/dist/gs/strings/builder.js.map +1 -0
- package/dist/gs/strings/clone.d.ts +1 -0
- package/dist/gs/strings/clone.js +16 -0
- package/dist/gs/strings/clone.js.map +1 -0
- package/dist/gs/strings/compare.d.ts +1 -0
- package/dist/gs/strings/compare.js +14 -0
- package/dist/gs/strings/compare.js.map +1 -0
- package/dist/gs/strings/index.d.ts +2 -0
- package/dist/gs/strings/index.js +3 -0
- package/dist/gs/strings/index.js.map +1 -0
- package/dist/gs/strings/iter.d.ts +8 -0
- package/dist/gs/strings/iter.js +160 -0
- package/dist/gs/strings/iter.js.map +1 -0
- package/dist/gs/strings/reader.d.ts +34 -0
- package/dist/gs/strings/reader.js +418 -0
- package/dist/gs/strings/reader.js.map +1 -0
- package/dist/gs/strings/replace.d.ts +106 -0
- package/dist/gs/strings/replace.js +1136 -0
- package/dist/gs/strings/replace.js.map +1 -0
- package/dist/gs/strings/search.d.ts +24 -0
- package/dist/gs/strings/search.js +169 -0
- package/dist/gs/strings/search.js.map +1 -0
- package/dist/gs/strings/strings.d.ts +47 -0
- package/dist/gs/strings/strings.js +418 -0
- package/dist/gs/strings/strings.js.map +1 -0
- package/dist/gs/stringslite/index.d.ts +1 -0
- package/dist/gs/stringslite/index.js +2 -0
- package/dist/gs/stringslite/index.js.map +1 -0
- package/dist/gs/stringslite/strings.d.ts +11 -0
- package/dist/gs/stringslite/strings.js +67 -0
- package/dist/gs/stringslite/strings.js.map +1 -0
- package/dist/gs/sync/index.d.ts +1 -0
- package/dist/gs/sync/index.js +2 -0
- package/dist/gs/sync/index.js.map +1 -0
- package/dist/gs/sync/sync.d.ts +79 -0
- package/dist/gs/sync/sync.js +392 -0
- package/dist/gs/sync/sync.js.map +1 -0
- package/dist/gs/time/time.js +7 -7
- package/dist/gs/time/time.js.map +1 -1
- package/dist/gs/unicode/index.d.ts +1 -0
- package/dist/gs/unicode/index.js +2 -0
- package/dist/gs/unicode/index.js.map +1 -0
- package/dist/gs/unicode/unicode.d.ts +105 -0
- package/dist/gs/unicode/unicode.js +332 -0
- package/dist/gs/unicode/unicode.js.map +1 -0
- package/dist/gs/unicode/utf8/index.d.ts +1 -0
- package/dist/gs/unicode/utf8/index.js +3 -0
- package/dist/gs/unicode/utf8/index.js.map +1 -0
- package/dist/gs/unicode/utf8/utf8.d.ts +20 -0
- package/dist/gs/unicode/utf8/utf8.js +196 -0
- package/dist/gs/unicode/utf8/utf8.js.map +1 -0
- package/dist/gs/unsafe/index.d.ts +1 -0
- package/dist/gs/unsafe/index.js +2 -0
- package/dist/gs/unsafe/index.js.map +1 -0
- package/dist/gs/unsafe/unsafe.d.ts +11 -0
- package/dist/gs/unsafe/unsafe.js +44 -0
- package/dist/gs/unsafe/unsafe.js.map +1 -0
- package/go.mod +2 -1
- package/go.sum +6 -2
- package/gs/README.md +6 -0
- package/gs/builtin/builtin.ts +158 -0
- package/gs/builtin/channel.ts +683 -0
- package/gs/builtin/defer.ts +58 -0
- package/gs/builtin/index.ts +1 -0
- package/gs/builtin/io.ts +22 -0
- package/gs/builtin/map.ts +50 -0
- package/gs/builtin/slice.ts +1030 -0
- package/gs/builtin/type.ts +1106 -0
- package/gs/builtin/varRef.ts +25 -0
- package/gs/cmp/godoc.txt +8 -0
- package/gs/cmp/index.ts +29 -0
- package/gs/context/context.ts +401 -0
- package/gs/context/godoc.txt +69 -0
- package/gs/context/index.ts +1 -0
- package/gs/errors/errors.ts +223 -0
- package/gs/errors/godoc.txt +63 -0
- package/gs/errors/index.ts +1 -0
- package/gs/internal/goarch/godoc.txt +39 -0
- package/gs/internal/goarch/index.ts +18 -0
- package/gs/io/godoc.txt +61 -0
- package/gs/io/index.ts +1 -0
- package/gs/io/io.go +75 -0
- package/gs/io/io.ts +546 -0
- package/gs/iter/godoc.txt +203 -0
- package/gs/iter/index.ts +1 -0
- package/gs/iter/iter.ts +117 -0
- package/gs/math/bits/index.ts +356 -0
- package/gs/math/godoc.txt +76 -0
- package/gs/runtime/godoc.txt +331 -0
- package/gs/runtime/index.ts +1 -0
- package/gs/runtime/runtime.ts +178 -0
- package/gs/slices/godoc.txt +44 -0
- package/gs/slices/index.ts +1 -0
- package/gs/slices/slices.ts +22 -0
- package/gs/strings/builder.test.ts +121 -0
- package/gs/strings/builder.ts +223 -0
- package/gs/strings/clone.test.ts +43 -0
- package/gs/strings/clone.ts +17 -0
- package/gs/strings/compare.test.ts +84 -0
- package/gs/strings/compare.ts +13 -0
- package/gs/strings/godoc.txt +66 -0
- package/gs/strings/index.ts +2 -0
- package/gs/strings/iter.test.ts +343 -0
- package/gs/strings/iter.ts +171 -0
- package/gs/strings/reader.test.ts +243 -0
- package/gs/strings/reader.ts +451 -0
- package/gs/strings/replace.test.ts +181 -0
- package/gs/strings/replace.ts +1310 -0
- package/gs/strings/search.test.ts +214 -0
- package/gs/strings/search.ts +213 -0
- package/gs/strings/strings.test.ts +477 -0
- package/gs/strings/strings.ts +510 -0
- package/gs/stringslite/godoc.txt +17 -0
- package/gs/stringslite/index.ts +1 -0
- package/gs/stringslite/strings.ts +82 -0
- package/gs/sync/godoc.txt +21 -0
- package/gs/sync/index.ts +1 -0
- package/gs/sync/sync.go +64 -0
- package/gs/sync/sync.ts +449 -0
- package/gs/time/godoc.md +116 -0
- package/gs/time/godoc.txt +116 -0
- package/gs/time/index.ts +1 -0
- package/gs/time/time.ts +272 -0
- package/gs/unicode/godoc.txt +52 -0
- package/gs/unicode/index.ts +1 -0
- package/gs/unicode/unicode.go +38 -0
- package/gs/unicode/unicode.ts +418 -0
- package/gs/unicode/utf8/godoc.txt +22 -0
- package/gs/unicode/utf8/index.ts +2 -0
- package/gs/unicode/utf8/utf8.ts +227 -0
- package/gs/unsafe/godoc.txt +19 -0
- package/gs/unsafe/index.ts +1 -0
- package/gs/unsafe/unsafe.test.ts +68 -0
- package/gs/unsafe/unsafe.ts +77 -0
- package/package.json +6 -4
package/gs/time/time.ts
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
// Time represents a time instant with nanosecond precision
|
|
2
|
+
export class Time {
|
|
3
|
+
private _date: globalThis.Date
|
|
4
|
+
private _nsec: number // nanoseconds within the second
|
|
5
|
+
private _monotonic?: number // high-resolution monotonic timestamp in nanoseconds
|
|
6
|
+
|
|
7
|
+
constructor(date: globalThis.Date, nsec: number = 0, monotonic?: number) {
|
|
8
|
+
this._date = new globalThis.Date(date.getTime())
|
|
9
|
+
this._nsec = nsec
|
|
10
|
+
this._monotonic = monotonic
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// clone returns a copy of this Time instance
|
|
14
|
+
public clone(): Time {
|
|
15
|
+
return new Time(this._date, this._nsec, this._monotonic)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Sub returns the duration t-u
|
|
19
|
+
// If both times have monotonic readings, use them for accurate duration calculation
|
|
20
|
+
public Sub(u: Time): Duration {
|
|
21
|
+
// If both times have monotonic readings, use them for more accurate duration calculation
|
|
22
|
+
if (this._monotonic !== undefined && u._monotonic !== undefined) {
|
|
23
|
+
const diffNs = this._monotonic - u._monotonic
|
|
24
|
+
return new Duration(diffNs)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Fallback to Date-based calculation
|
|
28
|
+
const diffMs = this._date.getTime() - u._date.getTime()
|
|
29
|
+
const diffNs = this._nsec - u._nsec
|
|
30
|
+
return new Duration(diffMs * 1000000 + diffNs) // Convert ms to ns and add ns difference
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Add adds the duration d to t, returning the sum
|
|
34
|
+
// Preserves monotonic reading if present
|
|
35
|
+
public Add(d: Duration): Time {
|
|
36
|
+
const durationNs = d.valueOf()
|
|
37
|
+
const newDate = new globalThis.Date(
|
|
38
|
+
this._date.getTime() + Math.floor(durationNs / 1000000),
|
|
39
|
+
)
|
|
40
|
+
const newNsec = this._nsec + (durationNs % 1000000)
|
|
41
|
+
const newMonotonic =
|
|
42
|
+
this._monotonic !== undefined ? this._monotonic + durationNs : undefined
|
|
43
|
+
return new Time(newDate, newNsec, newMonotonic)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Equal reports whether t and u represent the same time instant
|
|
47
|
+
// Uses monotonic clock if both times have it
|
|
48
|
+
public Equal(u: Time): boolean {
|
|
49
|
+
if (this._monotonic !== undefined && u._monotonic !== undefined) {
|
|
50
|
+
return this._monotonic === u._monotonic
|
|
51
|
+
}
|
|
52
|
+
return this._date.getTime() === u._date.getTime() && this._nsec === u._nsec
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Before reports whether the time instant t is before u
|
|
56
|
+
// Uses monotonic clock if both times have it
|
|
57
|
+
public Before(u: Time): boolean {
|
|
58
|
+
if (this._monotonic !== undefined && u._monotonic !== undefined) {
|
|
59
|
+
return this._monotonic < u._monotonic
|
|
60
|
+
}
|
|
61
|
+
const thisMs = this._date.getTime()
|
|
62
|
+
const uMs = u._date.getTime()
|
|
63
|
+
return thisMs < uMs || (thisMs === uMs && this._nsec < u._nsec)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// After reports whether the time instant t is after u
|
|
67
|
+
// Uses monotonic clock if both times have it
|
|
68
|
+
public After(u: Time): boolean {
|
|
69
|
+
if (this._monotonic !== undefined && u._monotonic !== undefined) {
|
|
70
|
+
return this._monotonic > u._monotonic
|
|
71
|
+
}
|
|
72
|
+
const thisMs = this._date.getTime()
|
|
73
|
+
const uMs = u._date.getTime()
|
|
74
|
+
return thisMs > uMs || (thisMs === uMs && this._nsec > u._nsec)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Round returns the result of rounding t to the nearest multiple of d
|
|
78
|
+
// Strips monotonic reading as per Go specification
|
|
79
|
+
public Round(d: Duration): Time {
|
|
80
|
+
// Implementation would round to nearest duration
|
|
81
|
+
// For now, simplified version that strips monotonic reading
|
|
82
|
+
return new Time(this._date, this._nsec)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Truncate returns the result of rounding t down to a multiple of d
|
|
86
|
+
// Strips monotonic reading as per Go specification
|
|
87
|
+
public Truncate(d: Duration): Time {
|
|
88
|
+
// Implementation would truncate to duration
|
|
89
|
+
// For now, simplified version that strips monotonic reading
|
|
90
|
+
return new Time(this._date, this._nsec)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// String returns the time formatted as a string
|
|
94
|
+
public String(): string {
|
|
95
|
+
// Format as "YYYY-MM-DD HH:MM:SS +0000 UTC" to match Go's format
|
|
96
|
+
const year = this._date.getUTCFullYear()
|
|
97
|
+
const month = String(this._date.getUTCMonth() + 1).padStart(2, '0')
|
|
98
|
+
const day = String(this._date.getUTCDate()).padStart(2, '0')
|
|
99
|
+
const hour = String(this._date.getUTCHours()).padStart(2, '0')
|
|
100
|
+
const minute = String(this._date.getUTCMinutes()).padStart(2, '0')
|
|
101
|
+
const second = String(this._date.getUTCSeconds()).padStart(2, '0')
|
|
102
|
+
|
|
103
|
+
let result = `${year}-${month}-${day} ${hour}:${minute}:${second} +0000 UTC`
|
|
104
|
+
|
|
105
|
+
// Include monotonic reading in debug output as per Go specification
|
|
106
|
+
if (this._monotonic !== undefined) {
|
|
107
|
+
result += ` m=${this._monotonic}`
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return result
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Duration represents a span of time
|
|
115
|
+
export class Duration {
|
|
116
|
+
private _nanoseconds: number
|
|
117
|
+
|
|
118
|
+
constructor(nanoseconds: number) {
|
|
119
|
+
this._nanoseconds = nanoseconds
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Compare this duration with another
|
|
123
|
+
public lt(other: Duration): boolean {
|
|
124
|
+
return this._nanoseconds < other._nanoseconds
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Multiply duration by a number (for expressions like Hour * 24)
|
|
128
|
+
public static multiply(duration: Duration, multiplier: number): Duration {
|
|
129
|
+
return new Duration(duration._nanoseconds * multiplier)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Add support for * operator
|
|
133
|
+
public multiply(multiplier: number): Duration {
|
|
134
|
+
return Duration.multiply(this, multiplier)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// valueOf returns the primitive number value, allowing direct comparison with < > etc
|
|
138
|
+
public valueOf(): number {
|
|
139
|
+
return this._nanoseconds
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// toString for string representation
|
|
143
|
+
public toString(): string {
|
|
144
|
+
return this._nanoseconds.toString() + 'ns'
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Override multiplication operator for Duration * number
|
|
149
|
+
export function multiplyDuration(
|
|
150
|
+
duration: Duration,
|
|
151
|
+
multiplier: number,
|
|
152
|
+
): Duration {
|
|
153
|
+
return Duration.multiply(duration, multiplier)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Location represents a time zone
|
|
157
|
+
export class Location {
|
|
158
|
+
private _name: string
|
|
159
|
+
|
|
160
|
+
constructor(name: string) {
|
|
161
|
+
this._name = name
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
public get name(): string {
|
|
165
|
+
return this._name
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Month represents a month of the year
|
|
170
|
+
export enum Month {
|
|
171
|
+
January = 1,
|
|
172
|
+
February = 2,
|
|
173
|
+
March = 3,
|
|
174
|
+
April = 4,
|
|
175
|
+
May = 5,
|
|
176
|
+
June = 6,
|
|
177
|
+
July = 7,
|
|
178
|
+
August = 8,
|
|
179
|
+
September = 9,
|
|
180
|
+
October = 10,
|
|
181
|
+
November = 11,
|
|
182
|
+
December = 12,
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Now returns the current local time with monotonic clock reading
|
|
186
|
+
export function Now(): Time {
|
|
187
|
+
const date = new globalThis.Date()
|
|
188
|
+
let monotonic: number | undefined
|
|
189
|
+
|
|
190
|
+
// Use performance.now() for high-resolution monotonic timing if available
|
|
191
|
+
if (typeof performance !== 'undefined' && performance.now) {
|
|
192
|
+
// performance.now() returns milliseconds with sub-millisecond precision
|
|
193
|
+
// Convert to nanoseconds for consistency with Go's time package
|
|
194
|
+
monotonic = performance.now() * 1000000
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return new Time(date, 0, monotonic)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Date returns the Time corresponding to
|
|
201
|
+
// yyyy-mm-dd hh:mm:ss + nsec nanoseconds
|
|
202
|
+
// in the appropriate zone for that time in the given location
|
|
203
|
+
// Does not include monotonic reading as per Go specification
|
|
204
|
+
export function Date(
|
|
205
|
+
year: number,
|
|
206
|
+
month: Month,
|
|
207
|
+
day: number,
|
|
208
|
+
hour: number,
|
|
209
|
+
min: number,
|
|
210
|
+
sec: number,
|
|
211
|
+
nsec: number,
|
|
212
|
+
loc: Location,
|
|
213
|
+
): Time {
|
|
214
|
+
let date: globalThis.Date
|
|
215
|
+
if (loc.name === 'UTC') {
|
|
216
|
+
// Use Date.UTC for proper UTC handling
|
|
217
|
+
const utcTime = globalThis.Date.UTC(
|
|
218
|
+
year,
|
|
219
|
+
month - 1,
|
|
220
|
+
day,
|
|
221
|
+
hour,
|
|
222
|
+
min,
|
|
223
|
+
sec,
|
|
224
|
+
Math.floor(nsec / 1000000),
|
|
225
|
+
)
|
|
226
|
+
date = new globalThis.Date(utcTime)
|
|
227
|
+
} else {
|
|
228
|
+
// For local time or other timezones, use regular Date constructor
|
|
229
|
+
date = new globalThis.Date(
|
|
230
|
+
year,
|
|
231
|
+
month - 1,
|
|
232
|
+
day,
|
|
233
|
+
hour,
|
|
234
|
+
min,
|
|
235
|
+
sec,
|
|
236
|
+
Math.floor(nsec / 1000000),
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
return new Time(date, nsec % 1000000) // No monotonic reading
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Common locations
|
|
243
|
+
export const UTC = new Location('UTC')
|
|
244
|
+
|
|
245
|
+
// Common durations (matching Go's time package constants)
|
|
246
|
+
export const Nanosecond = new Duration(1)
|
|
247
|
+
export const Microsecond = new Duration(1000)
|
|
248
|
+
export const Millisecond = new Duration(1000000)
|
|
249
|
+
export const Second = new Duration(1000000000)
|
|
250
|
+
export const Minute = new Duration(60000000000)
|
|
251
|
+
export const Hour = new Duration(3600000000000)
|
|
252
|
+
|
|
253
|
+
// Since returns the time elapsed since t
|
|
254
|
+
// Uses monotonic clock if available for accurate measurement
|
|
255
|
+
export function Since(t: Time): Duration {
|
|
256
|
+
return Now().Sub(t)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Until returns the duration until t
|
|
260
|
+
// Uses monotonic clock if available for accurate measurement
|
|
261
|
+
export function Until(t: Time): Duration {
|
|
262
|
+
return t.Sub(Now())
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Sleep pauses the current execution for at least the duration d
|
|
266
|
+
export async function Sleep(d: Duration): Promise<void> {
|
|
267
|
+
const ms = d.valueOf() / 1000000 // Convert nanoseconds to milliseconds
|
|
268
|
+
return new Promise((resolve) => setTimeout(resolve, ms))
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Export month constants
|
|
272
|
+
export const May = Month.May
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
package unicode // import "unicode"
|
|
2
|
+
|
|
3
|
+
Package unicode provides data and functions to test some properties of Unicode
|
|
4
|
+
code points.
|
|
5
|
+
|
|
6
|
+
const MaxRune = '\U0010FFFF' ...
|
|
7
|
+
const UpperCase = iota ...
|
|
8
|
+
const UpperLower = MaxRune + 1
|
|
9
|
+
const Version = "15.0.0"
|
|
10
|
+
var Cc = _Cc ...
|
|
11
|
+
var Adlam = _Adlam ...
|
|
12
|
+
var ASCII_Hex_Digit = _ASCII_Hex_Digit ...
|
|
13
|
+
var CaseRanges = _CaseRanges
|
|
14
|
+
var Categories = map[string]*RangeTable{ ... }
|
|
15
|
+
var FoldCategory = map[string]*RangeTable{ ... }
|
|
16
|
+
var FoldScript = map[string]*RangeTable{ ... }
|
|
17
|
+
var GraphicRanges = []*RangeTable{ ... }
|
|
18
|
+
var PrintRanges = []*RangeTable{ ... }
|
|
19
|
+
var Properties = map[string]*RangeTable{ ... }
|
|
20
|
+
var Scripts = map[string]*RangeTable{ ... }
|
|
21
|
+
func In(r rune, ranges ...*RangeTable) bool
|
|
22
|
+
func Is(rangeTab *RangeTable, r rune) bool
|
|
23
|
+
func IsControl(r rune) bool
|
|
24
|
+
func IsDigit(r rune) bool
|
|
25
|
+
func IsGraphic(r rune) bool
|
|
26
|
+
func IsLetter(r rune) bool
|
|
27
|
+
func IsLower(r rune) bool
|
|
28
|
+
func IsMark(r rune) bool
|
|
29
|
+
func IsNumber(r rune) bool
|
|
30
|
+
func IsOneOf(ranges []*RangeTable, r rune) bool
|
|
31
|
+
func IsPrint(r rune) bool
|
|
32
|
+
func IsPunct(r rune) bool
|
|
33
|
+
func IsSpace(r rune) bool
|
|
34
|
+
func IsSymbol(r rune) bool
|
|
35
|
+
func IsTitle(r rune) bool
|
|
36
|
+
func IsUpper(r rune) bool
|
|
37
|
+
func SimpleFold(r rune) rune
|
|
38
|
+
func To(_case int, r rune) rune
|
|
39
|
+
func ToLower(r rune) rune
|
|
40
|
+
func ToTitle(r rune) rune
|
|
41
|
+
func ToUpper(r rune) rune
|
|
42
|
+
type CaseRange struct{ ... }
|
|
43
|
+
type Range16 struct{ ... }
|
|
44
|
+
type Range32 struct{ ... }
|
|
45
|
+
type RangeTable struct{ ... }
|
|
46
|
+
type SpecialCase []CaseRange
|
|
47
|
+
var AzeriCase SpecialCase = _TurkishCase
|
|
48
|
+
var TurkishCase SpecialCase = _TurkishCase
|
|
49
|
+
|
|
50
|
+
BUG: There is no mechanism for full case folding, that is, for
|
|
51
|
+
characters that involve multiple runes in the input or output.
|
|
52
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './unicode.js'
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package unicode
|
|
2
|
+
|
|
3
|
+
import "github.com/aperturerobotics/goscript/compiler"
|
|
4
|
+
|
|
5
|
+
// Metadata for unicode package functions
|
|
6
|
+
// Most unicode functions are synchronous character operations
|
|
7
|
+
|
|
8
|
+
// Character classification functions
|
|
9
|
+
var (
|
|
10
|
+
IsControlInfo = compiler.FunctionInfo{IsAsync: false}
|
|
11
|
+
IsDigitInfo = compiler.FunctionInfo{IsAsync: false}
|
|
12
|
+
IsGraphicInfo = compiler.FunctionInfo{IsAsync: false}
|
|
13
|
+
IsLetterInfo = compiler.FunctionInfo{IsAsync: false}
|
|
14
|
+
IsLowerInfo = compiler.FunctionInfo{IsAsync: false}
|
|
15
|
+
IsMarkInfo = compiler.FunctionInfo{IsAsync: false}
|
|
16
|
+
IsNumberInfo = compiler.FunctionInfo{IsAsync: false}
|
|
17
|
+
IsPrintInfo = compiler.FunctionInfo{IsAsync: false}
|
|
18
|
+
IsPunctInfo = compiler.FunctionInfo{IsAsync: false}
|
|
19
|
+
IsSpaceInfo = compiler.FunctionInfo{IsAsync: false}
|
|
20
|
+
IsSymbolInfo = compiler.FunctionInfo{IsAsync: false}
|
|
21
|
+
IsTitleInfo = compiler.FunctionInfo{IsAsync: false}
|
|
22
|
+
IsUpperInfo = compiler.FunctionInfo{IsAsync: false}
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
// Case conversion functions
|
|
26
|
+
var (
|
|
27
|
+
ToLowerInfo = compiler.FunctionInfo{IsAsync: false}
|
|
28
|
+
ToTitleInfo = compiler.FunctionInfo{IsAsync: false}
|
|
29
|
+
ToUpperInfo = compiler.FunctionInfo{IsAsync: false}
|
|
30
|
+
SimpleFoldInfo = compiler.FunctionInfo{IsAsync: false}
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
// Category functions
|
|
34
|
+
var (
|
|
35
|
+
InInfo = compiler.FunctionInfo{IsAsync: false}
|
|
36
|
+
IsInfo = compiler.FunctionInfo{IsAsync: false}
|
|
37
|
+
IsOneOfInfo = compiler.FunctionInfo{IsAsync: false}
|
|
38
|
+
)
|