motoko 3.0.0-beta5 → 3.0.0-beta7
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/contrib/hljs.js +13 -15
- package/contrib/monaco.js +4 -10
- package/lib/ast.d.ts +7 -1
- package/lib/ast.d.ts.map +1 -1
- package/lib/ast.js +5 -5
- package/lib/ast.js.map +1 -1
- package/lib/keywords.d.ts +3 -0
- package/lib/keywords.d.ts.map +1 -0
- package/lib/keywords.js +75 -0
- package/lib/keywords.js.map +1 -0
- package/package.json +1 -1
- package/packages/latest/base.json +1 -1
- package/src/ast.ts +13 -6
- package/src/keywords.ts +72 -0
- package/versions/latest/moc.min.js +1 -1
- package/versions/latest/moc_interpreter.min.js +1 -1
    
        package/contrib/hljs.js
    CHANGED
    
    | @@ -1,5 +1,9 @@ | |
| 1 1 | 
             
            'use strict';
         | 
| 2 2 |  | 
| 3 | 
            +
            const { keywords, typeKeywords } = require('../lib/keywords');
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            const literalKeywords = ['true', 'false', 'null'];
         | 
| 6 | 
            +
             | 
| 3 7 | 
             
            /// Highlight.js configuration
         | 
| 4 8 | 
             
            exports.configure = (hljs) => {
         | 
| 5 9 | 
             
                var string = {
         | 
| @@ -25,25 +29,19 @@ exports.configure = (hljs) => { | |
| 25 29 | 
             
                    ],
         | 
| 26 30 | 
             
                    relevance: 0,
         | 
| 27 31 | 
             
                };
         | 
| 28 | 
            -
                hljs.registerLanguage('motoko',  | 
| 32 | 
            +
                hljs.registerLanguage('motoko', (hljs) => {
         | 
| 29 33 | 
             
                    return {
         | 
| 30 34 | 
             
                        name: 'Motoko',
         | 
| 31 35 | 
             
                        aliases: ['mo'],
         | 
| 32 36 | 
             
                        keywords: {
         | 
| 33 37 | 
             
                            $pattern: '[a-zA-Z_]\\w*',
         | 
| 34 | 
            -
                            keyword:
         | 
| 35 | 
            -
                                 | 
| 36 | 
            -
             | 
| 37 | 
            -
                                 | 
| 38 | 
            -
                                '  | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
                            literal: 'true false null',
         | 
| 42 | 
            -
                            built_in:
         | 
| 43 | 
            -
                                'Any None Null Bool Int Int8 Int16 Int32 Int64' +
         | 
| 44 | 
            -
                                ' Nat Nat8 Nat16 Nat32 Nat64 Word8 Word16 Word32 Word64' +
         | 
| 45 | 
            -
                                ' Float Char Text Blob Error Principal' +
         | 
| 46 | 
            -
                                ' async',
         | 
| 38 | 
            +
                            keyword: keywords
         | 
| 39 | 
            +
                                .filter(
         | 
| 40 | 
            +
                                    (k) => !literalKeywords.includes(k) && k !== 'async',
         | 
| 41 | 
            +
                                )
         | 
| 42 | 
            +
                                .join(' '),
         | 
| 43 | 
            +
                            literal: literalKeywords.join(' '),
         | 
| 44 | 
            +
                            built_in: `async ${typeKeywords.join(' ')}`,
         | 
| 47 45 | 
             
                        },
         | 
| 48 46 | 
             
                        illegal: '</',
         | 
| 49 47 | 
             
                        contains: [
         | 
| @@ -92,7 +90,7 @@ exports.configure = (hljs) => { | |
| 92 90 | 
             
                        ],
         | 
| 93 91 | 
             
                    };
         | 
| 94 92 | 
             
                });
         | 
| 95 | 
            -
                hljs.registerLanguage('candid',  | 
| 93 | 
            +
                hljs.registerLanguage('candid', (hljs) => {
         | 
| 96 94 | 
             
                    return {
         | 
| 97 95 | 
             
                        name: 'Candid',
         | 
| 98 96 | 
             
                        aliases: ['did'],
         | 
    
        package/contrib/monaco.js
    CHANGED
    
    | @@ -1,5 +1,7 @@ | |
| 1 1 | 
             
            'use strict';
         | 
| 2 2 |  | 
| 3 | 
            +
            const { keywords, typeKeywords } = require('../lib/keywords');
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            /// Monaco editor configuration
         | 
| 4 6 | 
             
            exports.configure = (monaco) => {
         | 
| 5 7 | 
             
                monaco.languages.register({ id: 'motoko' });
         | 
| @@ -25,12 +27,7 @@ exports.configure = (monaco) => { | |
| 25 27 | 
             
                    defaultToken: '',
         | 
| 26 28 | 
             
                    tokenPostfix: '.mo',
         | 
| 27 29 | 
             
                    // prettier-ignore
         | 
| 28 | 
            -
                    keywords | 
| 29 | 
            -
                        'actor', 'and', 'async', 'assert', 'await', 'break', 'case', 'catch', 'class',
         | 
| 30 | 
            -
                        'continue', 'debug', 'debug_show', 'do', 'else', 'false', 'flexible', 'for', 'from_candid', 'func', 'if', 'ignore', 'in',
         | 
| 31 | 
            -
                        'import', 'label', 'let', 'loop', 'module', 'not', 'null', 'object', 'or', 'private', 'public', 'query', 'return', 'shared',
         | 
| 32 | 
            -
                        'stable', 'switch', 'system', 'throw', 'to_candid', 'true', 'try', 'type', 'var', 'while', 'with',
         | 
| 33 | 
            -
                    ],
         | 
| 30 | 
            +
                    keywords,
         | 
| 34 31 | 
             
                    accessmodifiers: [
         | 
| 35 32 | 
             
                        'public',
         | 
| 36 33 | 
             
                        'private',
         | 
| @@ -41,10 +38,7 @@ exports.configure = (monaco) => { | |
| 41 38 | 
             
                        'system',
         | 
| 42 39 | 
             
                    ],
         | 
| 43 40 | 
             
                    // prettier-ignore
         | 
| 44 | 
            -
                    typeKeywords | 
| 45 | 
            -
                        'Any', 'None', 'Null', 'Bool', 'Int', 'Int8', 'Int16', 'Int32', 'Int64', 'Nat',
         | 
| 46 | 
            -
                        'Nat8', 'Nat16', 'Nat32', 'Nat64', 'Float', 'Char', 'Text', 'Blob', 'Error', 'Principal',
         | 
| 47 | 
            -
                    ],
         | 
| 41 | 
            +
                    typeKeywords,
         | 
| 48 42 | 
             
                    // prettier-ignore
         | 
| 49 43 | 
             
                    operators: [
         | 
| 50 44 | 
             
                        '=', '<', '>', ':', '<:', '?', '+', '-', '*', '/', '%', '**', '+%', '-%', '*%', '**%', '&', '|', '^', '<<', '>>', '<<>', '<>>',
         | 
    
        package/lib/ast.d.ts
    CHANGED
    
    | @@ -9,12 +9,18 @@ export interface CompilerNode { | |
| 9 9 | 
             
            }
         | 
| 10 10 | 
             
            export declare type Span = [number, number];
         | 
| 11 11 | 
             
            export declare type AST = AST[] | Node | string | null;
         | 
| 12 | 
            -
            export interface  | 
| 12 | 
            +
            export interface Source {
         | 
| 13 | 
            +
                file?: string;
         | 
| 14 | 
            +
                start?: Span;
         | 
| 15 | 
            +
                end?: Span;
         | 
| 16 | 
            +
            }
         | 
| 17 | 
            +
            export interface Node extends Source {
         | 
| 13 18 | 
             
                name: string;
         | 
| 14 19 | 
             
                file?: string;
         | 
| 15 20 | 
             
                start?: Span;
         | 
| 16 21 | 
             
                end?: Span;
         | 
| 17 22 | 
             
                type?: Node;
         | 
| 23 | 
            +
                declaration?: Source;
         | 
| 18 24 | 
             
                args?: AST[];
         | 
| 19 25 | 
             
            }
         | 
| 20 26 | 
             
            export declare function simplifyAST(ast: CompilerNode): Node;
         | 
    
        package/lib/ast.d.ts.map
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            {"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW,GAAG,WAAW,EAAE,GAAG,YAAY,GAAG,MAAM,GAAG,IAAI,CAAC;AACvE,oBAAY,YAAY,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC;AAE3E,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,oBAAY,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACpC,oBAAY,GAAG,GAAG,GAAG,EAAE,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;AAE/C,MAAM,WAAW,IAAI; | 
| 1 | 
            +
            {"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW,GAAG,WAAW,EAAE,GAAG,YAAY,GAAG,MAAM,GAAG,IAAI,CAAC;AACvE,oBAAY,YAAY,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC;AAE3E,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,oBAAY,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACpC,oBAAY,GAAG,GAAG,GAAG,EAAE,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;AAE/C,MAAM,WAAW,MAAM;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,GAAG,CAAC,EAAE,IAAI,CAAC;CACd;AAED,MAAM,WAAW,IAAK,SAAQ,MAAM;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;CAChB;AAQD,wBAAgB,WAAW,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CAAC;AACrD,wBAAgB,WAAW,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,GAAG,EAAE,CAAC;AACvD,wBAAgB,WAAW,CAAC,CAAC,SAAS,WAAW,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC"}
         | 
    
        package/lib/ast.js
    CHANGED
    
    | @@ -15,11 +15,11 @@ function simplifyAST(ast) { | |
| 15 15 | 
             
                        : simplifyAST(subAst))), { file: start.args[0], start: [+start.args[1], +start.args[2]], end: [+end.args[1], +end.args[2]] });
         | 
| 16 16 | 
             
                }
         | 
| 17 17 | 
             
                if (ast.name === ':') {
         | 
| 18 | 
            -
                    const [ | 
| 19 | 
            -
                    // console.log( | 
| 20 | 
            -
                    return Object.assign(Object.assign({}, (typeof  | 
| 21 | 
            -
                        ? { name:  | 
| 22 | 
            -
                        : simplifyAST( | 
| 18 | 
            +
                    const [typeAst, type] = ast.args;
         | 
| 19 | 
            +
                    // console.log(typeAst); ////
         | 
| 20 | 
            +
                    return Object.assign(Object.assign({}, (typeof typeAst === 'string'
         | 
| 21 | 
            +
                        ? { name: typeAst }
         | 
| 22 | 
            +
                        : simplifyAST(typeAst))), { type: simplifyAST(type) });
         | 
| 23 23 | 
             
                }
         | 
| 24 24 | 
             
                return {
         | 
| 25 25 | 
             
                    name: ast.name,
         | 
    
        package/lib/ast.js.map
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            {"version":3,"file":"ast.js","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":";;; | 
| 1 | 
            +
            {"version":3,"file":"ast.js","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":";;;AAqCA,SAAgB,WAAW,CAAC,GAAgB;IACxC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACpB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;KACzC;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QACzB,OAAO,GAAG,CAAC;KACd;IACD,IAAI,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE;QAClB,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC,IAIhC,CAAC;QACF,uCACO,CAAC,OAAO,MAAM,KAAK,QAAQ;YAC1B,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;YAClB,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,KAC1B,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EACnB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EACvC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IACnC;KACL;IACD,IAAI,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE;QAClB,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,GAAG,CAAC,IAAmC,CAAC;QAChE,6BAA6B;QAC7B,uCACO,CAAC,OAAO,OAAO,KAAK,QAAQ;YAC3B,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;YACnB,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,KAC3B,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,IACzB;KACL;IACD,OAAO;QACH,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC;KAC9B,CAAC;AACN,CAAC;AApCD,kCAoCC;AAED,+CAA+C"}
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            {"version":3,"file":"keywords.d.ts","sourceRoot":"","sources":["../src/keywords.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,UAgDpB,CAAC;AAEF,eAAO,MAAM,YAAY,UAqBxB,CAAC"}
         | 
    
        package/lib/keywords.js
    ADDED
    
    | @@ -0,0 +1,75 @@ | |
| 1 | 
            +
            "use strict";
         | 
| 2 | 
            +
            Object.defineProperty(exports, "__esModule", { value: true });
         | 
| 3 | 
            +
            exports.typeKeywords = exports.keywords = void 0;
         | 
| 4 | 
            +
            exports.keywords = [
         | 
| 5 | 
            +
                'actor',
         | 
| 6 | 
            +
                'and',
         | 
| 7 | 
            +
                'async',
         | 
| 8 | 
            +
                'assert',
         | 
| 9 | 
            +
                'await',
         | 
| 10 | 
            +
                'break',
         | 
| 11 | 
            +
                'case',
         | 
| 12 | 
            +
                'catch',
         | 
| 13 | 
            +
                'class',
         | 
| 14 | 
            +
                'continue',
         | 
| 15 | 
            +
                'debug',
         | 
| 16 | 
            +
                'debug_show',
         | 
| 17 | 
            +
                'do',
         | 
| 18 | 
            +
                'else',
         | 
| 19 | 
            +
                'false',
         | 
| 20 | 
            +
                'flexible',
         | 
| 21 | 
            +
                'for',
         | 
| 22 | 
            +
                'from_candid',
         | 
| 23 | 
            +
                'func',
         | 
| 24 | 
            +
                'if',
         | 
| 25 | 
            +
                'ignore',
         | 
| 26 | 
            +
                'in',
         | 
| 27 | 
            +
                'import',
         | 
| 28 | 
            +
                'label',
         | 
| 29 | 
            +
                'let',
         | 
| 30 | 
            +
                'loop',
         | 
| 31 | 
            +
                'module',
         | 
| 32 | 
            +
                'not',
         | 
| 33 | 
            +
                'null',
         | 
| 34 | 
            +
                'object',
         | 
| 35 | 
            +
                'or',
         | 
| 36 | 
            +
                'private',
         | 
| 37 | 
            +
                'public',
         | 
| 38 | 
            +
                'query',
         | 
| 39 | 
            +
                'return',
         | 
| 40 | 
            +
                'shared',
         | 
| 41 | 
            +
                'stable',
         | 
| 42 | 
            +
                'switch',
         | 
| 43 | 
            +
                'system',
         | 
| 44 | 
            +
                'throw',
         | 
| 45 | 
            +
                'to_candid',
         | 
| 46 | 
            +
                'true',
         | 
| 47 | 
            +
                'try',
         | 
| 48 | 
            +
                'type',
         | 
| 49 | 
            +
                'var',
         | 
| 50 | 
            +
                'while',
         | 
| 51 | 
            +
                'with',
         | 
| 52 | 
            +
            ];
         | 
| 53 | 
            +
            exports.typeKeywords = [
         | 
| 54 | 
            +
                'Any',
         | 
| 55 | 
            +
                'None',
         | 
| 56 | 
            +
                'Null',
         | 
| 57 | 
            +
                'Bool',
         | 
| 58 | 
            +
                'Int',
         | 
| 59 | 
            +
                'Int8',
         | 
| 60 | 
            +
                'Int16',
         | 
| 61 | 
            +
                'Int32',
         | 
| 62 | 
            +
                'Int64',
         | 
| 63 | 
            +
                'Nat',
         | 
| 64 | 
            +
                'Nat8',
         | 
| 65 | 
            +
                'Nat16',
         | 
| 66 | 
            +
                'Nat32',
         | 
| 67 | 
            +
                'Nat64',
         | 
| 68 | 
            +
                'Float',
         | 
| 69 | 
            +
                'Char',
         | 
| 70 | 
            +
                'Text',
         | 
| 71 | 
            +
                'Blob',
         | 
| 72 | 
            +
                'Error',
         | 
| 73 | 
            +
                'Principal',
         | 
| 74 | 
            +
            ];
         | 
| 75 | 
            +
            //# sourceMappingURL=keywords.js.map
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            {"version":3,"file":"keywords.js","sourceRoot":"","sources":["../src/keywords.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG;IACpB,OAAO;IACP,KAAK;IACL,OAAO;IACP,QAAQ;IACR,OAAO;IACP,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,UAAU;IACV,OAAO;IACP,YAAY;IACZ,IAAI;IACJ,MAAM;IACN,OAAO;IACP,UAAU;IACV,KAAK;IACL,aAAa;IACb,MAAM;IACN,IAAI;IACJ,QAAQ;IACR,IAAI;IACJ,QAAQ;IACR,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,KAAK;IACL,MAAM;IACN,QAAQ;IACR,IAAI;IACJ,SAAS;IACT,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,WAAW;IACX,MAAM;IACN,KAAK;IACL,MAAM;IACN,KAAK;IACL,OAAO;IACP,MAAM;CACT,CAAC;AAEW,QAAA,YAAY,GAAG;IACxB,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;IACL,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,KAAK;IACL,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,WAAW;CACd,CAAC"}
         | 
    
        package/package.json
    CHANGED