ranger-compiler 3.0.5 → 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 +41 -0
- package/README.md +114 -8
- package/dist/Lang.rgr +149 -13
- 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 +82 -4
- 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 +30176 -22193
- 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
|
|
|
@@ -193,9 +229,11 @@ language {
|
|
|
193
229
|
templates {
|
|
194
230
|
ranger ("(cast " (e 1) " " (e 2) ":" (typeof 2) " )")
|
|
195
231
|
ts ( (e 1) " as " (typeof 2) )
|
|
232
|
+
kotlin ( (e 1) " as " (typeof 2) )
|
|
196
233
|
es6 ( (e 1) )
|
|
197
234
|
java7 ( "((" (typeof 2) ")" (e 1) ")" )
|
|
198
235
|
swift3 ( (e 1) " as " (typeof 2) "" )
|
|
236
|
+
swift6 ( (e 1) " as " (typeof 2) "" )
|
|
199
237
|
cpp ( "mpark::get<" (typeof 2) ">(" (e 1) ")"
|
|
200
238
|
|
|
201
239
|
(plugin 'makefile' ((dep 'variant.hpp' 'https://github.com/mpark/variant/releases/download/v1.2.2/variant.hpp')))
|
|
@@ -208,6 +246,7 @@ language {
|
|
|
208
246
|
random _:int ( min:int max:int) {
|
|
209
247
|
templates {
|
|
210
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"))
|
|
211
250
|
}
|
|
212
251
|
}
|
|
213
252
|
|
|
@@ -484,6 +523,7 @@ func r_io_get_env( name string) *GoNullable {
|
|
|
484
523
|
; Command line arguments
|
|
485
524
|
shell_arg cmdArg:string (index:int) {
|
|
486
525
|
templates {
|
|
526
|
+
llvm ( "(shell_arg " (e 1) ")")
|
|
487
527
|
cpp ( "std::string(__g_argv[" (e 1) " + 1])")
|
|
488
528
|
php ( "$argv[" (e 1) " + 1]" )
|
|
489
529
|
java7 ( "args[" (e 1) "]")
|
|
@@ -500,6 +540,7 @@ func r_io_get_env( name string) *GoNullable {
|
|
|
500
540
|
|
|
501
541
|
shell_arg_cnt cmdArg:int () @doc("return the number of arguments for command line utility") {
|
|
502
542
|
templates {
|
|
543
|
+
llvm ( "(shell_arg_cnt)")
|
|
503
544
|
cpp ( "__g_argc - 1")
|
|
504
545
|
swift3 ("CommandLine.arguments.count - 1")
|
|
505
546
|
swift6 ("CommandLine.arguments.count - 1")
|
|
@@ -843,6 +884,7 @@ fn r_write_file(path: &str, filename: &str, data: &str) {
|
|
|
843
884
|
read_file cmdReadFile@(optional async):string (path:string filename:string) {
|
|
844
885
|
|
|
845
886
|
templates {
|
|
887
|
+
llvm ( "(read_file " (e 1) " " (e 2) ")")
|
|
846
888
|
ts ( "await (new Promise<string>(resolve => { require('fs').readFile( " (e 1) " + '/' + " (e 2) " , 'utf8', (err,data)=>{ resolve(data) }) } ))" )
|
|
847
889
|
es6 ( "await (new Promise(resolve => { require('fs').readFile( " (e 1) " + '/' + " (e 2) " , 'utf8', (err,data)=>{ resolve(data) }) } ))" )
|
|
848
890
|
ranger ( "(read_file " (e 1) " " (e 2) ")" )
|
|
@@ -1460,6 +1502,8 @@ fn r_read_file(path: &str, filename: &str) -> Option<String> {
|
|
|
1460
1502
|
int2double cmdIntToDouble:double ( value:int ) {
|
|
1461
1503
|
templates {
|
|
1462
1504
|
ranger ( "(int2double " (e 1) ")" )
|
|
1505
|
+
kotlin ( (e 1) ".toDouble()" )
|
|
1506
|
+
swift6 ( "Double(" (e 1) ")" )
|
|
1463
1507
|
* ( "parseFloat(" (e 1) ")" )
|
|
1464
1508
|
}
|
|
1465
1509
|
}
|
|
@@ -1502,6 +1546,7 @@ fn r_read_file(path: &str, filename: &str) -> Option<String> {
|
|
|
1502
1546
|
rust ( "" (e 1) ".floor() as i64" )
|
|
1503
1547
|
scala ( "math.floor(" (e 1) ").toInt" (imp "scala.math"))
|
|
1504
1548
|
java7 ( "(int)Math.floor(" (e 1) ")" (imp "java.lang.Math"))
|
|
1549
|
+
kotlin ( "(Math.floor(" (e 1) ")).toInt()" (imp "java.lang.Math"))
|
|
1505
1550
|
* ( "Math.floor(" (e 1) ")")
|
|
1506
1551
|
}
|
|
1507
1552
|
}
|
|
@@ -1843,6 +1888,7 @@ fn r_read_file(path: &str, filename: &str) -> Option<String> {
|
|
|
1843
1888
|
csharp ( "new " (typeof 1) "( new " (r_atype 1) "[" (e 2)"])")
|
|
1844
1889
|
swift3 ( "" (typeof 1)"(repeating:" (e 3) ", count:" (e 2) ")" )
|
|
1845
1890
|
ranger ( "(make _:" (typeof 1) " " (e 2) ")" )
|
|
1891
|
+
llvm ( "(make _:" (typeof 1) " " (e 2) ")" )
|
|
1846
1892
|
go ( "make(" (typeof 1) "," (e 2) ")" )
|
|
1847
1893
|
cpp ( (typeof 1) "(" (e 2) ")")
|
|
1848
1894
|
; new ArrayList<Double>( Arrays.asList( new Double[len_2] ) );
|
|
@@ -2035,7 +2081,7 @@ case class customException(smth:String) extends Exception
|
|
|
2035
2081
|
i
|
|
2036
2082
|
"}" nl
|
|
2037
2083
|
)
|
|
2038
|
-
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 "}" )
|
|
2039
2085
|
|
|
2040
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 "}" )
|
|
2041
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 "}" )
|
|
@@ -2186,6 +2232,7 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
|
|
|
2186
2232
|
|
|
2187
2233
|
strlen cmdStrlen:int ( text:string ) {
|
|
2188
2234
|
templates {
|
|
2235
|
+
llvm ( "(strlen " (e 1) ")")
|
|
2189
2236
|
ranger ( "( strlen (" (e 1 ) "))")
|
|
2190
2237
|
cpp ( '(int)('(e 1) ".length())")
|
|
2191
2238
|
java7 ( (e 1) ".length()")
|
|
@@ -2201,6 +2248,50 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
|
|
|
2201
2248
|
}
|
|
2202
2249
|
}
|
|
2203
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
|
+
|
|
2204
2295
|
; String s = new String(a, 2, 4)
|
|
2205
2296
|
|
|
2206
2297
|
; C#
|
|
@@ -2275,6 +2366,7 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
|
|
|
2275
2366
|
; Allocate a new buffer of specified size (zero-filled)
|
|
2276
2367
|
buffer_alloc cmdBufferAlloc:buffer ( size:int ) {
|
|
2277
2368
|
templates {
|
|
2369
|
+
llvm ( "(buffer_alloc " (e 1) ")" )
|
|
2278
2370
|
ranger ( "(buffer_alloc " (e 1) ")" )
|
|
2279
2371
|
es6 ( "(function(){ var b = new ArrayBuffer(" (e 1) "); b._view = new DataView(b); return b; })()" )
|
|
2280
2372
|
go ( "make([]byte, " (e 1) ")" )
|
|
@@ -2290,6 +2382,7 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
|
|
|
2290
2382
|
; Get the length of a buffer in bytes
|
|
2291
2383
|
buffer_length cmdBufferLength:int ( buf:buffer ) {
|
|
2292
2384
|
templates {
|
|
2385
|
+
llvm ( "(buffer_length " (e 1) ")" )
|
|
2293
2386
|
ranger ( "(buffer_length " (e 1) ")" )
|
|
2294
2387
|
es6 ( (e 1) ".byteLength" )
|
|
2295
2388
|
go ( "int64(len(" (e 1) "))" )
|
|
@@ -2305,6 +2398,7 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
|
|
|
2305
2398
|
; Read a single byte at offset (returns 0-255)
|
|
2306
2399
|
buffer_get cmdBufferGet:int ( buf:buffer offset:int ) {
|
|
2307
2400
|
templates {
|
|
2401
|
+
llvm ( "(buffer_get " (e 1) " " (e 2) ")" )
|
|
2308
2402
|
ranger ( "(buffer_get " (e 1) " " (e 2) ")" )
|
|
2309
2403
|
es6 ( (e 1) "._view.getUint8(" (e 2) ")" )
|
|
2310
2404
|
go ( "int64(" (e 1) "[" (e 2) "])" )
|
|
@@ -2320,6 +2414,7 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
|
|
|
2320
2414
|
; Write a single byte at offset (value should be 0-255)
|
|
2321
2415
|
buffer_set cmdBufferSet:void ( buf:buffer offset:int value:int ) {
|
|
2322
2416
|
templates {
|
|
2417
|
+
llvm ( "(buffer_set " (e 1) " " (e 2) " " (e 3) ")" )
|
|
2323
2418
|
ranger ( "(buffer_set " (e 1) " " (e 2) " " (e 3) ")" )
|
|
2324
2419
|
es6 ( (e 1) "._view.setUint8(" (e 2) ", " (e 3) ")" )
|
|
2325
2420
|
go ( (e 1) "[" (e 2) "] = byte(" (e 3) ")" )
|
|
@@ -2398,6 +2493,7 @@ std::string r_buffer_to_base64(const std::vector<uint8_t>& data) {
|
|
|
2398
2493
|
; Write buffer to a binary file
|
|
2399
2494
|
buffer_write_file cmdBufferWriteFile:void ( path:string filename:string buf:buffer ) {
|
|
2400
2495
|
templates {
|
|
2496
|
+
llvm ( "(buffer_write_file " (e 1) " " (e 2) " " (e 3) ")" )
|
|
2401
2497
|
ranger ( "(buffer_write_file " (e 1) " " (e 2) " " (e 3) ")" )
|
|
2402
2498
|
es6 ( "require('fs').writeFileSync(" (e 1) " + '/' + " (e 2) ", Buffer.from(" (e 3) "))" )
|
|
2403
2499
|
go ( "os.WriteFile(" (e 1) " + \"/\" + " (e 2) ", " (e 3) ", 0644)" (imp "os") )
|
|
@@ -2420,6 +2516,7 @@ void r_buffer_write_file(const std::string& path, const std::string& filename, c
|
|
|
2420
2516
|
; Read a binary file into a buffer
|
|
2421
2517
|
buffer_read_file cmdBufferReadFile:buffer ( path:string filename:string ) {
|
|
2422
2518
|
templates {
|
|
2519
|
+
llvm ( "(buffer_read_file " (e 1) " " (e 2) ")" )
|
|
2423
2520
|
ranger ( "(buffer_read_file " (e 1) " " (e 2) ")" )
|
|
2424
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; })()" )
|
|
2425
2522
|
go ( "func() []byte { d, _ := os.ReadFile(filepath.Join(" (e 1) ", " (e 2) ")); return d }()" (imp "os") (imp "path/filepath") )
|
|
@@ -2495,6 +2592,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
|
|
|
2495
2592
|
; Allocate a new int_buffer of specified size (zero-filled)
|
|
2496
2593
|
int_buffer_alloc cmdIntBufferAlloc:int_buffer ( size:int ) {
|
|
2497
2594
|
templates {
|
|
2595
|
+
llvm ( "(int_buffer_alloc " (e 1) ")" )
|
|
2498
2596
|
ranger ( "(int_buffer_alloc " (e 1) ")" )
|
|
2499
2597
|
es6 ( "new Int32Array(" (e 1) ")" )
|
|
2500
2598
|
go ( "make([]int64, " (e 1) ")" )
|
|
@@ -2525,6 +2623,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
|
|
|
2525
2623
|
; Read an int64 at index
|
|
2526
2624
|
int_buffer_get cmdIntBufferGet:int ( buf:int_buffer index:int ) {
|
|
2527
2625
|
templates {
|
|
2626
|
+
llvm ( "(int_buffer_get " (e 1) " " (e 2) ")" )
|
|
2528
2627
|
ranger ( "(int_buffer_get " (e 1) " " (e 2) ")" )
|
|
2529
2628
|
es6 ( (e 1) "[" (e 2) "]" )
|
|
2530
2629
|
go ( (e 1) "[" (e 2) "]" )
|
|
@@ -2540,6 +2639,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
|
|
|
2540
2639
|
; Write an int64 at index
|
|
2541
2640
|
int_buffer_set cmdIntBufferSet:void ( buf:int_buffer index:int value:int ) {
|
|
2542
2641
|
templates {
|
|
2642
|
+
llvm ( "(int_buffer_set " (e 1) " " (e 2) " " (e 3) ")" )
|
|
2543
2643
|
ranger ( "(int_buffer_set " (e 1) " " (e 2) " " (e 3) ")" )
|
|
2544
2644
|
es6 ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
2545
2645
|
go ( (e 1) "[" (e 2) "] = " (e 3) )
|
|
@@ -2555,6 +2655,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
|
|
|
2555
2655
|
; Fill int_buffer with a value in range [start, end)
|
|
2556
2656
|
int_buffer_fill cmdIntBufferFill:void ( buf:int_buffer value:int start:int end:int ) {
|
|
2557
2657
|
templates {
|
|
2658
|
+
llvm ( "(int_buffer_fill " (e 1) " " (e 2) " " (e 3) " " (e 4) ")" )
|
|
2558
2659
|
ranger ( "(int_buffer_fill " (e 1) " " (e 2) " " (e 3) " " (e 4) ")" )
|
|
2559
2660
|
es6 ( (e 1) ".fill(" (e 2) ", " (e 3) ", " (e 4) ")" )
|
|
2560
2661
|
go ( "for i := " (e 3) "; i < " (e 4) "; i++ { " (e 1) "[i] = " (e 2) " }" )
|
|
@@ -2716,6 +2817,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
|
|
|
2716
2817
|
|
|
2717
2818
|
to_int cmdToInt:int ( value:double ) {
|
|
2718
2819
|
templates {
|
|
2820
|
+
llvm ( "(to_int " (e 1) ")" )
|
|
2719
2821
|
ranger ( "(to_int " (e 1) ")")
|
|
2720
2822
|
csharp ( "(int)" (e 1 ) "" )
|
|
2721
2823
|
swift3 ( "Int(" (e 1 ) ")" )
|
|
@@ -2785,6 +2887,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
|
|
|
2785
2887
|
at _:string ( text:string position:int ) {
|
|
2786
2888
|
templates {
|
|
2787
2889
|
ranger ( '(at ' (e 1) ' ' ( e 2 ) ')')
|
|
2890
|
+
llvm ( "(at " (e 1) " " (e 2) ")")
|
|
2788
2891
|
cpp ( 'r_utf8_char_at(' (e 1) ', ' (e 2) ')'
|
|
2789
2892
|
(create_polyfill '
|
|
2790
2893
|
std::string r_utf8_char_at(const std::string& str, int pos_i)
|
|
@@ -2833,6 +2936,7 @@ std::string r_utf8_char_at(const std::string& str, int pos_i)
|
|
|
2833
2936
|
|
|
2834
2937
|
charAt cmdCharAt:int ( text:string position:int ) {
|
|
2835
2938
|
templates {
|
|
2939
|
+
llvm ( "(charAt " (e 1) " " (e 2) ")")
|
|
2836
2940
|
ranger ( "(charAt " (e 1) " " ( e 2 ) ")")
|
|
2837
2941
|
cpp ( (e 1) ".at(" (e 2) ")")
|
|
2838
2942
|
csharp ( (e 1) "[" (e 2) "]")
|
|
@@ -2970,7 +3074,9 @@ std::string r_utf8_substr(const std::string& str, int start_i, int leng_i)
|
|
|
2970
3074
|
ranger ( "(strfromcode " (e 1) ")")
|
|
2971
3075
|
csharp ( "((char)" (e 1) ").toString()")
|
|
2972
3076
|
java7 ( "(new String( new char[] {" (e 1) " }))")
|
|
3077
|
+
kotlin ( (e 1) ".toChar().toString()")
|
|
2973
3078
|
swift3 ( "(String( Character( UnicodeScalar(" (e 1) " ) )))")
|
|
3079
|
+
swift6 ( "String(UnicodeScalar(" (e 1) ")!)")
|
|
2974
3080
|
php ( "chr(" (e 1) ")")
|
|
2975
3081
|
scala ( "(" (e 1) ".toChar)")
|
|
2976
3082
|
go ("string([]rune{rune(" (e 1) ")})")
|
|
@@ -2986,7 +3092,9 @@ std::string r_utf8_substr(const std::string& str, int start_i, int leng_i)
|
|
|
2986
3092
|
ranger ( "(strfromcode " (e 1) ")")
|
|
2987
3093
|
csharp ( "((char)" (e 1) ").toString()")
|
|
2988
3094
|
java7 ( "(new String( Character.toChars(" (e 1) ")))")
|
|
3095
|
+
kotlin ( (e 1) ".toChar().toString()")
|
|
2989
3096
|
swift3 ( "(String( Character( UnicodeScalar(" (e 1) " )! )))")
|
|
3097
|
+
swift6 ( "String(UnicodeScalar(" (e 1) ")!)")
|
|
2990
3098
|
php ( "chr(" (e 1) ")")
|
|
2991
3099
|
scala ( "(" (e 1) ".toChar)")
|
|
2992
3100
|
go ("string([]rune{rune(" (e 1) ")})")
|
|
@@ -3382,6 +3490,9 @@ std::string join(const T& v, const std::string& delim) {
|
|
|
3382
3490
|
get cmdGet@(optional):T ( a:[T] index:int ) {
|
|
3383
3491
|
templates {
|
|
3384
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) "]" )
|
|
3385
3496
|
}
|
|
3386
3497
|
}
|
|
3387
3498
|
|
|
@@ -3431,6 +3542,7 @@ r_optional_primitive<int> cpp_get_map_int_value( std::map<" (r_ktype 1) ", int>
|
|
|
3431
3542
|
get cmdGet@(optional weak):T ( map:[K:T] key:K ) {
|
|
3432
3543
|
templates {
|
|
3433
3544
|
ranger ( "(get " (e 1) " " (e 2) ")")
|
|
3545
|
+
llvm ( "(get " (e 1) " " (e 2) ")")
|
|
3434
3546
|
java7 ( (e 1) ".get(" (e 2) ")" )
|
|
3435
3547
|
rust ( (e 1) ".get(" (e 2) ")" )
|
|
3436
3548
|
|
|
@@ -3463,6 +3575,7 @@ i "}" nl ))
|
|
|
3463
3575
|
set cmdSet@(moves@( 3 1 ) ):void ( array@(mutates):[T] index:int value@( refto@(1) ):T ) {
|
|
3464
3576
|
templates {
|
|
3465
3577
|
ranger ( "set " (e 1) " " (e 2) " " (e 3) )
|
|
3578
|
+
llvm ( "set " (e 1) " " (e 2) " " (e 3) )
|
|
3466
3579
|
java7 ( (e 1) ".set(" (e 2) ", " (e 3) ");" )
|
|
3467
3580
|
rust ( (e 1) "[" (e 2) " as usize] = " (e 3) ";" )
|
|
3468
3581
|
scala ( (e 1) "(" (e 2) ") = " (e 3) )
|
|
@@ -3477,6 +3590,7 @@ i "}" nl ))
|
|
|
3477
3590
|
set cmdSet@(moves@( 3 1 ) ):void ( map@(mutates):[K:T] key:K value@( refto@(1) ):T ) {
|
|
3478
3591
|
templates {
|
|
3479
3592
|
ranger ( "set " (e 1) " " (e 2) " " (e 3) )
|
|
3593
|
+
llvm ( "set " (e 1) " " (e 2) " " (e 3) )
|
|
3480
3594
|
java7 ( (e 1) ".put(" (e 2) ", " (e 3) ");" )
|
|
3481
3595
|
rust ( (e 1) ".insert(" (e 2) ", " (e 3) ");" )
|
|
3482
3596
|
scala ( (e 1) ".put(" (e 2) ", " (e 3) ")" )
|
|
@@ -3502,6 +3616,7 @@ i "}" nl ))
|
|
|
3502
3616
|
itemAt cmdItemAt@(weak):T ( array:[T] index:int ) {
|
|
3503
3617
|
templates {
|
|
3504
3618
|
ranger ( "(itemAt " (e 1) " " (e 2) ")" )
|
|
3619
|
+
llvm ( "(itemAt " (e 1) " " (e 2) ")" )
|
|
3505
3620
|
cpp ( (e 1) ".at(" (e 2) ")" (imp "<vector>"))
|
|
3506
3621
|
java7 ( (e 1) ".get(" (e 2) ")" )
|
|
3507
3622
|
; lift return optional type => safer
|
|
@@ -3563,6 +3678,7 @@ int r_string_index_of_from( std::string str, std::string key, int start ) {
|
|
|
3563
3678
|
" )
|
|
3564
3679
|
)
|
|
3565
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) ")" )
|
|
3566
3682
|
ranger ( "(indexOfFrom " (e 1) " " (e 2) " " (e 3) ")")
|
|
3567
3683
|
}
|
|
3568
3684
|
}
|
|
@@ -3867,6 +3983,7 @@ func r_index_of ( arr:" (typeof 1) " , elem: " (typeof 2) ") -> Int { " nl I
|
|
|
3867
3983
|
|
|
3868
3984
|
length cmdStrlen:int ( text:string ) {
|
|
3869
3985
|
templates {
|
|
3986
|
+
llvm ( "(length " (e 1) ")")
|
|
3870
3987
|
ranger ( "(length " (e 1) ")")
|
|
3871
3988
|
cpp ( (e 1) ".length()")
|
|
3872
3989
|
java7 ( (e 1) ".length()")
|
|
@@ -3962,6 +4079,7 @@ func r_index_of ( arr:" (typeof 1) " , elem: " (typeof 2) ") -> Int { " nl I
|
|
|
3962
4079
|
array_length cmdArrayLength:int ( array:[T] ) {
|
|
3963
4080
|
templates {
|
|
3964
4081
|
ranger ( "(array_length " (e 1) ")")
|
|
4082
|
+
llvm ( "(array_length " (e 1) ")")
|
|
3965
4083
|
cpp ( '(int)(' (e 1) ".size())" )
|
|
3966
4084
|
swift3 ( (e 1) ".count")
|
|
3967
4085
|
swift6 ( (e 1) ".count")
|
|
@@ -4025,6 +4143,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
|
|
|
4025
4143
|
print cmdPrint:void ( text:string) {
|
|
4026
4144
|
templates {
|
|
4027
4145
|
ranger ( nl "print " (e 1) nl)
|
|
4146
|
+
llvm ( nl "print " (e 1) nl)
|
|
4028
4147
|
cpp (ln "std::cout << " (e 1) " << std::endl;" nl (imp "<iostream>") (imp "<string>"))
|
|
4029
4148
|
kotlin ( nl "println( " (e 1) " )" nl )
|
|
4030
4149
|
scala ( "println( " (e 1) " )" )
|
|
@@ -4044,6 +4163,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
|
|
|
4044
4163
|
; Write text without newline
|
|
4045
4164
|
write cmdWrite:void ( text:string) {
|
|
4046
4165
|
templates {
|
|
4166
|
+
llvm ( nl "write " (e 1) nl)
|
|
4047
4167
|
cpp ( nl "std::cout << " (e 1) " << std::flush;" nl (imp "<iostream>"))
|
|
4048
4168
|
go ( nl "fmt.Print( " (e 1) " )" nl (imp "fmt"))
|
|
4049
4169
|
rust ( nl "print!(\"{}\", " (e 1) ");" nl)
|
|
@@ -4061,6 +4181,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
|
|
|
4061
4181
|
; Clear the terminal screen
|
|
4062
4182
|
clear_screen cmdClearScreen:void () {
|
|
4063
4183
|
templates {
|
|
4184
|
+
llvm ( nl "clear_screen" nl)
|
|
4064
4185
|
cpp ( nl "std::cout << \"\\x1b[2J\\x1b[H\" << std::flush;" nl (imp "<iostream>"))
|
|
4065
4186
|
go ( nl "fmt.Print(\"\\x1b[2J\\x1b[H\")" nl (imp "fmt"))
|
|
4066
4187
|
rust ( nl "print!(\"\\x1b[2J\\x1b[H\");" nl)
|
|
@@ -4078,6 +4199,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
|
|
|
4078
4199
|
; Move cursor to position (1-based coordinates)
|
|
4079
4200
|
move_cursor cmdMoveCursor:void ( x:int y:int) {
|
|
4080
4201
|
templates {
|
|
4202
|
+
llvm ( nl "move_cursor " (e 1) " " (e 2) nl)
|
|
4081
4203
|
cpp ( nl "std::cout << \"\\x1b[\" << (" (e 2) ") << \";\" << (" (e 1) ") << \"H\" << std::flush;" nl (imp "<iostream>"))
|
|
4082
4204
|
go ( nl "fmt.Printf(\"\\x1b[%d;%dH\", " (e 2) ", " (e 1) ")" nl (imp "fmt"))
|
|
4083
4205
|
rust ( nl "print!(\"\\x1b[{};{}H\", " (e 2) ", " (e 1) ");" nl)
|
|
@@ -4095,6 +4217,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
|
|
|
4095
4217
|
; Hide terminal cursor
|
|
4096
4218
|
hide_cursor cmdHideCursor:void () {
|
|
4097
4219
|
templates {
|
|
4220
|
+
llvm ( nl "hide_cursor" nl)
|
|
4098
4221
|
cpp ( nl "std::cout << \"\\x1b[?25l\" << std::flush;" nl (imp "<iostream>"))
|
|
4099
4222
|
go ( nl "fmt.Print(\"\\x1b[?25l\")" nl (imp "fmt"))
|
|
4100
4223
|
rust ( nl "print!(\"\\x1b[?25l\");" nl)
|
|
@@ -4112,6 +4235,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
|
|
|
4112
4235
|
; Show terminal cursor
|
|
4113
4236
|
show_cursor cmdShowCursor:void () {
|
|
4114
4237
|
templates {
|
|
4238
|
+
llvm ( nl "show_cursor" nl)
|
|
4115
4239
|
cpp ( nl "std::cout << \"\\x1b[?25h\" << std::flush;" nl (imp "<iostream>"))
|
|
4116
4240
|
go ( nl "fmt.Print(\"\\x1b[?25h\")" nl (imp "fmt"))
|
|
4117
4241
|
rust ( nl "print!(\"\\x1b[?25h\");" nl)
|
|
@@ -4837,6 +4961,7 @@ fun r_read_key(): String {
|
|
|
4837
4961
|
; Sleep for specified milliseconds (blocking)
|
|
4838
4962
|
sleep_ms cmdSleepMs@(async):void (ms:int) {
|
|
4839
4963
|
templates {
|
|
4964
|
+
llvm ( nl "sleep_ms " (e 1) nl)
|
|
4840
4965
|
es6 ( nl "await new Promise(r => setTimeout(r, " (e 1) "));" nl )
|
|
4841
4966
|
rust ( nl "std::thread::sleep(std::time::Duration::from_millis(" (e 1) " as u64));" nl )
|
|
4842
4967
|
go ( nl "time.Sleep(time.Duration(" (e 1) ") * time.Millisecond)" nl (imp "time"))
|
|
@@ -4854,6 +4979,7 @@ fun r_read_key(): String {
|
|
|
4854
4979
|
|
|
4855
4980
|
exit cmdExit:void ( code:int) {
|
|
4856
4981
|
templates {
|
|
4982
|
+
llvm ( nl "exit " (e 1) nl)
|
|
4857
4983
|
ranger ( nl "exit " (e 1) nl)
|
|
4858
4984
|
cpp ( nl "exit(" (e 1) ");" nl (imp "<cstdlib>"))
|
|
4859
4985
|
kotlin ( nl "System.exit(" (e 1) ")" nl )
|
|
@@ -4873,10 +4999,12 @@ fun r_read_key(): String {
|
|
|
4873
4999
|
templates {
|
|
4874
5000
|
es6 ((e 1) '.toLowerCase()')
|
|
4875
5001
|
java7 ((e 1) '.toLowerCase()')
|
|
5002
|
+
kotlin ((e 1) '.lowercase()')
|
|
4876
5003
|
go ( "strings.ToLower(" (e 1) ")" (imp "strings"))
|
|
4877
5004
|
php ("strtolower(" (e 1) ")")
|
|
4878
5005
|
csharp ((e 1) ".ToLower()")
|
|
4879
5006
|
swift3 ((e 1) ".lowercased()")
|
|
5007
|
+
swift6 ((e 1) ".lowercased()")
|
|
4880
5008
|
scala ((e 1) ".toLowerCase()")
|
|
4881
5009
|
python ((e 1) ".lower()")
|
|
4882
5010
|
}
|
|
@@ -4884,6 +5012,8 @@ fun r_read_key(): String {
|
|
|
4884
5012
|
to_uppercase _:string (s:string) {
|
|
4885
5013
|
templates {
|
|
4886
5014
|
swift3 ( (e 1) ".uppercased()")
|
|
5015
|
+
swift6 ( (e 1) ".uppercased()")
|
|
5016
|
+
kotlin ( (e 1) ".uppercase()" )
|
|
4887
5017
|
scala ( (e 1 ) ".toUpperCase()" )
|
|
4888
5018
|
ranger ("(to_uppercase " (e 1) ")")
|
|
4889
5019
|
es6 ( (e 1) ".toUpperCase()")
|
|
@@ -4915,6 +5045,7 @@ std::string r_cpp_str_to_uppercase(std::string original)
|
|
|
4915
5045
|
|
|
4916
5046
|
to_double toDouble:double ( input:int ) {
|
|
4917
5047
|
templates {
|
|
5048
|
+
llvm ( "(to_double " (e 1) ")" )
|
|
4918
5049
|
ranger ("( to_double " (e 1) " )")
|
|
4919
5050
|
go ("float64( " (e 1) " )")
|
|
4920
5051
|
es6 ( (e 1) )
|
|
@@ -5349,23 +5480,25 @@ std::string r_cpp_str_to_uppercase(std::string original)
|
|
|
5349
5480
|
}
|
|
5350
5481
|
}
|
|
5351
5482
|
|
|
5352
|
-
proc_send
|
|
5483
|
+
; proc_send is lowered in ng_RangerProcessProcSend.rgr (typed handler methods, overload match).
|
|
5484
|
+
|
|
5485
|
+
begin_dispatch_turn@(moves@( 1 )) cmdBeginDispatchTurn:void (root:RangerProcessBase) {
|
|
5353
5486
|
templates {
|
|
5354
|
-
es6 ( "
|
|
5355
|
-
kotlin ( "
|
|
5356
|
-
swift6 ( "
|
|
5357
|
-
swift3 ( "
|
|
5358
|
-
* ( "/*
|
|
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 */" )
|
|
5359
5492
|
}
|
|
5360
5493
|
}
|
|
5361
5494
|
|
|
5362
|
-
|
|
5495
|
+
end_dispatch_turn@(moves@( 1 )) cmdEndDispatchTurn:void (root:RangerProcessBase) {
|
|
5363
5496
|
templates {
|
|
5364
|
-
es6 ( "(
|
|
5365
|
-
kotlin ( "
|
|
5366
|
-
swift6 ( "
|
|
5367
|
-
swift3 ( "
|
|
5368
|
-
* ( "/*
|
|
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 */" )
|
|
5369
5502
|
}
|
|
5370
5503
|
}
|
|
5371
5504
|
|
|
@@ -5453,6 +5586,7 @@ systemclass buffer {
|
|
|
5453
5586
|
csharp "byte[]"
|
|
5454
5587
|
kotlin ByteArray
|
|
5455
5588
|
scala "Array[Byte]"
|
|
5589
|
+
llvm i64
|
|
5456
5590
|
}
|
|
5457
5591
|
|
|
5458
5592
|
; SYSTEM CLASS: int_buffer
|
|
@@ -5472,6 +5606,7 @@ systemclass int_buffer {
|
|
|
5472
5606
|
csharp "long[]"
|
|
5473
5607
|
kotlin LongArray
|
|
5474
5608
|
scala "Array[Long]"
|
|
5609
|
+
llvm i64
|
|
5475
5610
|
}
|
|
5476
5611
|
|
|
5477
5612
|
; SYSTEM CLASS: double_buffer
|
|
@@ -5491,6 +5626,7 @@ systemclass double_buffer {
|
|
|
5491
5626
|
csharp "double[]"
|
|
5492
5627
|
kotlin DoubleArray
|
|
5493
5628
|
scala "Array[Double]"
|
|
5629
|
+
llvm i64
|
|
5494
5630
|
}
|
|
5495
5631
|
|
|
5496
5632
|
; ============================================================================
|