1.0.12 • Published 2 years ago

nv-cli-ictx v1.0.12

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

nv-cli-ictx

  • nv-cli-ictx
  • cli tool, generate a ctx for lex-var, its a simple version of nv-macro-lexvar

install

  • npm install nv-cli-ictx -g

usage

    Usage: nv_cli_ictx [options]
    Options:
        -c, --ctxname            ctxname
        -p, --props              property desciptions
        -i, --indent             indent
        -f, --format_help        the suffix format help
        -h, --help               usage

example

        nv-cli-ictx# nv_cli_ictx -c ictx -p a@gtst b@gtst c@gtst

output

let ictx = {
    get a()  {return(a)},
    set a(v) {a =v},
    get b()  {return(b)},
    set b(v) {b =v},
    get c()  {return(c)},
    set c(v) {c =v},
    "#": -1,
    _rtrn()           {ictx["#"]=0},
    _thrw()           {ictx["#"]=1},
    _break()          {ictx["#"]=2},
    _continue()       {ictx["#"]=3},
    get completion_() {return(ictx["#"])}
}

copy AND paste it

    const _while = (ictx) => {
        while(ictx.a<5) {
           ictx.b = ictx.b+ictx.c;
           ictx.a = ictx.a+1
           ictx._rtrn()
        }
        return(ictx); 
    }

    function tst() {
        ///
        let a=0;
        let b=20;
        let c=30;
        ///-------pre
        let ictx = {
            get a()  {return(a)},
            set a(v) {a =v},
            get b()  {return(b)},
            set b(v) {b =v},
            get c()  {return(c)},
            set c(v) {c =v},
            "#": -1,
            _rtrn()           {ictx["#"]=0},
            _thrw()           {ictx["#"]=1},
            _break()          {ictx["#"]=2},
            _continue()       {ictx["#"]=3},
            get completion_() {return(ictx["#"])}
        }
        ////----handler

        _while(ictx);
        
        ////----post
        if(ictx.completion_===0) {
            return(b)
        }
    }

    /*
    > tst()
    170
    >

    */

LICENSE

  • ISC