nilscript2to3 is a tool to help migrate oj/NilScript 2.x files to NilScript 3.
- Rename all files with an
.ojextension to use a.nsextension
find . -name '*.oj' -exec sh -c 'mv "$0" "${0%.oj}.ns"' {} \;
- Run
nilscript2to3 --checkon all.nsfiles:
find . -name '*.ns' -exec path/to/nilscript2to3 --check {} \;
This will check the files and print warnings for a subset of issues which cause parse error in NilScript 3:
- The use of
@forwarddirective - The use of
@squeezedirective - The use of the following types:
double,float,int,char,short,long,Bool,bool - A naming conflict between/among a class, protocol, and/or
@type
- Run
nilscript2to3 --rewriteon all.nsfiles.
find . -name '*.ns' -rewrite path/to/nilscript2to3 --check {} \;
This performs the following:
- Rewrites
id<TheProtocol>type annotations intoTheProtocol - Rewrites
@property TheType thePropertyinto@property theProperty : TheType - Rewrites
@implementation TheClassinto@class TheClass@implementation,@property, and protocol types into their new format.
- Find and replace the following in your build scripts:
| Find | Replace | Notes |
|---|---|---|
.oj |
.ns |
File extensions |
ojc |
nsc |
References to the compiler binary |
ojc |
nilscript References to the npm package |
|
oj |
nilscript |
The public API global variable (oj.isObject()) |
$oj_oj |
N$_nilscript |
The global variable used by the compiler |
- Find any replace any usage of the following in your symbolication/crash reporting scripts:
?????