ranger-compiler 3.1.0 → 3.1.1
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/CHANGELOG.md +25 -0
- package/README.md +81 -9
- package/dist/Lang.rgr +153 -1
- package/dist/lib/IsoDate/DateMath.rgr +219 -0
- package/dist/lib/IsoDate/IsoCalendar.rgr +137 -0
- package/dist/lib/IsoDate/IsoDateParse.rgr +57 -0
- package/dist/lib/IsoDateLib.rgr +15 -0
- package/dist/lib/RangerProcess.rgr +47 -0
- package/dist/lib/Regex/RegexMatch.rgr +134 -0
- package/dist/lib/RegexLib.rgr +10 -0
- package/dist/lib/Time.rgr +2 -1
- package/dist/rgrc.js +9715 -2229
- package/package.json +13 -4
package/dist/Lang.rgr
CHANGED
|
@@ -57,6 +57,7 @@ language {
|
|
|
57
57
|
php PHP php
|
|
58
58
|
python Python py
|
|
59
59
|
nim Nim nim
|
|
60
|
+
llvm LLVM IR ll
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
toplevel_keywords (class systemclass Constructor fn sfn Import Extend Enum def let operators)
|
|
@@ -92,6 +93,40 @@ language {
|
|
|
92
93
|
}
|
|
93
94
|
kotlin {
|
|
94
95
|
object _object
|
|
96
|
+
val _val
|
|
97
|
+
var _var
|
|
98
|
+
fun _fun
|
|
99
|
+
class _class
|
|
100
|
+
when _when
|
|
101
|
+
is _is
|
|
102
|
+
in _in
|
|
103
|
+
as _as
|
|
104
|
+
null _null
|
|
105
|
+
interface _interface
|
|
106
|
+
package _package
|
|
107
|
+
typealias _typealias
|
|
108
|
+
companion _companion
|
|
109
|
+
init _init
|
|
110
|
+
override _override
|
|
111
|
+
open _open
|
|
112
|
+
abstract _abstract
|
|
113
|
+
sealed _sealed
|
|
114
|
+
data _data
|
|
115
|
+
internal _internal
|
|
116
|
+
private _private
|
|
117
|
+
protected _protected
|
|
118
|
+
public _public
|
|
119
|
+
operator _operator
|
|
120
|
+
inline _inline
|
|
121
|
+
lateinit _lateinit
|
|
122
|
+
vararg _vararg
|
|
123
|
+
reified _reified
|
|
124
|
+
suspend _suspend
|
|
125
|
+
tailrec _tailrec
|
|
126
|
+
where _where
|
|
127
|
+
get _get
|
|
128
|
+
set _set
|
|
129
|
+
field _field
|
|
95
130
|
}
|
|
96
131
|
rust {
|
|
97
132
|
type r#type
|
|
@@ -186,6 +221,7 @@ language {
|
|
|
186
221
|
random _:double () {
|
|
187
222
|
templates {
|
|
188
223
|
es6 ('Math.random()')
|
|
224
|
+
kotlin ('Math.random()' (imp "java.lang.Math"))
|
|
189
225
|
}
|
|
190
226
|
}
|
|
191
227
|
|
|
@@ -210,6 +246,7 @@ language {
|
|
|
210
246
|
random _:int ( min:int max:int) {
|
|
211
247
|
templates {
|
|
212
248
|
es6 ('Math.floor(Math.random()*(' (e 2) ' - ' (e 1)' + 1) + ' (e 1)')')
|
|
249
|
+
kotlin ('(Math.floor(Math.random() * (' (e 2) ' - ' (e 1) ' + 1)).toInt() + ' (e 1) ')' (imp "java.lang.Math"))
|
|
213
250
|
}
|
|
214
251
|
}
|
|
215
252
|
|
|
@@ -486,6 +523,7 @@ func r_io_get_env( name string) *GoNullable {
|
|
|
486
523
|
; Command line arguments
|
|
487
524
|
shell_arg cmdArg:string (index:int) {
|
|
488
525
|
templates {
|
|
526
|
+
llvm ( "(shell_arg " (e 1) ")")
|
|
489
527
|
cpp ( "std::string(__g_argv[" (e 1) " + 1])")
|
|
490
528
|
php ( "$argv[" (e 1) " + 1]" )
|
|
491
529
|
java7 ( "args[" (e 1) "]")
|
|
@@ -502,6 +540,7 @@ func r_io_get_env( name string) *GoNullable {
|
|
|
502
540
|
|
|
503
541
|
shell_arg_cnt cmdArg:int () @doc("return the number of arguments for command line utility") {
|
|
504
542
|
templates {
|
|
543
|
+
llvm ( "(shell_arg_cnt)")
|
|
505
544
|
cpp ( "__g_argc - 1")
|
|
506
545
|
swift3 ("CommandLine.arguments.count - 1")
|
|
507
546
|
swift6 ("CommandLine.arguments.count - 1")
|
|
@@ -845,6 +884,7 @@ fn r_write_file(path: &str, filename: &str, data: &str) {
|
|
|
845
884
|
read_file cmdReadFile@(optional async):string (path:string filename:string) {
|
|
846
885
|
|
|
847
886
|
templates {
|
|
887
|
+
llvm ( "(read_file " (e 1) " " (e 2) ")")
|
|
848
888
|
ts ( "await (new Promise<string>(resolve => { require('fs').readFile( " (e 1) " + '/' + " (e 2) " , 'utf8', (err,data)=>{ resolve(data) }) } ))" )
|
|
849
889
|
es6 ( "await (new Promise(resolve => { require('fs').readFile( " (e 1) " + '/' + " (e 2) " , 'utf8', (err,data)=>{ resolve(data) }) } ))" )
|
|
850
890
|
ranger ( "(read_file " (e 1) " " (e 2) ")" )
|
|
@@ -1462,6 +1502,8 @@ fn r_read_file(path: &str, filename: &str) -> Option<String> {
|
|
|
1462
1502
|
int2double cmdIntToDouble:double ( value:int ) {
|
|
1463
1503
|
templates {
|
|
1464
1504
|
ranger ( "(int2double " (e 1) ")" )
|
|
1505
|
+
kotlin ( (e 1) ".toDouble()" )
|
|
1506
|
+
swift6 ( "Double(" (e 1) ")" )
|
|
1465
1507
|
* ( "parseFloat(" (e 1) ")" )
|
|
1466
1508
|
}
|
|
1467
1509
|
}
|
|
@@ -1504,6 +1546,7 @@ fn r_read_file(path: &str, filename: &str) -> Option<String> {
|
|
|
1504
1546
|
rust ( "" (e 1) ".floor() as i64" )
|
|
1505
1547
|
scala ( "math.floor(" (e 1) ").toInt" (imp "scala.math"))
|
|
1506
1548
|
java7 ( "(int)Math.floor(" (e 1) ")" (imp "java.lang.Math"))
|
|
1549
|
+
kotlin ( "(Math.floor(" (e 1) ")).toInt()" (imp "java.lang.Math"))
|
|
1507
1550
|
* ( "Math.floor(" (e 1) ")")
|
|
1508
1551
|
}
|
|
1509
1552
|
}
|
|
@@ -1845,6 +1888,7 @@ fn r_read_file(path: &str, filename: &str) -> Option<String> {
|
|
|
1845
1888
|
csharp ( "new " (typeof 1) "( new " (r_atype 1) "[" (e 2)"])")
|
|
1846
1889
|
swift3 ( "" (typeof 1)"(repeating:" (e 3) ", count:" (e 2) ")" )
|
|
1847
1890
|
ranger ( "(make _:" (typeof 1) " " (e 2) ")" )
|
|
1891
|
+
llvm ( "(make _:" (typeof 1) " " (e 2) ")" )
|
|
1848
1892
|
go ( "make(" (typeof 1) "," (e 2) ")" )
|
|
1849
1893
|
cpp ( (typeof 1) "(" (e 2) ")")
|
|
1850
1894
|
; new ArrayList<Double>( Arrays.asList( new Double[len_2] ) );
|
|
@@ -2037,7 +2081,7 @@ case class customException(smth:String) extends Exception
|
|
|
2037
2081
|
i
|
|
2038
2082
|
"}" nl
|
|
2039
2083
|
)
|
|
2040
|
-
go ( (
|
|
2084
|
+
go ( (forkctx _ ) (def 3) "var " (e 3) " int64 = 0; " nl "for ; " (e 3) " < int64(len(" (e 1) ")) ; " (e 3) "++ {" nl I nl (go_for_bind 2) nl (block 4) nl i "}" )
|
|
2041
2085
|
|
|
2042
2086
|
php ( (forkctx _ ) (def 2) (def 3) "for ( " (e 3) " = 0; " (e 3) " < count(" (e 1) "); " (e 3) "++) {" nl I (e 2) " = " (e 1) "[" (e 3) "];" nl (block 4) nl i "}" )
|
|
2043
2087
|
java7 ( (forkctx _ ) (def 2) (def 3) "for ( int " (e 3) " = 0; " (e 3) " < " (e 1) ".size(); " (e 3) "++) {" nl I (typeof 2) " " (e 2) " = " (e 1) ".get(" (e 3) ");" nl (block 4) nl i "}" )
|
|
@@ -2188,6 +2232,7 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
|
|
|
2188
2232
|
|
|
2189
2233
|
strlen cmdStrlen:int ( text:string ) {
|
|
2190
2234
|
templates {
|
|
2235
|
+
llvm ( "(strlen " (e 1) ")")
|
|
2191
2236
|
ranger ( "( strlen (" (e 1 ) "))")
|
|
2192
2237
|
cpp ( '(int)('(e 1) ".length())")
|
|
2193
2238
|
java7 ( (e 1) ".length()")
|
|
@@ -2203,6 +2248,50 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
|
|
|
2203
2248
|
}
|
|
2204
2249
|
}
|
|
2205
2250
|
|
|
2251
|
+
; ISO calendar dates (YYYY-MM-DD). See lib/IsoDate/ and ai/ISO_DATE.md.
|
|
2252
|
+
iso_add_days cmdIsoAddDays:string ( iso:string days:int ) {
|
|
2253
|
+
templates {
|
|
2254
|
+
ranger ( "(DateMath.addDays " (e 1) " " (e 2) ")")
|
|
2255
|
+
kotlin ( "java.time.LocalDate.parse(" (e 1) ").plusDays(" (e 2) ".toLong()).toString()" (imp "java.time.LocalDate"))
|
|
2256
|
+
java7 ( "java.time.LocalDate.parse(" (e 1) ").plusDays(" (e 2) ").toString()" (imp "java.time.LocalDate"))
|
|
2257
|
+
es6 ( "((iso,d)=>{const p=iso.split('-').map(Number);const t=new Date(Date.UTC(p[0],p[1]-1,p[2]+d));return t.toISOString().slice(0,10)})(" (e 1) "," (e 2) ")")
|
|
2258
|
+
* ( "(DateMath.addDays " (e 1) " " (e 2) ")")
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
iso_compare cmdIsoCompare:int ( a:string b:string ) {
|
|
2263
|
+
templates {
|
|
2264
|
+
ranger ( "(DateMath.compareIso " (e 1) " " (e 2) ")")
|
|
2265
|
+
kotlin ( "java.time.LocalDate.parse(" (e 1) ").compareTo(java.time.LocalDate.parse(" (e 2) "))" (imp "java.time.LocalDate"))
|
|
2266
|
+
java7 ( "java.time.LocalDate.parse(" (e 1) ").compareTo(java.time.LocalDate.parse(" (e 2) "))" (imp "java.time.LocalDate"))
|
|
2267
|
+
es6 ( "((a,b)=>a<b?-1:a>b?1:0)(" (e 1) "," (e 2) ")")
|
|
2268
|
+
* ( "(DateMath.compareIso " (e 1) " " (e 2) ")")
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
iso_between cmdIsoBetween:boolean ( d:string start:string end:string ) {
|
|
2273
|
+
templates {
|
|
2274
|
+
ranger ( "(DateMath.isBetween " (e 1) " " (e 2) " " (e 3) ")")
|
|
2275
|
+
kotlin ( "(!java.time.LocalDate.parse(" (e 1) ").isBefore(java.time.LocalDate.parse(" (e 2) ")) && !java.time.LocalDate.parse(" (e 1) ").isAfter(java.time.LocalDate.parse(" (e 3) ")))" (imp "java.time.LocalDate"))
|
|
2276
|
+
java7 ( "(!java.time.LocalDate.parse(" (e 1) ").isBefore(java.time.LocalDate.parse(" (e 2) ")) && !java.time.LocalDate.parse(" (e 1) ").isAfter(java.time.LocalDate.parse(" (e 3) ")))" (imp "java.time.LocalDate"))
|
|
2277
|
+
es6 ( "((d,s,e)=>d>=s&&d<=e)(" (e 1) "," (e 2) "," (e 3) ")")
|
|
2278
|
+
* ( "(DateMath.isBetween " (e 1) " " (e 2) " " (e 3) ")")
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
; Case-insensitive regex substring search. Pattern is a string (no /literal/). See lib/Regex/ and ai/REGEX.md.
|
|
2283
|
+
regex_test cmdRegexTest:boolean ( pattern:string haystack:string ) {
|
|
2284
|
+
templates {
|
|
2285
|
+
ranger ( "(RegexMatch.testIgnoreCase(" (e 1) " " (e 2) "))")
|
|
2286
|
+
kotlin ( "try { Regex(" (e 1) ", RegexOption.IGNORE_CASE).containsMatchIn(" (e 2) ") } catch (_: Exception) { false }" )
|
|
2287
|
+
java7 ( "try { java.util.regex.Pattern.compile(" (e 1) ", java.util.regex.Pattern.CASE_INSENSITIVE).matcher(" (e 2) ").find() } catch (Exception e) { false }" (imp "java.util.regex.Pattern"))
|
|
2288
|
+
es6 ( "(()=>{try{return new RegExp(" (e 1) ",'i').test(" (e 2) ");}catch{return false;}})()" )
|
|
2289
|
+
swift6 ( (e 2) ".range(of: " (e 1) ", options: [.regularExpression, .caseInsensitive]) != nil" )
|
|
2290
|
+
swift3 ( (e 2) ".range(of: " (e 1) ", options: [.regularExpression, .caseInsensitive]) != nil" )
|
|
2291
|
+
* ( "(RegexMatch.testIgnoreCase(" (e 1) " " (e 2) "))")
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2206
2295
|
; String s = new String(a, 2, 4)
|
|
2207
2296
|
|
|
2208
2297
|
; C#
|
|
@@ -2277,6 +2366,7 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
|
|
|
2277
2366
|
; Allocate a new buffer of specified size (zero-filled)
|
|
2278
2367
|
buffer_alloc cmdBufferAlloc:buffer ( size:int ) {
|
|
2279
2368
|
templates {
|
|
2369
|
+
llvm ( "(buffer_alloc " (e 1) ")" )
|
|
2280
2370
|
ranger ( "(buffer_alloc " (e 1) ")" )
|
|
2281
2371
|
es6 ( "(function(){ var b = new ArrayBuffer(" (e 1) "); b._view = new DataView(b); return b; })()" )
|
|
2282
2372
|
go ( "make([]byte, " (e 1) ")" )
|
|
@@ -2292,6 +2382,7 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
|
|
|
2292
2382
|
; Get the length of a buffer in bytes
|
|
2293
2383
|
buffer_length cmdBufferLength:int ( buf:buffer ) {
|
|
2294
2384
|
templates {
|
|
2385
|
+
llvm ( "(buffer_length " (e 1) ")" )
|
|
2295
2386
|
ranger ( "(buffer_length " (e 1) ")" )
|
|
2296
2387
|
es6 ( (e 1) ".byteLength" )
|
|
2297
2388
|
go ( "int64(len(" (e 1) "))" )
|
|
@@ -2307,6 +2398,7 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
|
|
|
2307
2398
|
; Read a single byte at offset (returns 0-255)
|
|
2308
2399
|
buffer_get cmdBufferGet:int ( buf:buffer offset:int ) {
|
|
2309
2400
|
templates {
|
|
2401
|
+
llvm ( "(buffer_get " (e 1) " " (e 2) ")" )
|
|
2310
2402
|
ranger ( "(buffer_get " (e 1) " " (e 2) ")" )
|
|
2311
2403
|
es6 ( (e 1) "._view.getUint8(" (e 2) ")" )
|
|
2312
2404
|
go ( "int64(" (e 1) "[" (e 2) "])" )
|
|
@@ -2322,6 +2414,7 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
|
|
|
2322
2414
|
; Write a single byte at offset (value should be 0-255)
|
|
2323
2415
|
buffer_set cmdBufferSet:void ( buf:buffer offset:int value:int ) {
|
|
2324
2416
|
templates {
|
|
2417
|
+
llvm ( "(buffer_set " (e 1) " " (e 2) " " (e 3) ")" )
|
|
2325
2418
|
ranger ( "(buffer_set " (e 1) " " (e 2) " " (e 3) ")" )
|
|
2326
2419
|
es6 ( (e 1) "._view.setUint8(" (e 2) ", " (e 3) ")" )
|
|
2327
2420
|
go ( (e 1) "[" (e 2) "] = byte(" (e 3) ")" )
|
|
@@ -2400,6 +2493,7 @@ std::string r_buffer_to_base64(const std::vector<uint8_t>& data) {
|
|
|
2400
2493
|
; Write buffer to a binary file
|
|
2401
2494
|
buffer_write_file cmdBufferWriteFile:void ( path:string filename:string buf:buffer ) {
|
|
2402
2495
|
templates {
|
|
2496
|
+
llvm ( "(buffer_write_file " (e 1) " " (e 2) " " (e 3) ")" )
|
|
2403
2497
|
ranger ( "(buffer_write_file " (e 1) " " (e 2) " " (e 3) ")" )
|
|
2404
2498
|
es6 ( "require('fs').writeFileSync(" (e 1) " + '/' + " (e 2) ", Buffer.from(" (e 3) "))" )
|
|
2405
2499
|
go ( "os.WriteFile(" (e 1) " + \"/\" + " (e 2) ", " (e 3) ", 0644)" (imp "os") )
|
|
@@ -2422,6 +2516,7 @@ void r_buffer_write_file(const std::string& path, const std::string& filename, c
|
|
|
2422
2516
|
; Read a binary file into a buffer
|
|
2423
2517
|
buffer_read_file cmdBufferReadFile:buffer ( path:string filename:string ) {
|
|
2424
2518
|
templates {
|
|
2519
|
+
llvm ( "(buffer_read_file " (e 1) " " (e 2) ")" )
|
|
2425
2520
|
ranger ( "(buffer_read_file " (e 1) " " (e 2) ")" )
|
|
2426
2521
|
es6 ( "(function(){ var b = require('fs').readFileSync(" (e 1) " + '/' + " (e 2) "); var ab = new ArrayBuffer(b.length); var v = new Uint8Array(ab); for(var i=0;i<b.length;i++)v[i]=b[i]; ab._view = new DataView(ab); return ab; })()" )
|
|
2427
2522
|
go ( "func() []byte { d, _ := os.ReadFile(filepath.Join(" (e 1) ", " (e 2) ")); return d }()" (imp "os") (imp "path/filepath") )
|
|
@@ -2497,6 +2592,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
|
|
|
2497
2592
|
; Allocate a new int_buffer of specified size (zero-filled)
|
|
2498
2593
|
int_buffer_alloc cmdIntBufferAlloc:int_buffer ( size:int ) {
|
|
2499
2594
|
templates {
|
|
2595
|
+
llvm ( "(int_buffer_alloc " (e 1) ")" )
|
|
2500
2596
|
ranger ( "(int_buffer_alloc " (e 1) ")" )
|
|
2501
2597
|
es6 ( "new Int32Array(" (e 1) ")" )
|
|
2502
2598
|
go ( "make([]int64, " (e 1) ")" )
|
|
@@ -2527,6 +2623,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
|
|
|
2527
2623
|
; Read an int64 at index
|
|
2528
2624
|
int_buffer_get cmdIntBufferGet:int ( buf:int_buffer index:int ) {
|
|
2529
2625
|
templates {
|
|
2626
|
+
llvm ( "(int_buffer_get " (e 1) " " (e 2) ")" )
|
|
2530
2627
|
ranger ( "(int_buffer_get " (e 1) " " (e 2) ")" )
|
|
2531
2628
|
es6 ( (e 1) "[" (e 2) "]" )
|
|
2532
2629
|
go ( (e 1) "[" (e 2) "]" )
|
|
@@ -2542,6 +2639,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
|
|
|
2542
2639
|
; Write an int64 at index
|
|
2543
2640
|
int_buffer_set cmdIntBufferSet:void ( buf:int_buffer index:int value:int ) {
|
|
2544
2641
|
templates {
|
|
2642
|
+
llvm ( "(int_buffer_set " (e 1) " " (e 2) " " (e 3) ")" )
|
|
2545
2643
|
ranger ( "(int_buffer_set " (e 1) " " (e 2) " " (e 3) ")" )
|
|
2546
2644
|
es6 ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
2547
2645
|
go ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
@@ -2557,6 +2655,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
|
|
|
2557
2655
|
; Fill int_buffer with a value in range [start, end)
|
|
2558
2656
|
int_buffer_fill cmdIntBufferFill:void ( buf:int_buffer value:int start:int end:int ) {
|
|
2559
2657
|
templates {
|
|
2658
|
+
llvm ( "(int_buffer_fill " (e 1) " " (e 2) " " (e 3) " " (e 4) ")" )
|
|
2560
2659
|
ranger ( "(int_buffer_fill " (e 1) " " (e 2) " " (e 3) " " (e 4) ")" )
|
|
2561
2660
|
es6 ( (e 1) ".fill(" (e 2) ", " (e 3) ", " (e 4) ")" )
|
|
2562
2661
|
go ( "for i := " (e 3) "; i < " (e 4) "; i++ { " (e 1) "[i] = " (e 2) " }" )
|
|
@@ -2718,6 +2817,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
|
|
|
2718
2817
|
|
|
2719
2818
|
to_int cmdToInt:int ( value:double ) {
|
|
2720
2819
|
templates {
|
|
2820
|
+
llvm ( "(to_int " (e 1) ")" )
|
|
2721
2821
|
ranger ( "(to_int " (e 1) ")")
|
|
2722
2822
|
csharp ( "(int)" (e 1 ) "" )
|
|
2723
2823
|
swift3 ( "Int(" (e 1 ) ")" )
|
|
@@ -2787,6 +2887,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
|
|
|
2787
2887
|
at _:string ( text:string position:int ) {
|
|
2788
2888
|
templates {
|
|
2789
2889
|
ranger ( '(at ' (e 1) ' ' ( e 2 ) ')')
|
|
2890
|
+
llvm ( "(at " (e 1) " " (e 2) ")")
|
|
2790
2891
|
cpp ( 'r_utf8_char_at(' (e 1) ', ' (e 2) ')'
|
|
2791
2892
|
(create_polyfill '
|
|
2792
2893
|
std::string r_utf8_char_at(const std::string& str, int pos_i)
|
|
@@ -2835,6 +2936,7 @@ std::string r_utf8_char_at(const std::string& str, int pos_i)
|
|
|
2835
2936
|
|
|
2836
2937
|
charAt cmdCharAt:int ( text:string position:int ) {
|
|
2837
2938
|
templates {
|
|
2939
|
+
llvm ( "(charAt " (e 1) " " (e 2) ")")
|
|
2838
2940
|
ranger ( "(charAt " (e 1) " " ( e 2 ) ")")
|
|
2839
2941
|
cpp ( (e 1) ".at(" (e 2) ")")
|
|
2840
2942
|
csharp ( (e 1) "[" (e 2) "]")
|
|
@@ -2972,7 +3074,9 @@ std::string r_utf8_substr(const std::string& str, int start_i, int leng_i)
|
|
|
2972
3074
|
ranger ( "(strfromcode " (e 1) ")")
|
|
2973
3075
|
csharp ( "((char)" (e 1) ").toString()")
|
|
2974
3076
|
java7 ( "(new String( new char[] {" (e 1) " }))")
|
|
3077
|
+
kotlin ( (e 1) ".toChar().toString()")
|
|
2975
3078
|
swift3 ( "(String( Character( UnicodeScalar(" (e 1) " ) )))")
|
|
3079
|
+
swift6 ( "String(UnicodeScalar(" (e 1) ")!)")
|
|
2976
3080
|
php ( "chr(" (e 1) ")")
|
|
2977
3081
|
scala ( "(" (e 1) ".toChar)")
|
|
2978
3082
|
go ("string([]rune{rune(" (e 1) ")})")
|
|
@@ -2988,7 +3092,9 @@ std::string r_utf8_substr(const std::string& str, int start_i, int leng_i)
|
|
|
2988
3092
|
ranger ( "(strfromcode " (e 1) ")")
|
|
2989
3093
|
csharp ( "((char)" (e 1) ").toString()")
|
|
2990
3094
|
java7 ( "(new String( Character.toChars(" (e 1) ")))")
|
|
3095
|
+
kotlin ( (e 1) ".toChar().toString()")
|
|
2991
3096
|
swift3 ( "(String( Character( UnicodeScalar(" (e 1) " )! )))")
|
|
3097
|
+
swift6 ( "String(UnicodeScalar(" (e 1) ")!)")
|
|
2992
3098
|
php ( "chr(" (e 1) ")")
|
|
2993
3099
|
scala ( "(" (e 1) ".toChar)")
|
|
2994
3100
|
go ("string([]rune{rune(" (e 1) ")})")
|
|
@@ -3384,6 +3490,9 @@ std::string join(const T& v, const std::string& delim) {
|
|
|
3384
3490
|
get cmdGet@(optional):T ( a:[T] index:int ) {
|
|
3385
3491
|
templates {
|
|
3386
3492
|
es6 ('( ' (e 1) '.length > ' (e 2)' && ' (e 2)' >= 0 ? '(e 1) '[' (e 2)'] : null ) ')
|
|
3493
|
+
ranger ( "(get " (e 1) " " (e 2) ")")
|
|
3494
|
+
llvm ( "(get " (e 1) " " (e 2) ")")
|
|
3495
|
+
* ( (e 1) "[" (e 2) "]" )
|
|
3387
3496
|
}
|
|
3388
3497
|
}
|
|
3389
3498
|
|
|
@@ -3433,6 +3542,7 @@ r_optional_primitive<int> cpp_get_map_int_value( std::map<" (r_ktype 1) ", int>
|
|
|
3433
3542
|
get cmdGet@(optional weak):T ( map:[K:T] key:K ) {
|
|
3434
3543
|
templates {
|
|
3435
3544
|
ranger ( "(get " (e 1) " " (e 2) ")")
|
|
3545
|
+
llvm ( "(get " (e 1) " " (e 2) ")")
|
|
3436
3546
|
java7 ( (e 1) ".get(" (e 2) ")" )
|
|
3437
3547
|
rust ( (e 1) ".get(" (e 2) ")" )
|
|
3438
3548
|
|
|
@@ -3465,6 +3575,7 @@ i "}" nl ))
|
|
|
3465
3575
|
set cmdSet@(moves@( 3 1 ) ):void ( array@(mutates):[T] index:int value@( refto@(1) ):T ) {
|
|
3466
3576
|
templates {
|
|
3467
3577
|
ranger ( "set " (e 1) " " (e 2) " " (e 3) )
|
|
3578
|
+
llvm ( "set " (e 1) " " (e 2) " " (e 3) )
|
|
3468
3579
|
java7 ( (e 1) ".set(" (e 2) ", " (e 3) ");" )
|
|
3469
3580
|
rust ( (e 1) "[" (e 2) " as usize] = " (e 3) ";" )
|
|
3470
3581
|
scala ( (e 1) "(" (e 2) ") = " (e 3) )
|
|
@@ -3479,6 +3590,7 @@ i "}" nl ))
|
|
|
3479
3590
|
set cmdSet@(moves@( 3 1 ) ):void ( map@(mutates):[K:T] key:K value@( refto@(1) ):T ) {
|
|
3480
3591
|
templates {
|
|
3481
3592
|
ranger ( "set " (e 1) " " (e 2) " " (e 3) )
|
|
3593
|
+
llvm ( "set " (e 1) " " (e 2) " " (e 3) )
|
|
3482
3594
|
java7 ( (e 1) ".put(" (e 2) ", " (e 3) ");" )
|
|
3483
3595
|
rust ( (e 1) ".insert(" (e 2) ", " (e 3) ");" )
|
|
3484
3596
|
scala ( (e 1) ".put(" (e 2) ", " (e 3) ")" )
|
|
@@ -3504,6 +3616,7 @@ i "}" nl ))
|
|
|
3504
3616
|
itemAt cmdItemAt@(weak):T ( array:[T] index:int ) {
|
|
3505
3617
|
templates {
|
|
3506
3618
|
ranger ( "(itemAt " (e 1) " " (e 2) ")" )
|
|
3619
|
+
llvm ( "(itemAt " (e 1) " " (e 2) ")" )
|
|
3507
3620
|
cpp ( (e 1) ".at(" (e 2) ")" (imp "<vector>"))
|
|
3508
3621
|
java7 ( (e 1) ".get(" (e 2) ")" )
|
|
3509
3622
|
; lift return optional type => safer
|
|
@@ -3565,6 +3678,7 @@ int r_string_index_of_from( std::string str, std::string key, int start ) {
|
|
|
3565
3678
|
" )
|
|
3566
3679
|
)
|
|
3567
3680
|
rust ( "(" (e 1) "[" (e 3) " as usize..].find(&*" (e 2) ").map(|i| (i + " (e 3) " as usize) as i64).unwrap_or(-1))" )
|
|
3681
|
+
kotlin ( (e 1) ".indexOf(" (e 2 ) ", " (e 3) ")" )
|
|
3568
3682
|
ranger ( "(indexOfFrom " (e 1) " " (e 2) " " (e 3) ")")
|
|
3569
3683
|
}
|
|
3570
3684
|
}
|
|
@@ -3869,6 +3983,7 @@ func r_index_of ( arr:" (typeof 1) " , elem: " (typeof 2) ") -> Int { " nl I
|
|
|
3869
3983
|
|
|
3870
3984
|
length cmdStrlen:int ( text:string ) {
|
|
3871
3985
|
templates {
|
|
3986
|
+
llvm ( "(length " (e 1) ")")
|
|
3872
3987
|
ranger ( "(length " (e 1) ")")
|
|
3873
3988
|
cpp ( (e 1) ".length()")
|
|
3874
3989
|
java7 ( (e 1) ".length()")
|
|
@@ -3964,6 +4079,7 @@ func r_index_of ( arr:" (typeof 1) " , elem: " (typeof 2) ") -> Int { " nl I
|
|
|
3964
4079
|
array_length cmdArrayLength:int ( array:[T] ) {
|
|
3965
4080
|
templates {
|
|
3966
4081
|
ranger ( "(array_length " (e 1) ")")
|
|
4082
|
+
llvm ( "(array_length " (e 1) ")")
|
|
3967
4083
|
cpp ( '(int)(' (e 1) ".size())" )
|
|
3968
4084
|
swift3 ( (e 1) ".count")
|
|
3969
4085
|
swift6 ( (e 1) ".count")
|
|
@@ -4027,6 +4143,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
|
|
|
4027
4143
|
print cmdPrint:void ( text:string) {
|
|
4028
4144
|
templates {
|
|
4029
4145
|
ranger ( nl "print " (e 1) nl)
|
|
4146
|
+
llvm ( nl "print " (e 1) nl)
|
|
4030
4147
|
cpp (ln "std::cout << " (e 1) " << std::endl;" nl (imp "<iostream>") (imp "<string>"))
|
|
4031
4148
|
kotlin ( nl "println( " (e 1) " )" nl )
|
|
4032
4149
|
scala ( "println( " (e 1) " )" )
|
|
@@ -4046,6 +4163,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
|
|
|
4046
4163
|
; Write text without newline
|
|
4047
4164
|
write cmdWrite:void ( text:string) {
|
|
4048
4165
|
templates {
|
|
4166
|
+
llvm ( nl "write " (e 1) nl)
|
|
4049
4167
|
cpp ( nl "std::cout << " (e 1) " << std::flush;" nl (imp "<iostream>"))
|
|
4050
4168
|
go ( nl "fmt.Print( " (e 1) " )" nl (imp "fmt"))
|
|
4051
4169
|
rust ( nl "print!(\"{}\", " (e 1) ");" nl)
|
|
@@ -4063,6 +4181,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
|
|
|
4063
4181
|
; Clear the terminal screen
|
|
4064
4182
|
clear_screen cmdClearScreen:void () {
|
|
4065
4183
|
templates {
|
|
4184
|
+
llvm ( nl "clear_screen" nl)
|
|
4066
4185
|
cpp ( nl "std::cout << \"\\x1b[2J\\x1b[H\" << std::flush;" nl (imp "<iostream>"))
|
|
4067
4186
|
go ( nl "fmt.Print(\"\\x1b[2J\\x1b[H\")" nl (imp "fmt"))
|
|
4068
4187
|
rust ( nl "print!(\"\\x1b[2J\\x1b[H\");" nl)
|
|
@@ -4080,6 +4199,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
|
|
|
4080
4199
|
; Move cursor to position (1-based coordinates)
|
|
4081
4200
|
move_cursor cmdMoveCursor:void ( x:int y:int) {
|
|
4082
4201
|
templates {
|
|
4202
|
+
llvm ( nl "move_cursor " (e 1) " " (e 2) nl)
|
|
4083
4203
|
cpp ( nl "std::cout << \"\\x1b[\" << (" (e 2) ") << \";\" << (" (e 1) ") << \"H\" << std::flush;" nl (imp "<iostream>"))
|
|
4084
4204
|
go ( nl "fmt.Printf(\"\\x1b[%d;%dH\", " (e 2) ", " (e 1) ")" nl (imp "fmt"))
|
|
4085
4205
|
rust ( nl "print!(\"\\x1b[{};{}H\", " (e 2) ", " (e 1) ");" nl)
|
|
@@ -4097,6 +4217,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
|
|
|
4097
4217
|
; Hide terminal cursor
|
|
4098
4218
|
hide_cursor cmdHideCursor:void () {
|
|
4099
4219
|
templates {
|
|
4220
|
+
llvm ( nl "hide_cursor" nl)
|
|
4100
4221
|
cpp ( nl "std::cout << \"\\x1b[?25l\" << std::flush;" nl (imp "<iostream>"))
|
|
4101
4222
|
go ( nl "fmt.Print(\"\\x1b[?25l\")" nl (imp "fmt"))
|
|
4102
4223
|
rust ( nl "print!(\"\\x1b[?25l\");" nl)
|
|
@@ -4114,6 +4235,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
|
|
|
4114
4235
|
; Show terminal cursor
|
|
4115
4236
|
show_cursor cmdShowCursor:void () {
|
|
4116
4237
|
templates {
|
|
4238
|
+
llvm ( nl "show_cursor" nl)
|
|
4117
4239
|
cpp ( nl "std::cout << \"\\x1b[?25h\" << std::flush;" nl (imp "<iostream>"))
|
|
4118
4240
|
go ( nl "fmt.Print(\"\\x1b[?25h\")" nl (imp "fmt"))
|
|
4119
4241
|
rust ( nl "print!(\"\\x1b[?25h\");" nl)
|
|
@@ -4839,6 +4961,7 @@ fun r_read_key(): String {
|
|
|
4839
4961
|
; Sleep for specified milliseconds (blocking)
|
|
4840
4962
|
sleep_ms cmdSleepMs@(async):void (ms:int) {
|
|
4841
4963
|
templates {
|
|
4964
|
+
llvm ( nl "sleep_ms " (e 1) nl)
|
|
4842
4965
|
es6 ( nl "await new Promise(r => setTimeout(r, " (e 1) "));" nl )
|
|
4843
4966
|
rust ( nl "std::thread::sleep(std::time::Duration::from_millis(" (e 1) " as u64));" nl )
|
|
4844
4967
|
go ( nl "time.Sleep(time.Duration(" (e 1) ") * time.Millisecond)" nl (imp "time"))
|
|
@@ -4856,6 +4979,7 @@ fun r_read_key(): String {
|
|
|
4856
4979
|
|
|
4857
4980
|
exit cmdExit:void ( code:int) {
|
|
4858
4981
|
templates {
|
|
4982
|
+
llvm ( nl "exit " (e 1) nl)
|
|
4859
4983
|
ranger ( nl "exit " (e 1) nl)
|
|
4860
4984
|
cpp ( nl "exit(" (e 1) ");" nl (imp "<cstdlib>"))
|
|
4861
4985
|
kotlin ( nl "System.exit(" (e 1) ")" nl )
|
|
@@ -4875,10 +4999,12 @@ fun r_read_key(): String {
|
|
|
4875
4999
|
templates {
|
|
4876
5000
|
es6 ((e 1) '.toLowerCase()')
|
|
4877
5001
|
java7 ((e 1) '.toLowerCase()')
|
|
5002
|
+
kotlin ((e 1) '.lowercase()')
|
|
4878
5003
|
go ( "strings.ToLower(" (e 1) ")" (imp "strings"))
|
|
4879
5004
|
php ("strtolower(" (e 1) ")")
|
|
4880
5005
|
csharp ((e 1) ".ToLower()")
|
|
4881
5006
|
swift3 ((e 1) ".lowercased()")
|
|
5007
|
+
swift6 ((e 1) ".lowercased()")
|
|
4882
5008
|
scala ((e 1) ".toLowerCase()")
|
|
4883
5009
|
python ((e 1) ".lower()")
|
|
4884
5010
|
}
|
|
@@ -4886,6 +5012,8 @@ fun r_read_key(): String {
|
|
|
4886
5012
|
to_uppercase _:string (s:string) {
|
|
4887
5013
|
templates {
|
|
4888
5014
|
swift3 ( (e 1) ".uppercased()")
|
|
5015
|
+
swift6 ( (e 1) ".uppercased()")
|
|
5016
|
+
kotlin ( (e 1) ".uppercase()" )
|
|
4889
5017
|
scala ( (e 1 ) ".toUpperCase()" )
|
|
4890
5018
|
ranger ("(to_uppercase " (e 1) ")")
|
|
4891
5019
|
es6 ( (e 1) ".toUpperCase()")
|
|
@@ -4917,6 +5045,7 @@ std::string r_cpp_str_to_uppercase(std::string original)
|
|
|
4917
5045
|
|
|
4918
5046
|
to_double toDouble:double ( input:int ) {
|
|
4919
5047
|
templates {
|
|
5048
|
+
llvm ( "(to_double " (e 1) ")" )
|
|
4920
5049
|
ranger ("( to_double " (e 1) " )")
|
|
4921
5050
|
go ("float64( " (e 1) " )")
|
|
4922
5051
|
es6 ( (e 1) )
|
|
@@ -5353,6 +5482,26 @@ std::string r_cpp_str_to_uppercase(std::string original)
|
|
|
5353
5482
|
|
|
5354
5483
|
; proc_send is lowered in ng_RangerProcessProcSend.rgr (typed handler methods, overload match).
|
|
5355
5484
|
|
|
5485
|
+
begin_dispatch_turn@(moves@( 1 )) cmdBeginDispatchTurn:void (root:RangerProcessBase) {
|
|
5486
|
+
templates {
|
|
5487
|
+
es6 ( "ProcessRuntime.beginDispatchTurn(" (e 1) ")" )
|
|
5488
|
+
kotlin ( "ProcessRuntime.beginDispatchTurn(" (e 1) ")" )
|
|
5489
|
+
swift6 ( "ProcessRuntime.beginDispatchTurn(root: " (e 1) ")" )
|
|
5490
|
+
swift3 ( "ProcessRuntime.beginDispatchTurn(root: " (e 1) ")" )
|
|
5491
|
+
* ( "/* begin_dispatch_turn not implemented */" )
|
|
5492
|
+
}
|
|
5493
|
+
}
|
|
5494
|
+
|
|
5495
|
+
end_dispatch_turn@(moves@( 1 )) cmdEndDispatchTurn:void (root:RangerProcessBase) {
|
|
5496
|
+
templates {
|
|
5497
|
+
es6 ( "ProcessRuntime.endDispatchTurn(" (e 1) ")" )
|
|
5498
|
+
kotlin ( "ProcessRuntime.endDispatchTurn(" (e 1) ")" )
|
|
5499
|
+
swift6 ( "ProcessRuntime.endDispatchTurn(root: " (e 1) ")" )
|
|
5500
|
+
swift3 ( "ProcessRuntime.endDispatchTurn(root: " (e 1) ")" )
|
|
5501
|
+
* ( "/* end_dispatch_turn not implemented */" )
|
|
5502
|
+
}
|
|
5503
|
+
}
|
|
5504
|
+
|
|
5356
5505
|
proc_start@(moves@( 1 )) cmdProcStart:void (proc:RangerProcessBase) {
|
|
5357
5506
|
templates {
|
|
5358
5507
|
es6 ( "ProcessRuntime.startInstance(" (e 1) ")" )
|
|
@@ -5437,6 +5586,7 @@ systemclass buffer {
|
|
|
5437
5586
|
csharp "byte[]"
|
|
5438
5587
|
kotlin ByteArray
|
|
5439
5588
|
scala "Array[Byte]"
|
|
5589
|
+
llvm i64
|
|
5440
5590
|
}
|
|
5441
5591
|
|
|
5442
5592
|
; SYSTEM CLASS: int_buffer
|
|
@@ -5456,6 +5606,7 @@ systemclass int_buffer {
|
|
|
5456
5606
|
csharp "long[]"
|
|
5457
5607
|
kotlin LongArray
|
|
5458
5608
|
scala "Array[Long]"
|
|
5609
|
+
llvm i64
|
|
5459
5610
|
}
|
|
5460
5611
|
|
|
5461
5612
|
; SYSTEM CLASS: double_buffer
|
|
@@ -5475,6 +5626,7 @@ systemclass double_buffer {
|
|
|
5475
5626
|
csharp "double[]"
|
|
5476
5627
|
kotlin DoubleArray
|
|
5477
5628
|
scala "Array[Double]"
|
|
5629
|
+
llvm i64
|
|
5478
5630
|
}
|
|
5479
5631
|
|
|
5480
5632
|
; ============================================================================
|