├── FEATURES.md ├── fixtures ├── bash.d.ts ├── example │ ├── util.ts │ └── example.ts ├── tsconfig.json ├── experimental-module-system │ ├── example.sh │ ├── greeter.sh │ ├── module.sh │ └── test.js └── bash-features │ ├── scoped-fns.sh │ └── object.sh ├── repl ├── untyped.d.ts ├── repl.ts ├── transpile.ts ├── index.html ├── index.css ├── monaco-right.ts ├── monaco.ts └── index.ts ├── docs ├── 158.js.LICENSE.txt ├── css.worker.js.LICENSE.txt ├── html.worker.js.LICENSE.txt ├── json.worker.js.LICENSE.txt ├── editor.worker.js.LICENSE.txt ├── 9242107df7da7c6ad3cadf3133abcd37.ttf ├── 3018.js.LICENSE.txt ├── index.html ├── 2911.js.LICENSE.txt ├── 1233.js ├── 6774.js ├── 1471.js ├── ts.worker.js.LICENSE.txt ├── 2798.js ├── 8946.js ├── 1233.js.map ├── 4902.js ├── 2060.js ├── 6774.js.map ├── 5062.js ├── 5849.js ├── 4129.js ├── 8084.js ├── 1448.js ├── 911.js ├── 6489.js ├── 9537.js ├── 854.js ├── 249.js ├── 3919.js ├── 2140.js ├── 8670.js ├── 1471.js.map ├── 7043.js ├── 6082.js ├── 6241.js ├── 7287.js ├── 7562.js ├── 4368.js ├── 8946.js.map ├── 3585.js ├── 1259.js ├── 7637.js ├── 1147.js ├── 2798.js.map ├── 2954.js ├── 5593.js ├── 8715.js ├── 1065.js ├── 4386.js ├── 2911.js ├── 2075.js ├── 8719.js ├── 2571.js ├── 2892.js ├── 9398.js ├── 6717.js ├── 1960.js ├── 4902.js.map ├── 2060.js.map ├── 848.js ├── 4129.js.map ├── 5062.js.map ├── 9907.js └── 5849.js.map ├── .vscode ├── settings.json └── launch.json ├── src ├── util │ ├── flatmap-simple.ts │ ├── array.test.ts │ ├── test-util.ts │ └── array.ts ├── __snapshots__ │ ├── visitors.test.ts.snap │ └── transpile.test.ts.snap ├── index.ts ├── ast │ └── bash-ast-gen.js ├── example.ts ├── transpile.ts ├── transpile.test.ts └── scope.ts ├── .idea ├── misc.xml ├── vcs.xml ├── typescript-compiler.xml ├── jsLibraryMappings.xml ├── vagrant.xml ├── codeStyles │ └── codeStyleConfig.xml ├── prettier.xml ├── modules.xml ├── inspectionProfiles │ └── Project_Default.xml └── bashscript.iml ├── LICENSE ├── patches └── pretty-format+26.4.0.patch ├── .gitignore ├── package.json ├── webpack.config.js └── tsconfig.json /FEATURES.md: -------------------------------------------------------------------------------- 1 | async/await 2 | 3 | https://stackoverflow.com/a/20018504/595157 -------------------------------------------------------------------------------- /fixtures/bash.d.ts: -------------------------------------------------------------------------------- 1 | declare function echo(...text: Array): void 2 | -------------------------------------------------------------------------------- /fixtures/example/util.ts: -------------------------------------------------------------------------------- 1 | export function write(text: string) { 2 | echo('yey', text) 3 | } 4 | -------------------------------------------------------------------------------- /repl/untyped.d.ts: -------------------------------------------------------------------------------- 1 | declare module '!raw-loader*' { 2 | const str : string 3 | export = str 4 | } 5 | -------------------------------------------------------------------------------- /docs/158.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | Copyright (c) 2014 Taylor Hakes 3 | Copyright (c) 2014 Forbes Lindesay 4 | */ 5 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "node_modules/typescript/lib", 3 | "editor.formatOnSave": true 4 | } 5 | -------------------------------------------------------------------------------- /docs/css.worker.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | Copyright (c) 2014 Taylor Hakes 3 | Copyright (c) 2014 Forbes Lindesay 4 | */ 5 | -------------------------------------------------------------------------------- /docs/html.worker.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | Copyright (c) 2014 Taylor Hakes 3 | Copyright (c) 2014 Forbes Lindesay 4 | */ 5 | -------------------------------------------------------------------------------- /docs/json.worker.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | Copyright (c) 2014 Taylor Hakes 3 | Copyright (c) 2014 Forbes Lindesay 4 | */ 5 | -------------------------------------------------------------------------------- /docs/editor.worker.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | Copyright (c) 2014 Taylor Hakes 3 | Copyright (c) 2014 Forbes Lindesay 4 | */ 5 | -------------------------------------------------------------------------------- /docs/9242107df7da7c6ad3cadf3133abcd37.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niieani/bashscript/HEAD/docs/9242107df7da7c6ad3cadf3133abcd37.ttf -------------------------------------------------------------------------------- /fixtures/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noLib": true, 4 | "noEmit": true, 5 | "strict": true 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/util/flatmap-simple.ts: -------------------------------------------------------------------------------- 1 | export const flatmapSimple = (nestedArray: Array>): Array => 2 | ([] as Array).concat(...nestedArray) 3 | -------------------------------------------------------------------------------- /docs/3018.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | * The buffer module from node.js, for the browser. 3 | * 4 | * @author Feross Aboukhadijeh 5 | * @license MIT 6 | */ 7 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /repl/repl.ts: -------------------------------------------------------------------------------- 1 | // @ts-ignore 2 | import { echo } from './printer' 3 | 4 | /* such amazeballz */ 5 | function greet(name: string) { 6 | echo('Hello') 7 | } 8 | 9 | // oh yeah. 10 | greet('World') 11 | -------------------------------------------------------------------------------- /src/__snapshots__/visitors.test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`visitors variableStatementVisitor 1`] = ` 4 | "declare a= # Unsupported type: NumericLiteral 5 | 6 | 7 | " 8 | `; 9 | -------------------------------------------------------------------------------- /.idea/typescript-compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/jsLibraryMappings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vagrant.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | Webpack App
-------------------------------------------------------------------------------- /repl/transpile.ts: -------------------------------------------------------------------------------- 1 | import './index.css' 2 | import {transpileCode} from '../src/transpile' 3 | 4 | export const transpileText = (text: string) => { 5 | try { 6 | return transpileCode(text) 7 | } catch { 8 | return undefined 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.idea/prettier.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /docs/2911.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /*!--------------------------------------------------------------------------------------------- 2 | * Copyright (C) David Owens II, owensd.io. All rights reserved. 3 | *--------------------------------------------------------------------------------------------*/ 4 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/util/array.test.ts: -------------------------------------------------------------------------------- 1 | import {combineAlternate} from './array' 2 | 3 | describe('array utils', () => { 4 | test('combineAlternate', () => { 5 | expect(combineAlternate(['a', 'b', 'c'], [1, 2, 3])).toMatchObject([ 6 | 'a', 7 | 1, 8 | 'b', 9 | 2, 10 | 'c', 11 | 3, 12 | ]) 13 | }) 14 | }) 15 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import {Project} from 'ts-morph' 2 | import * as path from 'path' 3 | 4 | export const getFile = (file: string) => { 5 | const tsAST = new Project() 6 | const sourceDir = path.resolve(__dirname, '..', 'fixtures') 7 | tsAST.addDirectoryAtPath(`${sourceDir}/example`, {recursive: true}) 8 | return tsAST.getSourceFile(file) 9 | } 10 | -------------------------------------------------------------------------------- /fixtures/experimental-module-system/example.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SCRIPT_DIR=${BASH_SOURCE[0]%/*} 4 | # shellcheck source=module.sh 5 | source "${SCRIPT_DIR}/module.sh" 6 | 7 | # import {greet} from './module-test' 8 | # greet() ==> 9 | module greeter greet tterranigma 10 | module greeter greet niieani 11 | # greet('niieani') ==> 12 | # module ./greet util abc 13 | -------------------------------------------------------------------------------- /fixtures/experimental-module-system/greeter.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # this variable is local to this module: 4 | __module__invocationCount=0 5 | 6 | # function is "exported" as a part of this module 7 | __module__.greet() { 8 | __module__invocationCount=$((__module__invocationCount+1)) 9 | echo Greetings "$@" "(invocation ${__module__invocationCount})" 10 | } 11 | -------------------------------------------------------------------------------- /src/ast/bash-ast-gen.js: -------------------------------------------------------------------------------- 1 | // import sh from 'mvdan-sh' 2 | const sh = require('mvdan-sh') 3 | 4 | const {syntax} = sh 5 | const parser = syntax.NewParser() 6 | const result = parser.Parse(` 7 | concat 'hi' 'ho' "\${variable}" "\$(sub 1 2 3)" 8 | `) 9 | 10 | syntax.DebugPrint(result) 11 | console.log(JSON.stringify(result)) 12 | 13 | const makeVariableDeclaration = () => ({}) 14 | -------------------------------------------------------------------------------- /src/example.ts: -------------------------------------------------------------------------------- 1 | import path from 'path' 2 | import {readFileSync} from 'fs' 3 | import {transpileCode} from './transpile' 4 | 5 | export function transpileFile( 6 | filePath: string = path.resolve('fixtures/example/example.ts'), 7 | ) { 8 | const code = readFileSync(filePath).toString() 9 | const fileName = path.basename(filePath) 10 | return transpileCode(code, fileName) 11 | } 12 | -------------------------------------------------------------------------------- /src/util/test-util.ts: -------------------------------------------------------------------------------- 1 | import {Project} from 'ts-morph' 2 | 3 | export const makeTestFile = (fileContents: string) => { 4 | const project = new Project({ 5 | useInMemoryFileSystem: true, 6 | addFilesFromTsConfig: false, 7 | compilerOptions: { 8 | strict: true, 9 | noLib: true, 10 | }, 11 | }) 12 | return project.createSourceFile('main.ts', fileContents) 13 | } 14 | -------------------------------------------------------------------------------- /repl/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= htmlWebpackPlugin.options.title %> 5 | 6 | 7 | 8 | 9 |
10 |
11 | 12 |
13 | 14 | -------------------------------------------------------------------------------- /docs/1233.js: -------------------------------------------------------------------------------- 1 | (self.webpackJsonpbashscript=self.webpackJsonpbashscript||[]).push([[1233],{1233:(e,t,s)=>{"use strict";s.r(t),s.d(t,{initRight:()=>i});var a=s(50158);const n=document.getElementById("right");let l;const i=e=>l?(e&&l.getModel().setValue(e),l):(l=a.editor.create(n,{value:e||"",language:"shell",minimap:{enabled:!1},formatOnType:!0,scrollBeyondLastLine:!1,readOnly:!0,theme:"vs-dark"}),window.addEventListener("resize",()=>{l.layout()}),l)}}]); 2 | //# sourceMappingURL=1233.js.map -------------------------------------------------------------------------------- /docs/6774.js: -------------------------------------------------------------------------------- 1 | (self.webpackJsonpbashscript=self.webpackJsonpbashscript||[]).push([[6774],{36774:(e,t,n)=>{"use strict";n.r(t),n.d(t,{initLeft:()=>l});var s=n(50158);const a=document.getElementById("left");let r;const l=(e,t)=>{if(r)return e&&r.getModel().setValue(e),r;r=s.editor.create(a,{value:e||"",language:"typescript",minimap:{enabled:!1},formatOnType:!0,scrollBeyondLastLine:!1,readOnly:!1,theme:"vs-dark"}),window.addEventListener("resize",()=>{r.layout()});const n=r.getModel();return n.onDidChangeContent(()=>{t(n.getValue())}),r}}}]); 2 | //# sourceMappingURL=6774.js.map -------------------------------------------------------------------------------- /repl/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | min-height: 100%; 3 | display: flex; 4 | flex-direction: column; 5 | margin: 0; 6 | } 7 | 8 | #app { 9 | position: relative; 10 | height: 100%; 11 | flex: 1; 12 | } 13 | 14 | #left { 15 | left: 0; 16 | right: 50%; 17 | position: absolute; 18 | top: 0; 19 | bottom: 0; 20 | } 21 | 22 | #right { 23 | right: 0; 24 | left: 50%; 25 | font-size: 12px; 26 | background: #f7f7f7; 27 | border-left: 1px solid #ddd; 28 | overflow: auto; 29 | position: absolute; 30 | top: 0; 31 | bottom: 0; 32 | } -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | -------------------------------------------------------------------------------- /.idea/bashscript.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /fixtures/example/example.ts: -------------------------------------------------------------------------------- 1 | import {write} from './util' 2 | 3 | write('hello') 4 | 5 | // this won't work yet: 6 | const x = 123 7 | 8 | // I'm a comment 9 | /* I'm a multiline comment 10 | ...indeed... */ 11 | function lol(one: string, two: number) { 12 | // lol 13 | echo('x') 14 | // after 15 | echo('hmm') 16 | } 17 | 18 | function nestedFunctions() { 19 | echo('hi') 20 | let x = 1 21 | function nestedOne(a: number) { 22 | echo('hello', x) 23 | } 24 | return nestedOne 25 | } 26 | 27 | const arrowFn = () => { 28 | echo('hmm') 29 | return () => { 30 | echo('lool') 31 | } 32 | } 33 | 34 | const theNestedOne = nestedFunctions() 35 | theNestedOne(123) 36 | -------------------------------------------------------------------------------- /src/__snapshots__/transpile.test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`transpile a larger program 1`] = ` 4 | "function nestedFunctions.nestedOne { 5 | echo 'hello' 6 | } 7 | 8 | @module \\"./util\\" write 'hello' 9 | declare x= # Unsupported type: NumericLiteral 10 | 11 | 12 | # // I'm a comment 13 | 14 | # /* I'm a multiline comment 15 | 16 | # ...indeed... */ 17 | 18 | function lol { 19 | declare one=\${1} 20 | declare two=\${2} 21 | # lol 22 | 23 | echo 'x' 24 | # after 25 | 26 | echo 'hmm' 27 | } 28 | function nestedFunctions { 29 | echo 'hi' 30 | # function declaration extracted, see: nestedFunctions.nestedOne 31 | 32 | } 33 | " 34 | `; 35 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Launch Program", 11 | "program": "${workspaceFolder}/index", 12 | "runtimeArgs": [ 13 | "--inspect" 14 | ] 15 | }, 16 | { 17 | "type": "node", 18 | "request": "launch", 19 | "name": "Debug Jest", 20 | "runtimeExecutable": "yarn", 21 | "runtimeArgs": [ 22 | "run", 23 | "jest-debug" 24 | ], 25 | "port": 9229 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /docs/1471.js: -------------------------------------------------------------------------------- 1 | (self.webpackJsonpbashscript=self.webpackJsonpbashscript||[]).push([[1471],{31471:(e,t,s)=>{"use strict";s.r(t),s.d(t,{conf:()=>n,language:()=>o});var n={comments:{lineComment:"#"}},o={defaultToken:"keyword",ignoreCase:!0,tokenPostfix:".azcli",str:/[^#\s]/,tokenizer:{root:[{include:"@comment"},[/\s-+@str*\s*/,{cases:{"@eos":{token:"key.identifier",next:"@popall"},"@default":{token:"key.identifier",next:"@type"}}}],[/^-+@str*\s*/,{cases:{"@eos":{token:"key.identifier",next:"@popall"},"@default":{token:"key.identifier",next:"@type"}}}]],type:[{include:"@comment"},[/-+@str*\s*/,{cases:{"@eos":{token:"key.identifier",next:"@popall"},"@default":"key.identifier"}}],[/@str+\s*/,{cases:{"@eos":{token:"string",next:"@popall"},"@default":"string"}}]],comment:[[/#.*$/,{cases:{"@eos":{token:"comment",next:"@popall"}}}]]}}}}]); 2 | //# sourceMappingURL=1471.js.map -------------------------------------------------------------------------------- /src/transpile.ts: -------------------------------------------------------------------------------- 1 | import * as ts from 'typescript' 2 | import {translateTsAstToBashAst} from './visitors' 3 | import {write} from './ast/bash-ast' 4 | import {Scope} from './scope' 5 | 6 | export function transpile(sourceFile: ts.SourceFile) { 7 | const {nodes: [bashAst] = [], errors, warnings} = translateTsAstToBashAst({ 8 | tsNodes: [sourceFile], 9 | scope: new Scope({type: 'FILE', name: sourceFile.fileName}), 10 | }) 11 | const output = write(bashAst) 12 | console.log(errors) 13 | console.log(warnings) 14 | return output 15 | } 16 | 17 | export function transpileCode(code: string, fileName = 'default.ts') { 18 | const sourceFile: ts.SourceFile = ts.createSourceFile( 19 | fileName, 20 | code, 21 | ts.ScriptTarget.ESNext, 22 | true, 23 | ts.ScriptKind.TS, 24 | ) 25 | return transpile(sourceFile) 26 | } 27 | -------------------------------------------------------------------------------- /repl/monaco-right.ts: -------------------------------------------------------------------------------- 1 | // import * as Monaco from 'monaco-editor' 2 | import * as Monaco from 'monaco-editor/esm/vs/editor/editor.api' 3 | 4 | const monacoElement = document.getElementById('right')! 5 | let monaco: Monaco.editor.IStandaloneCodeEditor 6 | 7 | export const initRight = (initialValue: string | undefined) => { 8 | if (monaco) { 9 | if (initialValue) monaco.getModel()!.setValue(initialValue) 10 | return monaco 11 | } 12 | 13 | monaco = Monaco.editor.create(monacoElement, { 14 | value: initialValue || '', 15 | language: 'shell', 16 | minimap: {enabled: false}, 17 | formatOnType: true, 18 | // lineNumbers: "off", 19 | // roundedSelection: false, 20 | scrollBeyondLastLine: false, 21 | readOnly: true, 22 | theme: 'vs-dark', 23 | }) 24 | 25 | window.addEventListener('resize', () => { 26 | monaco.layout() 27 | }) 28 | 29 | return monaco 30 | } 31 | -------------------------------------------------------------------------------- /docs/ts.worker.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | Copyright (c) 2014 Taylor Hakes 3 | Copyright (c) 2014 Forbes Lindesay 4 | */ 5 | 6 | /*! ***************************************************************************** 7 | Copyright (c) Microsoft Corporation. All rights reserved. 8 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 9 | this file except in compliance with the License. You may obtain a copy of the 10 | License at http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 14 | WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 15 | MERCHANTABLITY OR NON-INFRINGEMENT. 16 | 17 | See the Apache Version 2.0 License for specific language governing permissions 18 | and limitations under the License. 19 | ***************************************************************************** */ 20 | -------------------------------------------------------------------------------- /src/transpile.test.ts: -------------------------------------------------------------------------------- 1 | import {transpileCode} from './transpile' 2 | 3 | describe('transpile', () => { 4 | test('a larger program', () => { 5 | // language=TypeScript 6 | const code = ` 7 | import {write} from './util' 8 | 9 | write('hello') 10 | 11 | const x = 123; 12 | 13 | // I'm a comment 14 | /* I'm a multiline comment 15 | ...indeed... */ 16 | function lol(one: string, two: number) { 17 | // lol 18 | echo('x') 19 | // after 20 | echo('hmm') 21 | } 22 | 23 | function nestedFunctions() { 24 | echo('hi') 25 | function nestedOne() { 26 | echo('hello') 27 | } 28 | } 29 | ` 30 | 31 | expect(transpileCode(code)).toMatchInlineSnapshot(` 32 | "@fromModule ./util write hello 33 | declare -i x=123 34 | function lol { 35 | echo x 36 | echo hmm 37 | } 38 | function nestedFunctions { 39 | echo hi 40 | declare -a __declaration=(function nestedFunctions.nestedOne) 41 | } 42 | function nestedFunctions.nestedOne { 43 | echo hello 44 | }" 45 | `) 46 | }) 47 | }) 48 | -------------------------------------------------------------------------------- /docs/2798.js: -------------------------------------------------------------------------------- 1 | (self.webpackJsonpbashscript=self.webpackJsonpbashscript||[]).push([[2798],{52798:(e,s,n)=>{"use strict";n.r(s),n.d(s,{conf:()=>o,language:()=>t});var o={comments:{lineComment:"#"},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}]},t={defaultToken:"",tokenPostfix:".ini",escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,tokenizer:{root:[[/^\[[^\]]*\]/,"metatag"],[/(^\w+)(\s*)(\=)/,["key","","delimiter"]],{include:"@whitespace"},[/\d+/,"number"],[/"([^"\\]|\\.)*$/,"string.invalid"],[/'([^'\\]|\\.)*$/,"string.invalid"],[/"/,"string",'@string."'],[/'/,"string","@string.'"]],whitespace:[[/[ \t\r\n]+/,""],[/^\s*[#;].*$/,"comment"]],string:[[/[^\\"']+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/["']/,{cases:{"$#==$S2":{token:"string",next:"@pop"},"@default":"string"}}]]}}}}]); 2 | //# sourceMappingURL=2798.js.map -------------------------------------------------------------------------------- /repl/monaco.ts: -------------------------------------------------------------------------------- 1 | // import * as Monaco from 'monaco-editor' 2 | import * as Monaco from 'monaco-editor/esm/vs/editor/editor.api' 3 | 4 | const monacoElement = document.getElementById('left')! 5 | let monaco: Monaco.editor.IStandaloneCodeEditor 6 | 7 | export const initLeft = ( 8 | initialValue: string | undefined, 9 | updateLeft: (untranspiled: string) => void, 10 | ) => { 11 | if (monaco) { 12 | if (initialValue) monaco.getModel()!.setValue(initialValue) 13 | return monaco 14 | } 15 | 16 | monaco = Monaco.editor.create(monacoElement, { 17 | value: initialValue || '', 18 | language: 'typescript', 19 | minimap: {enabled: false}, 20 | formatOnType: true, 21 | // lineNumbers: "off", 22 | // roundedSelection: false, 23 | scrollBeyondLastLine: false, 24 | readOnly: false, 25 | theme: 'vs-dark', 26 | }) 27 | 28 | window.addEventListener('resize', () => { 29 | monaco.layout() 30 | }) 31 | 32 | const monacoModel = monaco.getModel()! 33 | 34 | monacoModel.onDidChangeContent(() => { 35 | updateLeft(monacoModel.getValue()) 36 | }) 37 | 38 | return monaco 39 | } 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Bazyli Brzóska 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /patches/pretty-format+26.4.0.patch: -------------------------------------------------------------------------------- 1 | diff --git a/node_modules/pretty-format/build/plugins/DOMElement.js b/node_modules/pretty-format/build/plugins/DOMElement.js 2 | index bc9746a..5918c34 100644 3 | --- a/node_modules/pretty-format/build/plugins/DOMElement.js 4 | +++ b/node_modules/pretty-format/build/plugins/DOMElement.js 5 | @@ -24,12 +24,12 @@ const testNode = val => { 6 | 7 | const constructorName = val.constructor.name; 8 | const {nodeType, tagName} = val; 9 | - const isCustomElement = 10 | - (typeof tagName === 'string' && tagName.includes('-')) || 11 | - ((_val$hasAttribute = val.hasAttribute) === null || 12 | - _val$hasAttribute === void 0 13 | - ? void 0 14 | - : _val$hasAttribute.call(val, 'is')); 15 | + const isCustomElement = false; 16 | + // (typeof tagName === 'string' && tagName.includes('-')) || 17 | + // ((_val$hasAttribute = val.hasAttribute) === null || 18 | + // _val$hasAttribute === void 0 19 | + // ? void 0 20 | + // : _val$hasAttribute.call(val, 'is')); 21 | return ( 22 | (nodeType === ELEMENT_NODE && 23 | (ELEMENT_REGEXP.test(constructorName) || isCustomElement)) || 24 | -------------------------------------------------------------------------------- /repl/index.ts: -------------------------------------------------------------------------------- 1 | import './index.css' 2 | import sourceValue from '!raw-loader!./repl' 3 | 4 | declare var window: Window & {_sourceValue?: string} 5 | 6 | const init = async () => { 7 | const sourceChanged = 8 | window._sourceValue == null || window._sourceValue !== sourceValue 9 | window._sourceValue = sourceValue 10 | 11 | const [{initLeft}, {initRight}, {transpileText}] = await Promise.all([ 12 | import('./monaco'), 13 | import('./monaco-right'), 14 | import('./transpile'), 15 | ]) 16 | 17 | const originValue = sourceChanged ? sourceValue : undefined 18 | const transpiledValue = sourceChanged ? transpileText(sourceValue) : undefined 19 | const rightEditor = initRight(transpiledValue) 20 | 21 | const updateRight = (code: string) => { 22 | const transpiled = transpileText(code) 23 | if (transpiled !== undefined) rightEditor.setValue(transpiled) 24 | } 25 | 26 | const leftEditor = initLeft(originValue, updateRight) 27 | if (module.hot && !transpiledValue) { 28 | updateRight(leftEditor.getModel()!.getValue()) 29 | } 30 | } 31 | 32 | init() 33 | 34 | if (module.hot) { 35 | module.hot.accept() 36 | } 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | /src/_deprecated 61 | /dist 62 | /.cache 63 | /.idea/workspace.xml 64 | -------------------------------------------------------------------------------- /fixtures/bash-features/scoped-fns.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # const concat = (a) => { 4 | # const c = `${a}-super` 5 | # return (b) => { 6 | # return `${c}${b}` 7 | # } 8 | # } 9 | # const withOne = concat('one') 10 | # const result = withOne('two') 11 | 12 | function concat { 13 | # params: 14 | local a="${1}" 15 | # function body: 16 | local c="${a}-super" 17 | # preapplied function: 18 | # lambda declaration is: 19 | # [type, name, scoped_declarations_to_eval] 20 | local -a declaration=( 21 | function 22 | __lambda_concat_1 23 | "$(declare -p c)" 24 | # repeat ^ for each variable that is accessed in the body 25 | ) 26 | declare -p declaration 27 | } 28 | 29 | # all functions are top level 30 | function __lambda_concat_1 { 31 | # scoped variables (repeat for each): 32 | eval "${1}"; shift; 33 | # actual function body: 34 | local b="${1}" 35 | echo "${c}${b}" 36 | } 37 | 38 | function __callVar { 39 | # TODO: add check if var is a declaration 40 | # evaluate contents of the variable 41 | eval "${!1}"; shift; 42 | if [[ "${declaration[0]}" == "function" ]] 43 | then 44 | "${declaration[1]}" "${declaration[2]}" "$@" 45 | fi 46 | } 47 | 48 | declare withOne="$(concat 'one')" 49 | declare result="$(__callVar withOne 'two')" 50 | 51 | echo "${result}" -------------------------------------------------------------------------------- /fixtures/experimental-module-system/module.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | declare -a __moduleCache=() 4 | 5 | module() { 6 | local path="${1}" 7 | local export="${2}" 8 | shift; shift; 9 | local filename 10 | if [[ "${path:0:2}" == "./" ]] 11 | then 12 | filename="$( cd "${BASH_SOURCE[1]%/*}" && pwd )/${path#\./}" 13 | else 14 | # for absolute path we assume it's relative to "SCRIPT_DIR" 15 | filename="${SCRIPT_DIR}/${path}" 16 | fi 17 | load "${filename}.sh" "${export}" "$@" 18 | } 19 | 20 | load() { 21 | local filename="${1}" 22 | local export="${2}" 23 | shift; shift; 24 | local moduleName="_moduleId_${filename//[^a-zA-Z0-9]/_}" 25 | local moduleId="${!moduleName}" 26 | if [[ -z "${moduleId}" ]] 27 | then 28 | # module not yet loaded 29 | local moduleId="${#__moduleCache[@]}" 30 | local moduleContents 31 | moduleContents=$(<"${filename}") 32 | local moduleMemberPrefix="__module__${moduleId}" 33 | local prefixedModule="${moduleContents//__module__/$moduleMemberPrefix}" 34 | # declares reference to ID in global scope: 35 | eval ${moduleName}=${moduleId} 36 | __moduleCache+=($moduleName) 37 | # execute the module: 38 | eval "$prefixedModule" 39 | fi 40 | 41 | # module already loaded, execute 42 | __module__${moduleId}.${export} "$@" 43 | } 44 | -------------------------------------------------------------------------------- /src/util/array.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Combines two arrays by alternating their indices 3 | * combineAlternate([a, b, c], [1, 2, 3]) === [a, 1, b, 2, c, 3] 4 | */ 5 | export const combineAlternate = ( 6 | arr1: Array, 7 | arr2: Array, 8 | noLengthCheck = false, 9 | flipOrder = false, 10 | ): Array => 11 | noLengthCheck || arr1.length >= arr2.length 12 | ? arr1.reduce( 13 | (combined, arr1value, index) => 14 | index < arr2.length 15 | ? [ 16 | ...combined, 17 | ...(flipOrder 18 | ? [arr2[index], arr1value] 19 | : [arr1value, arr2[index]]), 20 | ] 21 | : [...combined, arr1value], 22 | [] as Array, 23 | ) 24 | : combineAlternate(arr2, arr1, true, true) 25 | 26 | export const findLastIndex = ( 27 | predicate: (value: T, index: number, obj: T[]) => boolean, 28 | ) => (arr: ReadonlyArray) => { 29 | const result = arr.slice().reverse().findIndex(predicate) 30 | return result >= 0 ? arr.length - 1 - result : result 31 | } 32 | 33 | export const last = (array: Array): T | undefined => 34 | array.slice().reverse()[0] 35 | 36 | export const ensureArray = (maybeArray: T | Array): Array => 37 | Array.isArray(maybeArray) ? maybeArray : [maybeArray] 38 | -------------------------------------------------------------------------------- /docs/8946.js: -------------------------------------------------------------------------------- 1 | (self.webpackJsonpbashscript=self.webpackJsonpbashscript||[]).push([[8946],{68946:(t,s,r)=>{"use strict";r.r(s),r.d(s,{conf:()=>e,language:()=>o});var e={brackets:[],autoClosingPairs:[],surroundingPairs:[]},o={keywords:[],typeKeywords:[],tokenPostfix:".csp",operators:[],symbols:/[=> {\n if (monaco) {\n if (initialValue) monaco.getModel()!.setValue(initialValue)\n return monaco\n }\n\n monaco = Monaco.editor.create(monacoElement, {\n value: initialValue || '',\n language: 'shell',\n minimap: {enabled: false},\n formatOnType: true,\n // lineNumbers: \"off\",\n // roundedSelection: false,\n scrollBeyondLastLine: false,\n readOnly: true,\n theme: 'vs-dark',\n })\n\n window.addEventListener('resize', () => {\n monaco.layout()\n })\n\n return monaco\n}\n"],"sourceRoot":""} -------------------------------------------------------------------------------- /docs/4902.js: -------------------------------------------------------------------------------- 1 | (self.webpackJsonpbashscript=self.webpackJsonpbashscript||[]).push([[4902],{4902:(e,t,a)=>{"use strict";a.r(t),a.d(t,{conf:()=>n,language:()=>i});var n={comments:{blockComment:["\x3c!--","--\x3e"]},brackets:[["<",">"]],autoClosingPairs:[{open:"<",close:">"},{open:"'",close:"'"},{open:'"',close:'"'}],surroundingPairs:[{open:"<",close:">"},{open:"'",close:"'"},{open:'"',close:'"'}]},i={defaultToken:"",tokenPostfix:".xml",ignoreCase:!0,qualifiedName:/(?:[\w\.\-]+:)?[\w\.\-]+/,tokenizer:{root:[[/[^<&]+/,""],{include:"@whitespace"},[/(<)(@qualifiedName)/,[{token:"delimiter"},{token:"tag",next:"@tag"}]],[/(<\/)(@qualifiedName)(\s*)(>)/,[{token:"delimiter"},{token:"tag"},"",{token:"delimiter"}]],[/(<\?)(@qualifiedName)/,[{token:"delimiter"},{token:"metatag",next:"@tag"}]],[/(<\!)(@qualifiedName)/,[{token:"delimiter"},{token:"metatag",next:"@tag"}]],[/<\!\[CDATA\[/,{token:"delimiter.cdata",next:"@cdata"}],[/&\w+;/,"string.escape"]],cdata:[[/[^\]]+/,""],[/\]\]>/,{token:"delimiter.cdata",next:"@pop"}],[/\]/,""]],tag:[[/[ \t\r\n]+/,""],[/(@qualifiedName)(\s*=\s*)("[^"]*"|'[^']*')/,["attribute.name","","attribute.value"]],[/(@qualifiedName)(\s*=\s*)("[^">?\/]*|'[^'>?\/]*)(?=[\?\/]\>)/,["attribute.name","","attribute.value"]],[/(@qualifiedName)(\s*=\s*)("[^">]*|'[^'>]*)/,["attribute.name","","attribute.value"]],[/@qualifiedName/,"attribute.name"],[/\?>/,{token:"delimiter",next:"@pop"}],[/(\/)(>)/,[{token:"tag"},{token:"delimiter",next:"@pop"}]],[/>/,{token:"delimiter",next:"@pop"}]],whitespace:[[/[ \t\r\n]+/,""],[//,{token:"comment",next:"@pop"}],[//,"comment","@pop"],[//,"comment","@pop"],[/[^-]+/,"comment.content"],[/./,"comment.content"]],otherTag:[[/\/?>/,"delimiter","@pop"],[/"([^"]*)"/,"attribute.value"],[/'([^']*)'/,"attribute.value"],[/[\w\-]+/,"attribute.name"],[/=/,"delimiter"],[/[ \t\r\n]+/]],script:[[/type/,"attribute.name","@scriptAfterType"],[/"([^"]*)"/,"attribute.value"],[/'([^']*)'/,"attribute.value"],[/[\w\-]+/,"attribute.name"],[/=/,"delimiter"],[/>/,{token:"delimiter",next:"@scriptEmbedded",nextEmbedded:"text/javascript"}],[/[ \t\r\n]+/],[/(<\/)(script\s*)(>)/,["delimiter","tag",{token:"delimiter",next:"@pop"}]]],scriptAfterType:[[/=/,"delimiter","@scriptAfterTypeEquals"],[/>/,{token:"delimiter",next:"@scriptEmbedded",nextEmbedded:"text/javascript"}],[/[ \t\r\n]+/],[/<\/script\s*>/,{token:"@rematch",next:"@pop"}]],scriptAfterTypeEquals:[[/"([^"]*)"/,{token:"attribute.value",switchTo:"@scriptWithCustomType.$1"}],[/'([^']*)'/,{token:"attribute.value",switchTo:"@scriptWithCustomType.$1"}],[/>/,{token:"delimiter",next:"@scriptEmbedded",nextEmbedded:"text/javascript"}],[/[ \t\r\n]+/],[/<\/script\s*>/,{token:"@rematch",next:"@pop"}]],scriptWithCustomType:[[/>/,{token:"delimiter",next:"@scriptEmbedded.$S2",nextEmbedded:"$S2"}],[/"([^"]*)"/,"attribute.value"],[/'([^']*)'/,"attribute.value"],[/[\w\-]+/,"attribute.name"],[/=/,"delimiter"],[/[ \t\r\n]+/],[/<\/script\s*>/,{token:"@rematch",next:"@pop"}]],scriptEmbedded:[[/<\/script/,{token:"@rematch",next:"@pop",nextEmbedded:"@pop"}],[/[^<]+/,""]],style:[[/type/,"attribute.name","@styleAfterType"],[/"([^"]*)"/,"attribute.value"],[/'([^']*)'/,"attribute.value"],[/[\w\-]+/,"attribute.name"],[/=/,"delimiter"],[/>/,{token:"delimiter",next:"@styleEmbedded",nextEmbedded:"text/css"}],[/[ \t\r\n]+/],[/(<\/)(style\s*)(>)/,["delimiter","tag",{token:"delimiter",next:"@pop"}]]],styleAfterType:[[/=/,"delimiter","@styleAfterTypeEquals"],[/>/,{token:"delimiter",next:"@styleEmbedded",nextEmbedded:"text/css"}],[/[ \t\r\n]+/],[/<\/style\s*>/,{token:"@rematch",next:"@pop"}]],styleAfterTypeEquals:[[/"([^"]*)"/,{token:"attribute.value",switchTo:"@styleWithCustomType.$1"}],[/'([^']*)'/,{token:"attribute.value",switchTo:"@styleWithCustomType.$1"}],[/>/,{token:"delimiter",next:"@styleEmbedded",nextEmbedded:"text/css"}],[/[ \t\r\n]+/],[/<\/style\s*>/,{token:"@rematch",next:"@pop"}]],styleWithCustomType:[[/>/,{token:"delimiter",next:"@styleEmbedded.$S2",nextEmbedded:"$S2"}],[/"([^"]*)"/,"attribute.value"],[/'([^']*)'/,"attribute.value"],[/[\w\-]+/,"attribute.name"],[/=/,"delimiter"],[/[ \t\r\n]+/],[/<\/style\s*>/,{token:"@rematch",next:"@pop"}]],styleEmbedded:[[/<\/style/,{token:"@rematch",next:"@pop",nextEmbedded:"@pop"}],[/[^<]+/,""]]}}}}]); 2 | //# sourceMappingURL=2571.js.map -------------------------------------------------------------------------------- /docs/2892.js: -------------------------------------------------------------------------------- 1 | (self.webpackJsonpbashscript=self.webpackJsonpbashscript||[]).push([[2892],{22892:(e,t,n)=>{"use strict";n.r(t),n.d(t,{conf:()=>o,language:()=>a});var o={comments:{lineComment:"//"},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:'"',close:'"',notIn:["string","comment"]},{open:"'",close:"'",notIn:["string","comment"]},{open:"{",close:"}",notIn:["string","comment"]},{open:"[",close:"]",notIn:["string","comment"]},{open:"(",close:")",notIn:["string","comment"]}],folding:{offSide:!0}},a={defaultToken:"",tokenPostfix:".pug",ignoreCase:!0,brackets:[{token:"delimiter.curly",open:"{",close:"}"},{token:"delimiter.array",open:"[",close:"]"},{token:"delimiter.parenthesis",open:"(",close:")"}],keywords:["append","block","case","default","doctype","each","else","extends","for","if","in","include","mixin","typeof","unless","var","when"],tags:["a","abbr","acronym","address","area","article","aside","audio","b","base","basefont","bdi","bdo","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","command","datalist","dd","del","details","dfn","div","dl","dt","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","keygen","kbd","label","li","link","map","mark","menu","meta","meter","nav","noframes","noscript","object","ol","optgroup","option","output","p","param","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strike","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","tracks","tt","u","ul","video","wbr"],symbols:/[\+\-\*\%\&\|\!\=\/\.\,\:]+/,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,tokenizer:{root:[[/^(\s*)([a-zA-Z_-][\w-]*)/,{cases:{"$2@tags":{cases:{"@eos":["","tag"],"@default":["",{token:"tag",next:"@tag.$1"}]}},"$2@keywords":["",{token:"keyword.$2"}],"@default":["",""]}}],[/^(\s*)(#[a-zA-Z_-][\w-]*)/,{cases:{"@eos":["","tag.id"],"@default":["",{token:"tag.id",next:"@tag.$1"}]}}],[/^(\s*)(\.[a-zA-Z_-][\w-]*)/,{cases:{"@eos":["","tag.class"],"@default":["",{token:"tag.class",next:"@tag.$1"}]}}],[/^(\s*)(\|.*)$/,""],{include:"@whitespace"},[/[a-zA-Z_$][\w$]*/,{cases:{"@keywords":{token:"keyword.$0"},"@default":""}}],[/[{}()\[\]]/,"@brackets"],[/@symbols/,"delimiter"],[/\d+\.\d+([eE][\-+]?\d+)?/,"number.float"],[/\d+/,"number"],[/"/,"string",'@string."'],[/'/,"string","@string.'"]],tag:[[/(\.)(\s*$)/,[{token:"delimiter",next:"@blockText.$S2."},""]],[/\s+/,{token:"",next:"@simpleText"}],[/#[a-zA-Z_-][\w-]*/,{cases:{"@eos":{token:"tag.id",next:"@pop"},"@default":"tag.id"}}],[/\.[a-zA-Z_-][\w-]*/,{cases:{"@eos":{token:"tag.class",next:"@pop"},"@default":"tag.class"}}],[/\(/,{token:"delimiter.parenthesis",next:"@attributeList"}]],simpleText:[[/[^#]+$/,{token:"",next:"@popall"}],[/[^#]+/,{token:""}],[/(#{)([^}]*)(})/,{cases:{"@eos":["interpolation.delimiter","interpolation",{token:"interpolation.delimiter",next:"@popall"}],"@default":["interpolation.delimiter","interpolation","interpolation.delimiter"]}}],[/#$/,{token:"",next:"@popall"}],[/#/,""]],attributeList:[[/\s+/,""],[/(\w+)(\s*=\s*)("|')/,["attribute.name","delimiter",{token:"attribute.value",next:"@value.$3"}]],[/\w+/,"attribute.name"],[/,/,{cases:{"@eos":{token:"attribute.delimiter",next:"@popall"},"@default":"attribute.delimiter"}}],[/\)$/,{token:"delimiter.parenthesis",next:"@popall"}],[/\)/,{token:"delimiter.parenthesis",next:"@pop"}]],whitespace:[[/^(\s*)(\/\/.*)$/,{token:"comment",next:"@blockText.$1.comment"}],[/[ \t\r\n]+/,""],[//,{token:"comment",next:"@pop"}],[/'],\r\n },\r\n brackets: [\r\n ['<', '>']\r\n ],\r\n autoClosingPairs: [\r\n { open: '<', close: '>' },\r\n { open: '\\'', close: '\\'' },\r\n { open: '\"', close: '\"' },\r\n ],\r\n surroundingPairs: [\r\n { open: '<', close: '>' },\r\n { open: '\\'', close: '\\'' },\r\n { open: '\"', close: '\"' },\r\n ]\r\n};\r\nexport var language = {\r\n defaultToken: '',\r\n tokenPostfix: '.xml',\r\n ignoreCase: true,\r\n // Useful regular expressions\r\n qualifiedName: /(?:[\\w\\.\\-]+:)?[\\w\\.\\-]+/,\r\n tokenizer: {\r\n root: [\r\n [/[^<&]+/, ''],\r\n { include: '@whitespace' },\r\n // Standard opening tag\r\n [/(<)(@qualifiedName)/, [\r\n { token: 'delimiter' },\r\n { token: 'tag', next: '@tag' }\r\n ]],\r\n // Standard closing tag\r\n [/(<\\/)(@qualifiedName)(\\s*)(>)/, [\r\n { token: 'delimiter' },\r\n { token: 'tag' },\r\n '',\r\n { token: 'delimiter' }\r\n ]],\r\n // Meta tags - instruction\r\n [/(<\\?)(@qualifiedName)/, [\r\n { token: 'delimiter' },\r\n { token: 'metatag', next: '@tag' }\r\n ]],\r\n // Meta tags - declaration\r\n [/(<\\!)(@qualifiedName)/, [\r\n { token: 'delimiter' },\r\n { token: 'metatag', next: '@tag' }\r\n ]],\r\n // CDATA\r\n [/<\\!\\[CDATA\\[/, { token: 'delimiter.cdata', next: '@cdata' }],\r\n [/&\\w+;/, 'string.escape'],\r\n ],\r\n cdata: [\r\n [/[^\\]]+/, ''],\r\n [/\\]\\]>/, { token: 'delimiter.cdata', next: '@pop' }],\r\n [/\\]/, '']\r\n ],\r\n tag: [\r\n [/[ \\t\\r\\n]+/, ''],\r\n [/(@qualifiedName)(\\s*=\\s*)(\"[^\"]*\"|'[^']*')/, ['attribute.name', '', 'attribute.value']],\r\n [/(@qualifiedName)(\\s*=\\s*)(\"[^\">?\\/]*|'[^'>?\\/]*)(?=[\\?\\/]\\>)/, ['attribute.name', '', 'attribute.value']],\r\n [/(@qualifiedName)(\\s*=\\s*)(\"[^\">]*|'[^'>]*)/, ['attribute.name', '', 'attribute.value']],\r\n [/@qualifiedName/, 'attribute.name'],\r\n [/\\?>/, { token: 'delimiter', next: '@pop' }],\r\n [/(\\/)(>)/, [\r\n { token: 'tag' },\r\n { token: 'delimiter', next: '@pop' }\r\n ]],\r\n [/>/, { token: 'delimiter', next: '@pop' }],\r\n ],\r\n whitespace: [\r\n [/[ \\t\\r\\n]+/, ''],\r\n [//, { token: 'comment', next: '@pop' }],\r\n [/