├── LICENSE ├── README.md ├── dependencies └── polyfills.js ├── docs ├── Makefile ├── _build │ ├── doctrees │ │ ├── auto-golf.doctree │ │ ├── basic-examples.doctree │ │ ├── basics.doctree │ │ ├── environment.pickle │ │ ├── errors.doctree │ │ ├── first-program.doctree │ │ ├── getters.doctree │ │ ├── getting-started.doctree │ │ ├── index.doctree │ │ ├── installation.doctree │ │ ├── new-features.doctree │ │ ├── understanding.doctree │ │ ├── unicode.doctree │ │ └── variables.doctree │ └── html │ │ ├── .buildinfo │ │ ├── _sources │ │ ├── auto-golf.txt │ │ ├── basic-examples.txt │ │ ├── basics.txt │ │ ├── errors.txt │ │ ├── first-program.txt │ │ ├── getters.txt │ │ ├── getting-started.txt │ │ ├── index.txt │ │ ├── installation.txt │ │ ├── new-features.txt │ │ ├── understanding.txt │ │ ├── unicode.txt │ │ └── variables.txt │ │ ├── _static │ │ ├── ajax-loader.gif │ │ ├── basic.css │ │ ├── comment-bright.png │ │ ├── comment-close.png │ │ ├── comment.png │ │ ├── css │ │ │ ├── badge_only.css │ │ │ └── theme.css │ │ ├── doctools.js │ │ ├── down-pressed.png │ │ ├── down.png │ │ ├── file.png │ │ ├── fonts │ │ │ ├── Inconsolata-Bold.ttf │ │ │ ├── Inconsolata-Regular.ttf │ │ │ ├── Lato-Bold.ttf │ │ │ ├── Lato-Regular.ttf │ │ │ ├── RobotoSlab-Bold.ttf │ │ │ ├── RobotoSlab-Regular.ttf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.svg │ │ │ ├── fontawesome-webfont.ttf │ │ │ └── fontawesome-webfont.woff │ │ ├── jquery-1.11.1.js │ │ ├── jquery.js │ │ ├── js │ │ │ ├── modernizr.min.js │ │ │ └── theme.js │ │ ├── minus.png │ │ ├── plus.png │ │ ├── pygments.css │ │ ├── searchtools.js │ │ ├── underscore-1.3.1.js │ │ ├── underscore.js │ │ ├── up-pressed.png │ │ ├── up.png │ │ └── websupport.js │ │ ├── auto-golf.html │ │ ├── basic-examples.html │ │ ├── errors.html │ │ ├── genindex.html │ │ ├── getting-started.html │ │ ├── index.html │ │ ├── installation.html │ │ ├── new-features.html │ │ ├── objects.inv │ │ ├── search.html │ │ ├── searchindex.js │ │ └── variables.html ├── auto-golf.rst ├── basic-examples.rst ├── conf.py ├── errors.rst ├── getting-started.rst ├── index.rst ├── installation.rst ├── make.bat ├── new-features.rst └── variables.rst ├── logo ├── TeaScript.png └── TeaScriptWide.png └── src ├── env ├── generator.es6.js ├── generator.js ├── macros.js └── props.json ├── sh ├── sh.js ├── teascript └── teascript_run ├── v1 └── teascript.js ├── v2 └── teascript.js └── v3 ├── teascript.es6 └── teascript.js /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | TeaScript 4 | 5 |

6 | 7 | # Try TeaScript 8 |

9 | All Documentation
10 | Online Interpreter 11 |

12 | 13 | # TeaScript 3 is now out! 14 | See the release notes for more information 15 | 16 | # Documentation 17 | Read The Docs documentation is now available at 18 | -------------------------------------------------------------------------------- /dependencies/polyfills.js: -------------------------------------------------------------------------------- 1 | /* (The MIT License) 2 | * 3 | * Copyright (c) 2012 Brandon Benvie 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 6 | * associated documentation files (the 'Software'), to deal in the Software without restriction, 7 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 8 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included with all copies or 12 | * substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 15 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | void function(G,A,l,b,d,t,h,F,i,c,m,E,e){var z=h.getOwnPropertyNames,r=typeof z===l&&!(b in z);var a=i.bind?i.bind.bind(i.call):function(a){return function(b){return function(){return a.apply(b,arguments)}}}(i.call);var J=a(i[d]),K=a({}[d]),H=a(0..toString),f=a(i.call),L=a(i.apply),q=a({}.hasOwnProperty),D=a([].push),s=a([].splice);var x=function(a){return typeof a!==l?'':'name'in a?a.name:J(a).match(/^\n?function\s?(\w*)?_?\(/)[1]};var g=r?h.create:function(e,a){var c=function(){};c[b]=h(e);var d=new c;if(a)for(var f in a)u(d,f,a[k]);return d};var u=r?h.defineProperty:function(a,b,c){return a[b]=c.value,a};var v=function(c,a,b){return typeof a===l&&(b=a,a=x(b).replace(/_$/,'')),u(c,a,{configurable:!0,writable:!0,value:b})};var I=r?function(a){return function(b){return a(b)||b instanceof t}}(t.isArray):function(a){return a instanceof t||K(a)==='[object Array]'};var C='WeakMap'in c;var j=C?function(){function j(b){var a=new d;this.get=function(b){return e(a,b)},this.set=function(b,c){f(a,b,c)},b&&(this.wrap=function(c,d){if(g(a,c))throw new TypeError('Object is already a '+b);f(a,c,d)},this.unwrap=function(d){var c=e(a,d);if(!c)throw new TypeError(b+' is not generic');return c})}var d=c.WeakMap,e=a(d[b].get),f=a(d[b].set),g=a(d[b].has);return j}():function(){function getOwnPropertyNames(b){var a=z(b);return q(b,c)&&s(a,o(a,c),1),a}function j(d){var h=f(),a=f(),b={};b[a]={writable:!0,value:e};var c=function(d){var a=k(d);if(q(a,h))return a[h](b);var c=g(null,b);return u(a,h,{value:new F('s','l',l)(b,c)}),c};this.get=function(b){return c(b)[a]},this.set=function(b,d){c(b)[a]=d},d&&(this.wrap=function(e,f){var b=c(e);if(b[a])throw new TypeError('Object is already a '+d);b[a]=f},this.unwrap=function(e){var b=c(e)[a];if(!b)throw new TypeError(d+' is not generic');return b})}var l='return function(k){if(k===s)return l}',m=Math.random,i=g(null),n=a(''.slice),o=a([].indexOf);var f=function(){var a=n(H(m(),36),2);return a in i?f():i[a]=a};var c=f();if(r){var k=function(a){return!q(a,c)&&u(a,c,{value:g(null)}),a[c]};v(h,getOwnPropertyNames)}else{var p=function(a){function toString(){return a}return toString[d]=toString}(h[b][d]+'');var k=function(a){function toString(){return b.call(this)}if(q(a,d)&&c in a[d])return a[d][c];if(!(d in a))throw new Error('Can\'t store values for '+a);var b=a[d];return a[d]=toString,toString[d]=p,toString[c]={}}}return j}();var n=function(){function toString(){return a[0]+x(this)+a[1]}var a=(''+h).split('Object');v(toString,toString);var c={__proto__:[]}instanceof t?function(a){a.__proto__=toString}:function(a){v(a,toString)};var d=function(a){function toString(){return f}var d=a.shift(),f='[object '+x(d)+']';a.push(toString),c(d);for(var e=0;e/dev/null 2>&1; echo $$?), 1) 12 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 13 | endif 14 | 15 | # Internal variables. 16 | PAPEROPT_a4 = -D latex_paper_size=a4 17 | PAPEROPT_letter = -D latex_paper_size=letter 18 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 19 | # the i18n builder cannot share the environment and doctrees with the others 20 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 21 | 22 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext 23 | 24 | help: 25 | @echo "Please use \`make ' where is one of" 26 | @echo " html to make standalone HTML files" 27 | @echo " dirhtml to make HTML files named index.html in directories" 28 | @echo " singlehtml to make a single large HTML file" 29 | @echo " pickle to make pickle files" 30 | @echo " json to make JSON files" 31 | @echo " htmlhelp to make HTML files and a HTML help project" 32 | @echo " qthelp to make HTML files and a qthelp project" 33 | @echo " applehelp to make an Apple Help Book" 34 | @echo " devhelp to make HTML files and a Devhelp project" 35 | @echo " epub to make an epub" 36 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 37 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 38 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 39 | @echo " text to make text files" 40 | @echo " man to make manual pages" 41 | @echo " texinfo to make Texinfo files" 42 | @echo " info to make Texinfo files and run them through makeinfo" 43 | @echo " gettext to make PO message catalogs" 44 | @echo " changes to make an overview of all changed/added/deprecated items" 45 | @echo " xml to make Docutils-native XML files" 46 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 47 | @echo " linkcheck to check all external links for integrity" 48 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 49 | @echo " coverage to run coverage check of the documentation (if enabled)" 50 | 51 | clean: 52 | rm -rf $(BUILDDIR)/* 53 | 54 | html: 55 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 56 | @echo 57 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 58 | 59 | dirhtml: 60 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 61 | @echo 62 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 63 | 64 | singlehtml: 65 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 66 | @echo 67 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 68 | 69 | pickle: 70 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 71 | @echo 72 | @echo "Build finished; now you can process the pickle files." 73 | 74 | json: 75 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 76 | @echo 77 | @echo "Build finished; now you can process the JSON files." 78 | 79 | htmlhelp: 80 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 81 | @echo 82 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 83 | ".hhp project file in $(BUILDDIR)/htmlhelp." 84 | 85 | qthelp: 86 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 87 | @echo 88 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 89 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 90 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/TeaScript.qhcp" 91 | @echo "To view the help file:" 92 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/TeaScript.qhc" 93 | 94 | applehelp: 95 | $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp 96 | @echo 97 | @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." 98 | @echo "N.B. You won't be able to view it unless you put it in" \ 99 | "~/Library/Documentation/Help or install it in your application" \ 100 | "bundle." 101 | 102 | devhelp: 103 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 104 | @echo 105 | @echo "Build finished." 106 | @echo "To view the help file:" 107 | @echo "# mkdir -p $$HOME/.local/share/devhelp/TeaScript" 108 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/TeaScript" 109 | @echo "# devhelp" 110 | 111 | epub: 112 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 113 | @echo 114 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 115 | 116 | latex: 117 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 118 | @echo 119 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 120 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 121 | "(use \`make latexpdf' here to do that automatically)." 122 | 123 | latexpdf: 124 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 125 | @echo "Running LaTeX files through pdflatex..." 126 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 127 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 128 | 129 | latexpdfja: 130 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 131 | @echo "Running LaTeX files through platex and dvipdfmx..." 132 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 133 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 134 | 135 | text: 136 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 137 | @echo 138 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 139 | 140 | man: 141 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 142 | @echo 143 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 144 | 145 | texinfo: 146 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 147 | @echo 148 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 149 | @echo "Run \`make' in that directory to run these through makeinfo" \ 150 | "(use \`make info' here to do that automatically)." 151 | 152 | info: 153 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 154 | @echo "Running Texinfo files through makeinfo..." 155 | make -C $(BUILDDIR)/texinfo info 156 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 157 | 158 | gettext: 159 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 160 | @echo 161 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 162 | 163 | changes: 164 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 165 | @echo 166 | @echo "The overview file is in $(BUILDDIR)/changes." 167 | 168 | linkcheck: 169 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 170 | @echo 171 | @echo "Link check complete; look for any errors in the above output " \ 172 | "or in $(BUILDDIR)/linkcheck/output.txt." 173 | 174 | doctest: 175 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 176 | @echo "Testing of doctests in the sources finished, look at the " \ 177 | "results in $(BUILDDIR)/doctest/output.txt." 178 | 179 | coverage: 180 | $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage 181 | @echo "Testing of coverage in the sources finished, look at the " \ 182 | "results in $(BUILDDIR)/coverage/python.txt." 183 | 184 | xml: 185 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 186 | @echo 187 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 188 | 189 | pseudoxml: 190 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 191 | @echo 192 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 193 | -------------------------------------------------------------------------------- /docs/_build/doctrees/auto-golf.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/doctrees/auto-golf.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/basic-examples.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/doctrees/basic-examples.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/basics.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/doctrees/basics.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/environment.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/doctrees/environment.pickle -------------------------------------------------------------------------------- /docs/_build/doctrees/errors.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/doctrees/errors.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/first-program.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/doctrees/first-program.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/getters.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/doctrees/getters.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/getting-started.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/doctrees/getting-started.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/index.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/doctrees/index.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/installation.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/doctrees/installation.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/new-features.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/doctrees/new-features.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/understanding.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/doctrees/understanding.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/unicode.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/doctrees/unicode.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/variables.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/doctrees/variables.doctree -------------------------------------------------------------------------------- /docs/_build/html/.buildinfo: -------------------------------------------------------------------------------- 1 | # Sphinx build info version 1 2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. 3 | config: c3c7f461642091ddff62d2f7276135e9 4 | tags: 645f666f9bcd5a90fca523b33c5a78b7 5 | -------------------------------------------------------------------------------- /docs/_build/html/_sources/auto-golf.txt: -------------------------------------------------------------------------------- 1 | Auto-Golfing 2 | ************ 3 | 4 | ``Auto-Golf`` is a feature which performs automatic golfing for you. It provides a few features. 5 | 6 | .. hint:: 7 | The ``Un-Auto-Golf`` will do the opposite and will attempt to make code more readable. 8 | 9 | Unicode Shortcuts 10 | ================= 11 | 12 | Unicode shortcuts are a way to get code as short as possible without doing any work! What are they? Unicode shortcuts are 1-byte long unicode characters which expand to longer TeaScript code at compile time. Confusing, here's an example: 13 | 14 | .. code-block:: js 15 | 16 | £lc) // Original Code 17 | xl(#lc) // Code at compile-time 18 | 19 | What if I want to use a unicode character in my code. Unicode characters in literals (i.e. Strings, RegExps, Snippets) are not converted. If for some reason you do want a unicode property name, it can be used by using a ``\\`` before the character 20 | 21 | .. code-block:: js 22 | 23 | \£lc // Original Code 24 | £lc // Code at compile-time 25 | 26 | So how do you use them? You simpily click the ``Auto-Golf`` button. 27 | 28 | Ommiting characters 29 | =================== 30 | 31 | Removing Brackets 32 | ----------------- 33 | 34 | If you have a function, and then a literal, you can ommit the ``(`` before it. You can also ommit ending ``)`` and other brackets 35 | 36 | .. code-block:: js 37 | 38 | MF(32) // Before 39 | MF32 // After 40 | 41 | MF(3,x[32]) // Before 42 | MF3,x[32 // After 43 | 44 | Removing Literal Endings 45 | ------------------------ 46 | 47 | Endings of literal characters can be ommited, this includes Strings, RegExps, and Snippets. 48 | 49 | .. code-block:: js 50 | 51 | "Foo" // Before 52 | "Foo // After 53 | 54 | `Foo` // Before 55 | `Foo // After 56 | 57 | /Fo{2}/ // Before 58 | /Fo{2} // After -------------------------------------------------------------------------------- /docs/_build/html/_sources/basic-examples.txt: -------------------------------------------------------------------------------- 1 | Basic Examples 2 | ************** 3 | 4 | String Tasks 5 | ============= 6 | 7 | Hello, World 8 | ------------- 9 | .. sidebar:: Explanation 10 | 11 | ``"`` begins a string literal. 12 | 13 | Outputs ``Hello, World`` 14 | 15 | .. code-block:: js 16 | 17 | "Hello, World! 18 | 19 | cat 20 | ---- 21 | .. sidebar:: Explanation 22 | 23 | ``x`` contains the input 24 | 25 | Outputs the input 26 | 27 | .. code-block:: js 28 | 29 | x 30 | 31 | Number Tasks 32 | ============= 33 | 34 | Fibonacci 35 | --------- 36 | 37 | .. sidebar:: Explanation 38 | 39 | ``F`` is a Fibonacci function. ``x`` is the input 40 | 41 | Given ``n`` this calculated the ``n``\ th Fibonacci number 42 | 43 | .. code-block:: js 44 | 45 | F(x 46 | 47 | Primality Test 48 | -------------- 49 | 50 | .. sidebar:: Explanation 51 | 52 | ``mP`` is a primality check function 53 | 54 | Calculates whether a given number is prime 55 | 56 | .. code-block:: js 57 | 58 | mP(x 59 | 60 | Array Tasks 61 | =========== 62 | 63 | Cycling Arrays 64 | --------------- 65 | 66 | .. sidebar:: Explanation 67 | 68 | ``C`` cycles an array, ``x`` is the input 69 | 70 | Cycle an array 1 spots 71 | 72 | .. code-block:: js 73 | 74 | xC1 75 | 76 | Average of Numbers 77 | ------------------- 78 | 79 | .. sidebar:: Explanation 80 | 81 | ``x`` is the input, ``x`` is a sum getter. ``n`` is the length. Compiled, this is ``x.x/x.n`` or ``x.sum/x.length`` 82 | 83 | Calculates the average of numbers 84 | 85 | .. code-block:: js 86 | 87 | xx/xn -------------------------------------------------------------------------------- /docs/_build/html/_sources/basics.txt: -------------------------------------------------------------------------------- 1 | # test -------------------------------------------------------------------------------- /docs/_build/html/_sources/errors.txt: -------------------------------------------------------------------------------- 1 | Error Handling 2 | ************** 3 | 4 | Approaching Literal Maximum 5 | ============================ 6 | 7 | This is the only error that can be thrown during compilation at the moment. This is caused when a literal (i.e. String, RegEx) is unbalanced. 8 | 9 | .. code-block:: js 10 | 11 | "unclosed string 12 | /unclosed regex 13 | $unclosed snippet 14 | 15 | Dependency not found: babel 16 | =========================== 17 | 18 | ``babeljs``, was not able to be loaded, check your network connection and ensure babel is connected. If you believe this shouldn't be occuring don't hesitate to `report it `_ on Github. 19 | 20 | Existing sub___: Slot used 21 | ============================= 22 | 23 | During enviorment generation, a few errors can occur, this occurs when TeaScript is trying to assign a variable but it has already been assigned. You can override this by force setting ``TEASCRIPT_ENV`` to false, each time enviroment generation takes place 24 | 25 | .. note:: 26 | This is a technical error, you are either using an unsupported browser/enviorment or there is a bug in TeaScript. If you believe it's a bug, don't hesitate to `report it `_ on Github 27 | 28 | Invalid location, ___, error ___ 29 | ================================= 30 | 31 | If this ever occurs, TeaScript has encountered an issue with the ``props.json`` file, possible fixes are reinstalling the ``props.json``. If this continues, don't hesitate to `report it `_ on Github. 32 | 33 | Unexpected Type: ___ at ___ 34 | =========================== 35 | 36 | This is another error with the ``props.json``, check to make sure the json is valid. Try reinstalling the ``props.json``, and if that doesn't work, don't hesitate to `report it `_ on Github. 37 | 38 | Duplicate Getter: ___ 39 | ====================== 40 | 41 | An attempt was made to assign a getter to an already assigned key. To diagnose this, try looking for duplicate getters in the ``props.json`` and change/remove them. 42 | 43 | *Any* other error 44 | ================= 45 | 46 | All other errors are either JS Runtime or syntax errors, which can be solved by entering `Debugging Mode` 47 | 48 | Syntax Errors 49 | -------------- 50 | 51 | A syntax error starts with ``SyntaxError:``, and is an error with the syntax itself, the error should display from where the error originated and by looking at the previous compilation steps, you may be able to identify where the error occured. 52 | 53 | This error could of originated in any of the following compilation stages: 54 | 55 | * String Balancing 56 | * Unicode Shortcuts 57 | * Property Expansion 58 | * Paranthesis Balancing 59 | * babel compilation 60 | 61 | If you believe the error originated during babel compilation, report the error at `babel's Github `_. 62 | 63 | Runtime Errors 64 | -------------- 65 | 66 | Any other error is a JS runtime error which is usually caused by referencing a variable that doesn't exist. Runtime errors are errors with the code itself rather than the syntax. Try to break down your code and try to identify where the error is originating. If you believe this error shouldn't be happening, don't hesitate to `report it `_ on Github. -------------------------------------------------------------------------------- /docs/_build/html/_sources/first-program.txt: -------------------------------------------------------------------------------- 1 | Writing Your First Program 2 | ************************** 3 | 4 | To get started with TeaScript, you're going to want to set up your enviorment. Instructions are `install`_ 5 | -------------------------------------------------------------------------------- /docs/_build/html/_sources/getters.txt: -------------------------------------------------------------------------------- 1 | # test -------------------------------------------------------------------------------- /docs/_build/html/_sources/getting-started.txt: -------------------------------------------------------------------------------- 1 | Getting Started 2 | *************** 3 | 4 | Getting started with TeaScript is *very* easy especially if you have prior JavaScript knowledge. 5 | 6 | This was the main goal of TeaScript was a JavaScript golfing language that *was* JavaScript but with shorter property names. This slowly evolved but TeaScript is backwards compatible so every JavaScript program is a valid TeaScript program 7 | 8 | Literals 9 | ======== 10 | 11 | Literals are very simple in TeaScript as they are the same as JavaScript literals 12 | 13 | Strings 14 | ------- 15 | 16 | They are three types of strings 17 | 18 | .. code-block:: js 19 | 20 | "Double Quoted String Literal" 21 | 'Single Quoted String Literal' 22 | `String templates` 23 | 24 | String templates have a few extra features such as: 25 | 26 | .. code-block:: js 27 | 28 | `String templates support inline 29 | newlines and code such as ${2+1}` 30 | 31 | Numbers 32 | ------- 33 | 34 | Numbers are also, just *numbers*: 35 | 36 | .. code-block:: js 37 | 38 | 12345 // Decimal 39 | 12.34 // Decimal 40 | 1e23) // Scientific Notation 41 | 0xFA) // Hexadecimal 42 | 0b10) // Binary 43 | 0o18) // Octal 44 | 45 | RegExp 46 | ------- 47 | 48 | TeaScript has support for RegExp literals and they're just the same as JavaScript 49 | 50 | .. code-block:: js 51 | 52 | /[A-Za-z]/gi 53 | 54 | By TeaScript 3.1, I hope to have `XRegExp`, implemented which should allow your RegExp literals to look like: 55 | 56 | .. code-block:: js 57 | 58 | /\u{L}+/u 59 | 60 | Functions 61 | --------- 62 | 63 | Functions are the same as JavaScript too. 64 | 65 | .. code-block:: js 66 | 67 | (a,b,c)=>a+b+c // Arguments[a,b,c] adds them together 68 | a=>a // Single argument a, returns a 69 | 70 | This is quite lengthy so I've added the ``#`` operator which automatically expands to ``(l,i,a,b)=>`` at compile time 71 | 72 | .. code-block:: none 73 | 74 | #l+i+a // Arguments[l,i,a,b] adds first 3 75 | 76 | Input 77 | ===== 78 | 79 | Input Options 80 | ------------- 81 | 82 | The user can decide how (s)he wants the input. TeaScript supports all of the following input types: 83 | 84 | - String (default) 85 | - Number 86 | - Array 87 | 88 | Getting the Input 89 | ----------------- 90 | 91 | The input is stored in various variables: 92 | 93 | ======== ============= 94 | Input # Variable Name 95 | ======== ============= 96 | 1 ``x`` 97 | 2 ``y`` 98 | 3 ``z`` 99 | ======== ============= 100 | 101 | Need More inputs? An array of all the inputs is stored in the ``_`` variable. 102 | 103 | .... 104 | 105 | If the input is an array, the 1st input will be split upon ``,`` and each item will become a seperate input. For the code: 106 | 107 | .. code-block:: none 108 | 109 | Input 1,Input 2,Input 3 110 | 111 | The values are: 112 | 113 | =========== ============= 114 | Input Value Variable Name 115 | =========== ============= 116 | ``Input 1`` ``x`` 117 | ``Input 2`` ``y`` 118 | ``Input 3`` ``z`` 119 | =========== ============= -------------------------------------------------------------------------------- /docs/_build/html/_sources/index.txt: -------------------------------------------------------------------------------- 1 | Welcome to TeaScript's documentation! 2 | ===================================== 3 | 4 | TeaScript is a powerful JavaScript golfing language created by StackExchange, PPCG, user `Downgoat `_. TeaScript compiles to JavaScript and contains many helpful features for golfing 5 | 6 | Contents: 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | installation 12 | getting-started 13 | new-features 14 | variables 15 | auto-golf 16 | basic-examples 17 | errors -------------------------------------------------------------------------------- /docs/_build/html/_sources/installation.txt: -------------------------------------------------------------------------------- 1 | .. _label: install 2 | 3 | Installation 4 | *************** 5 | 6 | Running TeaScript is pretty simple, they're multiple ways you can do this 7 | 8 | Web Interface 9 | ============ 10 | 11 | TeaScript has a pretty sweet web interface and is the best enviorment for running TeaScript. All extensions are packaged up and usage is pretty straight-forward. 12 | 13 | * `Web Interface `_ 14 | * `Alternate URL `_ 15 | 16 | Command Line 17 | ============ 18 | 19 | If you wish to run TeaScript from the command line, ensure you have **SpiderMonkey 38** or higher installed. They're multiple ways to get started 20 | 21 | Auto-Install Script 22 | ------------------- 23 | 24 | Install ``teascript`` from the `GitHub `_ 25 | 26 | Give ``teascript`` the correct permissions 27 | 28 | .. code-block:: shell 29 | 30 | $ chmod +x teascript 31 | 32 | Run ``teascript``, and it should install the correct files. Enter the code, and then the input, ``,`` seperated. 33 | 34 | .. code-block:: shell 35 | :linenos: 36 | 37 | $ ./teascript 38 | TeaScript not installed. Installing TeaScript... 39 | # ... 40 | Code: # 41 | Input: # e.g.: Input 1,Input 2,Input 3,... 42 | # 43 | 44 | The next time you run TeaScript, it'll detect the `TeaScript/` folder and won't need to reinstall the dependencies. 45 | 46 | Manual Installation 47 | ------------------- 48 | 49 | You can also manually install/run TeaScript if you're having issues with the script 50 | 51 | Install the following files 52 | 53 | - Everything within `/src/v2 `_ 54 | - ``sh.js`` from `/src/sh/sh.js `_ 55 | 56 | Edit ``teascript.js`` and replace ``window`` with ``this``, and ``/*props.json*/`` with ``JSON.parse(read("props.json"))`` 57 | 58 | .. note:: 59 | Different enviorments might use a different function than ``read`` 60 | 61 | :node.js: ``fs.readFile`` 62 | :rhino: ``readFile`` 63 | :spidermonkey: ``read`` -------------------------------------------------------------------------------- /docs/_build/html/_sources/new-features.txt: -------------------------------------------------------------------------------- 1 | New Features 2 | ************ 3 | 4 | As said before, TeaScript is an *extension* of JavaScript meaning it adds features to JavaScript. Here you will learn about some of the features TeaScript 5 | adds to JavaScript 6 | 7 | Modified RegExp 8 | =============== 9 | 10 | RegExp literals have been expanded and are now more powerful than ever with custom character classes and hopefully even more features to come. 11 | 12 | Custom Character Classes 13 | ------------------------ 14 | 15 | TeaScript adds custom character classes (e.g. ``\w``) to a RegExp literal. These are esentially shorthands for character classes, an example 16 | 17 | .. code-block:: js 18 | 19 | /[A-Za-z]/ // Before 20 | /\L/ // After 21 | /[A-Za-z]/ // At compile-time 22 | 23 | .. topic:: New Character Classes 24 | :name: charclasslist 25 | 26 | ======= ============ 27 | Name Value 28 | ======= ============ 29 | ``\\A`` ``[A-Z]`` 30 | ``\\a`` ``[a-z]`` 31 | ``\\L`` ``[A-Za-z]`` 32 | ``\\N`` ``[A-Za-z0-9]`` 33 | ======= ============ 34 | 35 | Operators 36 | ========= 37 | 38 | # Operator 39 | ---------- 40 | 41 | The ``#`` operator is one that is *very* useful. It's a shorthand for function declerations that you can use where ever. ``#`` expands to ``(l,i,a,b)=>`` 42 | 43 | .. code-block:: js 44 | 45 | (a,b,c,d)=>a+b+c+d // Before 46 | #l+i+a+b // After 47 | 48 | @ Operator 49 | ---------- 50 | 51 | The ``@`` operator is similar to the ``#`` operator, but if you ever have two nested lambdas, you can use this. ``@`` expands to ``(q,r,s,t)=>q.`` 52 | 53 | .. code-block:: js 54 | 55 | (a,b,c,d)=>aT2)+b+d // Before 56 | @T2)+r+t // After 57 | 58 | .. _f-operator: 59 | 60 | ƒ Operator 61 | ---------- 62 | 63 | ``ƒ`` expands to ``f=(l,i,a,b)=>``, this can be used to create recursive functions easily without having to manually add a decleration 64 | 65 | .. code-block:: js 66 | 67 | f=(a,b)=>a<1?b:f(a--,b++); // Before 68 | ƒl<1?i:f(l--,i++); // After 69 | 70 | Σ Operator 71 | ---------- 72 | 73 | The ``Σ`` operator can be used to loop through arrays and strings, it expands to ``.l((l,i,a,b)=>``. 74 | 75 | .. code-block:: js 76 | 77 | xΣlc // Maps char codes 78 | xΣi // Generates range 79 | 80 | 81 | 82 | ? Operator 83 | ---------- 84 | 85 | This operator has 2 uses depending on where you use it. 86 | 87 | .. rubric:: Interrupting Property expansion 88 | 89 | If you ever need to use a JavaScript property name and TeaScript thinks it's a TeaScript property, insert a ``?`` after the property 90 | 91 | .. code-block:: js 92 | 93 | x.search(/\A/) // JavaScript 94 | x.search?/\A // TeaScript 95 | 96 | .. rubric:: Closing Parenthesis 97 | 98 | .. code-block:: js 99 | 100 | xl(#lT(2r("foo"[1]))) // Before 101 | xl(#lT(2r("foo"[1? // After -------------------------------------------------------------------------------- /docs/_build/html/_sources/understanding.txt: -------------------------------------------------------------------------------- 1 | Error Handling 2 | ************** 3 | 4 | Approaching Literal Maximum 5 | ============================ 6 | 7 | This is the only error that can be thrown during compilation at the moment. This is caused when a literal (i.e. String, RegEx) is unbalanced. 8 | 9 | .. code-block:: js 10 | 11 | "unclosed string 12 | /unclosed regex 13 | $unclosed snippet 14 | 15 | Dependency not found: babel 16 | =========================== 17 | 18 | ``babeljs``, was not able to be loaded, check your network connection and ensure babel is connected. If you believe this shouldn't be occuring don't hesitate to `report it `_ on Github. 19 | 20 | Existing sub___: Slot used 21 | ============================= 22 | 23 | During enviorment generation, a few errors can occur, this occurs when TeaScript is trying to assign a variable but it has already been assigned. You can override this by force setting ``TEASCRIPT_ENV`` to false, each time enviroment generation takes place 24 | 25 | .. note:: 26 | This is a technical error, you are either using an unsupported browser/enviorment or there is a bug in TeaScript. If you believe it's a bug, don't hesitate to `report it `_ on Github 27 | 28 | Invalid location, ___, error ___ 29 | ================================= 30 | 31 | If this ever occurs, TeaScript has encountered an issue with the ``props.json`` file, possible fixes are reinstalling the ``props.json``. If this continues, don't hesitate to `report it `_ on Github. 32 | 33 | Unexpected Type: ___ at ___ 34 | =========================== 35 | 36 | This is another error with the ``props.json``, check to make sure the json is valid. Try reinstalling the ``props.json``, and if that doesn't work, don't hesitate to `report it `_ on Github. 37 | 38 | Duplicate Getter: ___ 39 | ====================== 40 | 41 | An attempt was made to assign a getter to an already assigned key. To diagnose this, try looking for duplicate getters in the ``props.json`` and change/remove them. 42 | 43 | *Any* other error 44 | ================= 45 | 46 | All other errors are either JS Runtime or syntax errors, which can be solved by entering `Debugging Mode` 47 | 48 | Syntax Errors 49 | -------------- 50 | 51 | A syntax error starts with ``SyntaxError:``, and is an error with the syntax itself, the error should display from where the error originated and by looking at the previous compilation steps, you may be able to identify where the error occured. 52 | 53 | This error could of originated in any of the following compilation stages: 54 | 55 | * String Balancing 56 | * Unicode Shortcuts 57 | * Property Expansion 58 | * Paranthesis Balancing 59 | * babel compilation 60 | 61 | If you believe the error originated during babel compilation, report the error at `babel's Github `_. 62 | 63 | Runtime Errors 64 | -------------- 65 | 66 | Any other error is a JS runtime error which is usually caused by referencing a variable that doesn't exist. Runtime errors are errors with the code itself rather than the syntax. Try to break down your code and try to identify where the error is originating. If you believe this error shouldn't be happening, don't hesitate to `report it `_ on Github. -------------------------------------------------------------------------------- /docs/_build/html/_sources/unicode.txt: -------------------------------------------------------------------------------- 1 | Unicode Shortcuts 2 | ****************** 3 | 4 | Unicode shortcuts are a way to get code as short as possible without doing any work! What are they? Unicode shortcuts are 1-byte long unicode characters which expand to longer TeaScript code at compile time. Confusing, here's an example: 5 | 6 | .. code-block:: js 7 | 8 | £lc) // Original Code 9 | xl(#lc) // Code at compile-time 10 | 11 | What if I want to use a unicode character in my code. Unicode characters in literals (i.e. Strings, RegExps, Snippets) are not converted. If for some reason you do want a unicode property name, it can be used by using a ``\\`` before the character 12 | 13 | .. code-block:: js 14 | 15 | \£lc // Original Code 16 | £lc // Code at compile-time -------------------------------------------------------------------------------- /docs/_build/html/_sources/variables.txt: -------------------------------------------------------------------------------- 1 | Variables 2 | ********* 3 | 4 | TeaScript has many variables which are pre-initalized to various values but you can also use them for custom variables: 5 | 6 | Assignment 7 | ========== 8 | 9 | To assign a variable you can easier use a shorthand or the native JavaScript ways. 10 | 11 | Shorthands 12 | ---------- 13 | 14 | .. rubric:: Using ƒ 15 | 16 | This can be used to assign functions both recursive and not. To learn more about this operator, see :ref:`f-operator`. 17 | 18 | .. code-block:: js 19 | 20 | f=(l,i)=>l<1?i:f(l--,i++) // Before 21 | ƒl<1?i:l--:i++ // After 22 | 23 | f=l=>{for(i=0;i= 0 && !jQuery(node.parentNode).hasClass(className)) { 74 | var span = document.createElement("span"); 75 | span.className = className; 76 | span.appendChild(document.createTextNode(val.substr(pos, text.length))); 77 | node.parentNode.insertBefore(span, node.parentNode.insertBefore( 78 | document.createTextNode(val.substr(pos + text.length)), 79 | node.nextSibling)); 80 | node.nodeValue = val.substr(0, pos); 81 | } 82 | } 83 | else if (!jQuery(node).is("button, select, textarea")) { 84 | jQuery.each(node.childNodes, function() { 85 | highlight(this); 86 | }); 87 | } 88 | } 89 | return this.each(function() { 90 | highlight(this); 91 | }); 92 | }; 93 | 94 | /* 95 | * backward compatibility for jQuery.browser 96 | * This will be supported until firefox bug is fixed. 97 | */ 98 | if (!jQuery.browser) { 99 | jQuery.uaMatch = function(ua) { 100 | ua = ua.toLowerCase(); 101 | 102 | var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || 103 | /(webkit)[ \/]([\w.]+)/.exec(ua) || 104 | /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || 105 | /(msie) ([\w.]+)/.exec(ua) || 106 | ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || 107 | []; 108 | 109 | return { 110 | browser: match[ 1 ] || "", 111 | version: match[ 2 ] || "0" 112 | }; 113 | }; 114 | jQuery.browser = {}; 115 | jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true; 116 | } 117 | 118 | /** 119 | * Small JavaScript module for the documentation. 120 | */ 121 | var Documentation = { 122 | 123 | init : function() { 124 | this.fixFirefoxAnchorBug(); 125 | this.highlightSearchWords(); 126 | this.initIndexTable(); 127 | }, 128 | 129 | /** 130 | * i18n support 131 | */ 132 | TRANSLATIONS : {}, 133 | PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; }, 134 | LOCALE : 'unknown', 135 | 136 | // gettext and ngettext don't access this so that the functions 137 | // can safely bound to a different name (_ = Documentation.gettext) 138 | gettext : function(string) { 139 | var translated = Documentation.TRANSLATIONS[string]; 140 | if (typeof translated == 'undefined') 141 | return string; 142 | return (typeof translated == 'string') ? translated : translated[0]; 143 | }, 144 | 145 | ngettext : function(singular, plural, n) { 146 | var translated = Documentation.TRANSLATIONS[singular]; 147 | if (typeof translated == 'undefined') 148 | return (n == 1) ? singular : plural; 149 | return translated[Documentation.PLURALEXPR(n)]; 150 | }, 151 | 152 | addTranslations : function(catalog) { 153 | for (var key in catalog.messages) 154 | this.TRANSLATIONS[key] = catalog.messages[key]; 155 | this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')'); 156 | this.LOCALE = catalog.locale; 157 | }, 158 | 159 | /** 160 | * add context elements like header anchor links 161 | */ 162 | addContextElements : function() { 163 | $('div[id] > :header:first').each(function() { 164 | $('\u00B6'). 165 | attr('href', '#' + this.id). 166 | attr('title', _('Permalink to this headline')). 167 | appendTo(this); 168 | }); 169 | $('dt[id]').each(function() { 170 | $('\u00B6'). 171 | attr('href', '#' + this.id). 172 | attr('title', _('Permalink to this definition')). 173 | appendTo(this); 174 | }); 175 | }, 176 | 177 | /** 178 | * workaround a firefox stupidity 179 | * see: https://bugzilla.mozilla.org/show_bug.cgi?id=645075 180 | */ 181 | fixFirefoxAnchorBug : function() { 182 | if (document.location.hash) 183 | window.setTimeout(function() { 184 | document.location.href += ''; 185 | }, 10); 186 | }, 187 | 188 | /** 189 | * highlight the search words provided in the url in the text 190 | */ 191 | highlightSearchWords : function() { 192 | var params = $.getQueryParameters(); 193 | var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : []; 194 | if (terms.length) { 195 | var body = $('div.body'); 196 | if (!body.length) { 197 | body = $('body'); 198 | } 199 | window.setTimeout(function() { 200 | $.each(terms, function() { 201 | body.highlightText(this.toLowerCase(), 'highlighted'); 202 | }); 203 | }, 10); 204 | $('') 206 | .appendTo($('#searchbox')); 207 | } 208 | }, 209 | 210 | /** 211 | * init the domain index toggle buttons 212 | */ 213 | initIndexTable : function() { 214 | var togglers = $('img.toggler').click(function() { 215 | var src = $(this).attr('src'); 216 | var idnum = $(this).attr('id').substr(7); 217 | $('tr.cg-' + idnum).toggle(); 218 | if (src.substr(-9) == 'minus.png') 219 | $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); 220 | else 221 | $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); 222 | }).css('display', ''); 223 | if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) { 224 | togglers.click(); 225 | } 226 | }, 227 | 228 | /** 229 | * helper function to hide the search marks again 230 | */ 231 | hideSearchWords : function() { 232 | $('#searchbox .highlight-link').fadeOut(300); 233 | $('span.highlighted').removeClass('highlighted'); 234 | }, 235 | 236 | /** 237 | * make the url absolute 238 | */ 239 | makeURL : function(relativeURL) { 240 | return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL; 241 | }, 242 | 243 | /** 244 | * get the current relative url 245 | */ 246 | getCurrentURL : function() { 247 | var path = document.location.pathname; 248 | var parts = path.split(/\//); 249 | $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { 250 | if (this == '..') 251 | parts.pop(); 252 | }); 253 | var url = parts.join('/'); 254 | return path.substring(url.lastIndexOf('/') + 1, path.length - 1); 255 | } 256 | }; 257 | 258 | // quick alias for translations 259 | _ = Documentation.gettext; 260 | 261 | $(document).ready(function() { 262 | Documentation.init(); 263 | }); 264 | -------------------------------------------------------------------------------- /docs/_build/html/_static/down-pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/html/_static/down-pressed.png -------------------------------------------------------------------------------- /docs/_build/html/_static/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/html/_static/down.png -------------------------------------------------------------------------------- /docs/_build/html/_static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/html/_static/file.png -------------------------------------------------------------------------------- /docs/_build/html/_static/fonts/Inconsolata-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/html/_static/fonts/Inconsolata-Bold.ttf -------------------------------------------------------------------------------- /docs/_build/html/_static/fonts/Inconsolata-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/html/_static/fonts/Inconsolata-Regular.ttf -------------------------------------------------------------------------------- /docs/_build/html/_static/fonts/Lato-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/html/_static/fonts/Lato-Bold.ttf -------------------------------------------------------------------------------- /docs/_build/html/_static/fonts/Lato-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/html/_static/fonts/Lato-Regular.ttf -------------------------------------------------------------------------------- /docs/_build/html/_static/fonts/RobotoSlab-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/html/_static/fonts/RobotoSlab-Bold.ttf -------------------------------------------------------------------------------- /docs/_build/html/_static/fonts/RobotoSlab-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/html/_static/fonts/RobotoSlab-Regular.ttf -------------------------------------------------------------------------------- /docs/_build/html/_static/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/html/_static/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /docs/_build/html/_static/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/html/_static/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /docs/_build/html/_static/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/html/_static/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/_build/html/_static/js/theme.js: -------------------------------------------------------------------------------- 1 | require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o"); 77 | 78 | // Add expand links to all parents of nested ul 79 | $('.wy-menu-vertical ul').not('.simple').siblings('a').each(function () { 80 | var link = $(this); 81 | expand = $(''); 82 | expand.on('click', function (ev) { 83 | self.toggleCurrent(link); 84 | ev.stopPropagation(); 85 | return false; 86 | }); 87 | link.prepend(expand); 88 | }); 89 | }; 90 | 91 | nav.reset = function () { 92 | // Get anchor from URL and open up nested nav 93 | var anchor = encodeURI(window.location.hash); 94 | if (anchor) { 95 | try { 96 | var link = $('.wy-menu-vertical') 97 | .find('[href="' + anchor + '"]'); 98 | $('.wy-menu-vertical li.toctree-l1 li.current') 99 | .removeClass('current'); 100 | link.closest('li.toctree-l2').addClass('current'); 101 | link.closest('li.toctree-l3').addClass('current'); 102 | link.closest('li.toctree-l4').addClass('current'); 103 | } 104 | catch (err) { 105 | console.log("Error expanding nav for anchor", err); 106 | } 107 | } 108 | }; 109 | 110 | nav.onScroll = function () { 111 | this.winScroll = false; 112 | var newWinPosition = this.win.scrollTop(), 113 | winBottom = newWinPosition + this.winHeight, 114 | navPosition = this.navBar.scrollTop(), 115 | newNavPosition = navPosition + (newWinPosition - this.winPosition); 116 | if (newWinPosition < 0 || winBottom > this.docHeight) { 117 | return; 118 | } 119 | this.navBar.scrollTop(newNavPosition); 120 | this.winPosition = newWinPosition; 121 | }; 122 | 123 | nav.onResize = function () { 124 | this.winResize = false; 125 | this.winHeight = this.win.height(); 126 | this.docHeight = $(document).height(); 127 | }; 128 | 129 | nav.hashChange = function () { 130 | this.linkScroll = true; 131 | this.win.one('hashchange', function () { 132 | this.linkScroll = false; 133 | }); 134 | }; 135 | 136 | nav.toggleCurrent = function (elem) { 137 | var parent_li = elem.closest('li'); 138 | parent_li.siblings('li.current').removeClass('current'); 139 | parent_li.siblings().find('li.current').removeClass('current'); 140 | parent_li.find('> ul li.current').removeClass('current'); 141 | parent_li.toggleClass('current'); 142 | } 143 | 144 | return nav; 145 | }; 146 | 147 | module.exports.ThemeNav = ThemeNav(); 148 | 149 | if (typeof(window) != 'undefined') { 150 | window.SphinxRtdTheme = { StickyNav: module.exports.ThemeNav }; 151 | } 152 | 153 | },{"jquery":"jquery"}]},{},["sphinx-rtd-theme"]); 154 | -------------------------------------------------------------------------------- /docs/_build/html/_static/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/html/_static/minus.png -------------------------------------------------------------------------------- /docs/_build/html/_static/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/html/_static/plus.png -------------------------------------------------------------------------------- /docs/_build/html/_static/pygments.css: -------------------------------------------------------------------------------- 1 | .highlight .hll { background-color: #ffffcc } 2 | .highlight { background: #eeffcc; } 3 | .highlight .c { color: #408090; font-style: italic } /* Comment */ 4 | .highlight .err { border: 1px solid #FF0000 } /* Error */ 5 | .highlight .k { color: #007020; font-weight: bold } /* Keyword */ 6 | .highlight .o { color: #666666 } /* Operator */ 7 | .highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */ 8 | .highlight .cp { color: #007020 } /* Comment.Preproc */ 9 | .highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */ 10 | .highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */ 11 | .highlight .gd { color: #A00000 } /* Generic.Deleted */ 12 | .highlight .ge { font-style: italic } /* Generic.Emph */ 13 | .highlight .gr { color: #FF0000 } /* Generic.Error */ 14 | .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ 15 | .highlight .gi { color: #00A000 } /* Generic.Inserted */ 16 | .highlight .go { color: #333333 } /* Generic.Output */ 17 | .highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ 18 | .highlight .gs { font-weight: bold } /* Generic.Strong */ 19 | .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ 20 | .highlight .gt { color: #0044DD } /* Generic.Traceback */ 21 | .highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */ 22 | .highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */ 23 | .highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */ 24 | .highlight .kp { color: #007020 } /* Keyword.Pseudo */ 25 | .highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */ 26 | .highlight .kt { color: #902000 } /* Keyword.Type */ 27 | .highlight .m { color: #208050 } /* Literal.Number */ 28 | .highlight .s { color: #4070a0 } /* Literal.String */ 29 | .highlight .na { color: #4070a0 } /* Name.Attribute */ 30 | .highlight .nb { color: #007020 } /* Name.Builtin */ 31 | .highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */ 32 | .highlight .no { color: #60add5 } /* Name.Constant */ 33 | .highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */ 34 | .highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */ 35 | .highlight .ne { color: #007020 } /* Name.Exception */ 36 | .highlight .nf { color: #06287e } /* Name.Function */ 37 | .highlight .nl { color: #002070; font-weight: bold } /* Name.Label */ 38 | .highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ 39 | .highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */ 40 | .highlight .nv { color: #bb60d5 } /* Name.Variable */ 41 | .highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */ 42 | .highlight .w { color: #bbbbbb } /* Text.Whitespace */ 43 | .highlight .mb { color: #208050 } /* Literal.Number.Bin */ 44 | .highlight .mf { color: #208050 } /* Literal.Number.Float */ 45 | .highlight .mh { color: #208050 } /* Literal.Number.Hex */ 46 | .highlight .mi { color: #208050 } /* Literal.Number.Integer */ 47 | .highlight .mo { color: #208050 } /* Literal.Number.Oct */ 48 | .highlight .sb { color: #4070a0 } /* Literal.String.Backtick */ 49 | .highlight .sc { color: #4070a0 } /* Literal.String.Char */ 50 | .highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */ 51 | .highlight .s2 { color: #4070a0 } /* Literal.String.Double */ 52 | .highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */ 53 | .highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */ 54 | .highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */ 55 | .highlight .sx { color: #c65d09 } /* Literal.String.Other */ 56 | .highlight .sr { color: #235388 } /* Literal.String.Regex */ 57 | .highlight .s1 { color: #4070a0 } /* Literal.String.Single */ 58 | .highlight .ss { color: #517918 } /* Literal.String.Symbol */ 59 | .highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */ 60 | .highlight .vc { color: #bb60d5 } /* Name.Variable.Class */ 61 | .highlight .vg { color: #bb60d5 } /* Name.Variable.Global */ 62 | .highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */ 63 | .highlight .il { color: #208050 } /* Literal.Number.Integer.Long */ -------------------------------------------------------------------------------- /docs/_build/html/_static/underscore.js: -------------------------------------------------------------------------------- 1 | // Underscore.js 1.3.1 2 | // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. 3 | // Underscore is freely distributable under the MIT license. 4 | // Portions of Underscore are inspired or borrowed from Prototype, 5 | // Oliver Steele's Functional, and John Resig's Micro-Templating. 6 | // For all details and documentation: 7 | // http://documentcloud.github.com/underscore 8 | (function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source== 9 | c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c, 10 | h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else r._=b;b.VERSION="1.3.1";var j=b.each= 11 | b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e2;a== 12 | null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect= 13 | function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e= 14 | e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck= 15 | function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;bd?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a, 17 | c,d){d||(d=b.identity);for(var e=0,f=a.length;e>1;d(a[g])=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e=0;d--)b=[a[d].apply(this,b)];return b[0]}}; 24 | b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments, 25 | 1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)}; 26 | b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"}; 27 | b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.mixin=function(a){j(b.functions(a), 28 | function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+ 29 | u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]= 30 | function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain= 31 | true;return this};m.prototype.value=function(){return this._wrapped}}).call(this); 32 | -------------------------------------------------------------------------------- /docs/_build/html/_static/up-pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/html/_static/up-pressed.png -------------------------------------------------------------------------------- /docs/_build/html/_static/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/html/_static/up.png -------------------------------------------------------------------------------- /docs/_build/html/auto-golf.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Auto-Golfing — TeaScript beta documentation 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |
45 | 46 | 47 | 106 | 107 |
108 | 109 | 110 | 114 | 115 | 116 | 117 |
118 |
119 | 120 | 121 | 122 | 123 | 124 | 125 |
126 |
    127 |
  • Docs »
  • 128 | 129 |
  • Auto-Golfing
  • 130 |
  • 131 | 132 | 133 | View page source 134 | 135 | 136 |
  • 137 |
138 |
139 |
140 |
141 |
142 | 143 |
144 |

Auto-Golfing

145 |

Auto-Golf is a feature which performs automatic golfing for you. It provides a few features.

146 |
147 |

Hint

148 |

The Un-Auto-Golf will do the opposite and will attempt to make code more readable.

149 |
150 |
151 |

Unicode Shortcuts

152 |

Unicode shortcuts are a way to get code as short as possible without doing any work! What are they? Unicode shortcuts are 1-byte long unicode characters which expand to longer TeaScript code at compile time. Confusing, here’s an example:

153 |
£lc)    // Original Code
154 | xl(#lc) // Code at compile-time
155 | 
156 |
157 |

What if I want to use a unicode character in my code. Unicode characters in literals (i.e. Strings, RegExps, Snippets) are not converted. If for some reason you do want a unicode property name, it can be used by using a \\ before the character

158 |
\£lc     // Original Code
159 | £lc // Code at compile-time
160 | 
161 |
162 |

So how do you use them? You simpily click the Auto-Golf button.

163 |
164 |
165 |

Ommiting characters

166 |
167 |

Removing Brackets

168 |

If you have a function, and then a literal, you can ommit the ( before it. You can also ommit ending ) and other brackets

169 |
MF(32) // Before
170 | MF32   // After
171 | 
172 | MF(3,x[32]) // Before
173 | MF3,x[32    // After
174 | 
175 |
176 |
177 |
178 |

Removing Literal Endings

179 |

Endings of literal characters can be ommited, this includes Strings, RegExps, and Snippets.

180 |
"Foo"  // Before
181 | "Foo   // After
182 | 
183 | `Foo`  // Before
184 | `Foo   // After
185 | 
186 | /Fo{2}/ // Before
187 | /Fo{2}  // After
188 | 
189 |
190 |
191 |
192 |
193 | 194 | 195 |
196 |
197 |
198 | 199 | 207 | 208 | 209 |
210 | 211 |
212 |

213 | © Copyright 2015, Vihan. 214 | 215 |

216 |
217 | Built with Sphinx using a theme provided by Read the Docs. 218 | 219 |
220 | 221 |
222 |
223 | 224 |
225 | 226 |
227 | 228 | 229 | 230 | 231 | 232 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 259 | 260 | 261 | 262 | -------------------------------------------------------------------------------- /docs/_build/html/basic-examples.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Basic Examples — TeaScript beta documentation 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |
45 | 46 | 47 | 115 | 116 |
117 | 118 | 119 | 123 | 124 | 125 | 126 |
127 |
128 | 129 | 130 | 131 | 132 | 133 | 134 |
135 |
    136 |
  • Docs »
  • 137 | 138 |
  • Basic Examples
  • 139 |
  • 140 | 141 | 142 | View page source 143 | 144 | 145 |
  • 146 |
147 |
148 |
149 |
150 |
151 | 152 |
153 |

Basic Examples

154 |
155 |

String Tasks

156 |
157 |

Hello, World

158 | 162 |

Outputs Hello, World

163 |
"Hello, World!
164 | 
165 |
166 |
167 |
168 |

cat

169 | 173 |

Outputs the input

174 |
x
175 | 
176 |
177 |
178 |
179 |
180 |

Number Tasks

181 |
182 |

Fibonacci

183 | 187 |

Given n this calculated the nth Fibonacci number

188 |
F(x
189 | 
190 |
191 |
192 |
193 |

Primality Test

194 | 198 |

Calculates whether a given number is prime

199 |
mP(x
200 | 
201 |
202 |
203 |
204 |
205 |

Array Tasks

206 |
207 |

Cycling Arrays

208 | 212 |

Cycle an array 1 spots

213 |
xC1
214 | 
215 |
216 |
217 |
218 |

Average of Numbers

219 | 223 |

Calculates the average of numbers

224 |
xx/xn
225 | 
226 |
227 |
228 |
229 |
230 | 231 | 232 |
233 |
234 |
235 | 236 | 244 | 245 | 246 |
247 | 248 |
249 |

250 | © Copyright 2015, Vihan. 251 | 252 |

253 |
254 | Built with Sphinx using a theme provided by Read the Docs. 255 | 256 |
257 | 258 |
259 |
260 | 261 |
262 | 263 |
264 | 265 | 266 | 267 | 268 | 269 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 296 | 297 | 298 | 299 | -------------------------------------------------------------------------------- /docs/_build/html/genindex.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Index — TeaScript beta documentation 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |
44 | 45 | 46 | 98 | 99 |
100 | 101 | 102 | 106 | 107 | 108 | 109 |
110 |
111 | 112 | 113 | 114 | 115 | 116 | 117 |
118 |
    119 |
  • Docs »
  • 120 | 121 |
  • 122 |
  • 123 | 124 | 125 | 126 |
  • 127 |
128 |
129 |
130 |
131 |
132 | 133 | 134 |

Index

135 | 136 |
137 | 138 |
139 | 140 | 141 |
142 |
143 |
144 | 145 | 146 |
147 | 148 |
149 |

150 | © Copyright 2015, Vihan. 151 | 152 |

153 |
154 | Built with Sphinx using a theme provided by Read the Docs. 155 | 156 |
157 | 158 |
159 |
160 | 161 |
162 | 163 |
164 | 165 | 166 | 167 | 168 | 169 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 196 | 197 | 198 | 199 | -------------------------------------------------------------------------------- /docs/_build/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Welcome to TeaScript’s documentation! — TeaScript beta documentation 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |
44 | 45 | 46 | 98 | 99 |
100 | 101 | 102 | 106 | 107 | 108 | 109 |
110 |
111 | 112 | 113 | 114 | 115 | 116 | 117 |
118 |
    119 |
  • Docs »
  • 120 | 121 |
  • Welcome to TeaScript’s documentation!
  • 122 |
  • 123 | 124 | 125 | View page source 126 | 127 | 128 |
  • 129 |
130 |
131 |
132 |
133 |
134 | 135 |
136 |

Welcome to TeaScript’s documentation!

137 |

TeaScript is a powerful JavaScript golfing language created by StackExchange, PPCG, user Downgoat. TeaScript compiles to JavaScript and contains many helpful features for golfing

138 |

Contents:

139 |
140 | 183 |
184 |
185 | 186 | 187 |
188 |
189 |
190 | 191 | 197 | 198 | 199 |
200 | 201 |
202 |

203 | © Copyright 2015, Vihan. 204 | 205 |

206 |
207 | Built with Sphinx using a theme provided by Read the Docs. 208 | 209 |
210 | 211 |
212 |
213 | 214 |
215 | 216 |
217 | 218 | 219 | 220 | 221 | 222 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 249 | 250 | 251 | 252 | -------------------------------------------------------------------------------- /docs/_build/html/installation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Installation — TeaScript beta documentation 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |
45 | 46 | 47 | 106 | 107 |
108 | 109 | 110 | 114 | 115 | 116 | 117 |
118 |
119 | 120 | 121 | 122 | 123 | 124 | 125 |
126 |
    127 |
  • Docs »
  • 128 | 129 |
  • Installation
  • 130 |
  • 131 | 132 | 133 | View page source 134 | 135 | 136 |
  • 137 |
138 |
139 |
140 |
141 |
142 | 143 |
144 |

Installation

145 |

Running TeaScript is pretty simple, they’re multiple ways you can do this

146 |
147 |

Web Interface

148 |

TeaScript has a pretty sweet web interface and is the best enviorment for running TeaScript. All extensions are packaged up and usage is pretty straight-forward.

149 |
150 |
154 |
155 |
156 |
157 |

Command Line

158 |

If you wish to run TeaScript from the command line, ensure you have SpiderMonkey 38 or higher installed. They’re multiple ways to get started

159 |
160 |

Auto-Install Script

161 |

Install teascript from the GitHub

162 |

Give teascript the correct permissions

163 |
$ chmod +x teascript
164 | 
165 |
166 |

Run teascript, and it should install the correct files. Enter the code, and then the input, , seperated.

167 |
1
168 | 2
169 | 3
170 | 4
171 | 5
172 | 6
  $ ./teascript
173 |   TeaScript not installed. Installing TeaScript...
174 |   # ...
175 |   Code: # <TeaScript Code Here>
176 |   Input: # <Input Here> e.g.: Input 1,Input 2,Input 3,...
177 |   # <Output Here>
178 | 
179 |
180 |

The next time you run TeaScript, it’ll detect the TeaScript/ folder and won’t need to reinstall the dependencies.

181 |
182 |
183 |

Manual Installation

184 |

You can also manually install/run TeaScript if you’re having issues with the script

185 |

Install the following files

186 |
187 |
191 |
192 |

Edit teascript.js and replace window with this, and /*props.json*/ with JSON.parse(read("props.json"))

193 |
194 |

Note

195 |

Different enviorments might use a different function than read

196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 |
node.js:fs.readFile
rhino:readFile
spidermonkey:read
208 |
209 |
210 |
211 |
212 | 213 | 214 |
215 |
216 |
217 | 218 | 226 | 227 | 228 |
229 | 230 |
231 |

232 | © Copyright 2015, Vihan. 233 | 234 |

235 |
236 | Built with Sphinx using a theme provided by Read the Docs. 237 | 238 |
239 | 240 |
241 |
242 | 243 |
244 | 245 |
246 | 247 | 248 | 249 | 250 | 251 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 278 | 279 | 280 | 281 | -------------------------------------------------------------------------------- /docs/_build/html/objects.inv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vihanb/TeaScript/35785cb85f8000780ce1344076805bda2a93dc17/docs/_build/html/objects.inv -------------------------------------------------------------------------------- /docs/_build/html/search.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Search — TeaScript beta documentation 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |
43 | 44 | 45 | 97 | 98 |
99 | 100 | 101 | 105 | 106 | 107 | 108 |
109 |
110 | 111 | 112 | 113 | 114 | 115 | 116 |
117 |
    118 |
  • Docs »
  • 119 | 120 |
  • 121 |
  • 122 | 123 |
  • 124 |
125 |
126 |
127 |
128 |
129 | 130 | 138 | 139 | 140 |
141 | 142 |
143 | 144 |
145 |
146 |
147 | 148 | 149 |
150 | 151 |
152 |

153 | © Copyright 2015, Vihan. 154 | 155 |

156 |
157 | Built with Sphinx using a theme provided by Read the Docs. 158 | 159 |
160 | 161 |
162 |
163 | 164 |
165 | 166 |
167 | 168 | 169 | 170 | 171 | 172 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 200 | 201 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | -------------------------------------------------------------------------------- /docs/_build/html/searchindex.js: -------------------------------------------------------------------------------- 1 | Search.setIndex({envversion:46,filenames:["auto-golf","basic-examples","errors","getting-started","index","installation","new-features","variables"],objects:{},objnames:{},objtypes:{},terms:{"0b10":3,"0o18":3,"0x1f":[],"0xfa":3,"12e3":[],"1e23":3,"1st":3,"\u0192":[],"\u0192l":[6,7],"\u03c0":7,"\u03c3":[],"\u03c6":7,"break":2,"byte":0,"char":6,"default":3,"final":[],"function":[],"long":0,"new":[],"return":3,"short":0,"try":2,"var":7,"x\u03c3i":6,"x\u03c3lc":6,abc:[],abl:[2,7],about:[6,7],actual:[],add:[3,6],after:[0,6,7],all:[2,3,5],allow:3,alreadi:[2,7],also:[0,3,5,7],altern:5,alwai:[],anoth:2,argument:3,arrai:[],articl:[],asdf:[],assign:2,at2:6,attempt:[0,2],automag:[],automat:[0,3],avoid:[],babelj:2,back:[],backward:3,balanc:2,becaus:[],becom:3,been:[2,6],befor:[0,6,7],begin:1,believ:2,best:5,better:[],binari:3,both:7,bracket:[],browser:2,bug:2,button:0,calcul:1,can:[0,2,3,5,6,7],caus:2,chang:2,charact:[],check:[1,2],chmod:5,click:0,close:6,code:[0,2,3,5,6],codegolf:[],com:[],come:6,command:[],compat:3,compil:[0,1,2,3,4,6],confus:0,connect:2,contain:[1,4],content:4,continu:2,convert:0,correct:5,could:2,creat:[4,6],debug:2,decid:3,decim:3,decler:6,defin:[],definit:7,depend:[],detect:5,dfjkv:7,diagnos:2,differ:5,displai:2,doe:[],doesn:2,don:2,doubl:3,down:2,downgoat:4,drop:[],dure:2,each:[2,3],easi:3,easier:7,easili:6,edit:5,either:2,encount:2,ensur:[2,5],enter:[2,5],envior:[2,5],enviro:2,error:[],es2015:[],es5:[],esenti:6,especi:3,even:6,ever:[2,6],everi:3,everyth:5,evior:[],evolv:3,execut:[],expand:[0,3,6],expans:[2,6],experiment:[],exponenti:[],extens:[5,6],extra:3,fals:[2,7],featur:[],few:[0,2,3],file:[2,5],first:[],fix:2,folder:5,follow:[2,3,5],foo:[0,6],foofoofoo:[],forc:2,forward:5,freeli:[],from:[2,5],gener:[2,6],getter:[],github:[2,5],give:5,given:1,goal:3,golf:[],googl:[],handl:[],happen:2,have:[0,3,5,6],help:4,here:[0,5,6],hesit:2,hexadecim:3,higher:5,highli:[],hope:3,hopefulli:6,how:[0,3],http:[],idea:[],identifi:2,implement:3,includ:0,index:[],init:7,inlin:3,input:[],inser:[],insert:6,instal:[],instruct:[],interrupt:6,issu:[2,5],item:3,itself:2,javascript:[3,4,6,7],json:[2,5],just:[3,7],keep:[],kei:2,know:[],knowledg:3,lambda:6,languag:[3,4],learn:[6,7],length:1,lengthi:3,letter:7,like:3,line:[],load:2,longer:0,look:[2,3],loop:6,lot:[],made:2,mai:[2,7],main:3,make:[0,2],mani:[4,7],map:6,mean:6,mf32:0,mf3:0,middl:[],might:5,mode:2,modifi:[],modul:[],moment:2,more:[0,3,6,7],multipl:5,name:[0,3,6],nativ:7,need:[3,5,6],nest:6,network:2,never:[],newlin:3,next:5,node:5,nope:[],notat:3,now:6,occur:2,octal:3,onc:[],onli:2,oper:[],opposit:0,origin:[0,2],output:[1,5],overload:[],overrid:2,overwritten:7,packag:5,page:[],paranthesi:2,parenthesi:6,pars:5,perform:0,permiss:5,place:2,point:[],possibl:[0,2],power:[4,6],ppcg:4,pre:7,preassign:7,predefin:[],pretti:5,previou:2,prime:1,prior:3,program:[],prop:[2,5],properti:[0,2,3,6],provid:0,quit:3,quot:3,rang:6,rather:2,read:5,readabl:0,readfil:5,reason:0,recurs:[6,7],ref:[],referenc:2,regex:2,reinstal:[2,5],remov:[],repeat:[],replac:5,report:2,requir:[],rhino:5,run:5,runtim:[],said:6,same:3,scientif:3,search:6,see:7,seper:[3,5],set:2,shortcut:[],shorter:3,shorthand:[],should:[2,3,5],shouldn:2,similar:6,simpili:0,simpl:[3,5],singl:3,skip:7,slowli:3,snippet:[0,2],solv:2,some:[0,6,7],specul:[],spidermonkei:5,split:3,spot:1,src:5,stackexchang:4,stage:2,step:2,store:3,straight:5,sub___:[],sum:1,support:3,sure:2,sweet:5,syntax:[],syntaxerror:2,take:2,teascript_env:2,technic:2,templat:3,test:[],than:[2,5,6],thei:[0,3,5],them:[0,2,3,7],thi:[0,1,2,3,5,6,7],think:6,three:3,through:6,thrown:2,time:[0,2,3,5,6],togeth:3,too:3,track:[],two:6,type:[],unbalanc:2,unclos:2,understand:[],unicod:[],unimpl:[],unsupport:2,upon:3,url:5,usag:5,user:[3,4],usual:2,valid:[2,3],valu:[3,6,7],variabl:[2,3],variou:[3,7],veri:[3,6],wai:[0,5,7],want:[0,3],what:0,when:2,where:[2,6],whether:1,which:[0,2,3,7],window:5,wish:5,within:5,without:[0,6],won:5,word:[],work:[0,2],xc1:1,xor:[],xregexp:3,you:[0,2,3,5,6,7],your:[]},titles:["Auto-Golfing","Basic Examples","Error Handling","Getting Started","Welcome to TeaScript’s documentation!","Installation","New Features","Variables"],titleterms:{"\u0192":6,"\u03c3":6,"___":2,"class":6,"function":3,"new":6,ani:2,approach:2,arrai:1,assign:7,auto:[0,5],averag:1,babel:2,basic:1,bracket:0,cat:1,charact:[0,6],command:5,custom:6,cycl:1,depend:2,document:4,duplic:2,end:0,error:2,exampl:1,exist:2,explan:1,featur:6,fibonacci:1,first:[],found:2,get:3,getter:2,golf:0,handl:2,hello:1,indic:[],input:3,instal:5,interfac:5,invalid:2,line:5,liter:[0,2,3],locat:2,manual:5,maximum:2,modifi:6,number:[1,3],ommit:0,oper:[6,7],option:3,other:2,predefin:7,primal:1,program:[],regexp:[3,6],remov:0,runtim:2,script:5,shortcut:0,shorthand:7,slot:2,start:3,string:[1,3],sub:[],sub___:2,subglob:[],syntax:2,tabl:[],task:1,teascript:4,test:1,titl:[],type:2,understand:[],unexpect:2,unicod:0,variabl:7,web:5,welcom:4,world:1,write:[],your:[]}}) -------------------------------------------------------------------------------- /docs/auto-golf.rst: -------------------------------------------------------------------------------- 1 | Auto-Golfing 2 | ************ 3 | 4 | ``Auto-Golf`` is a feature which performs automatic golfing for you. It provides a few features. 5 | 6 | .. hint:: 7 | The ``Un-Auto-Golf`` will do the opposite and will attempt to make code more readable. 8 | 9 | Unicode Shortcuts 10 | ================= 11 | 12 | Unicode shortcuts are a way to get code as short as possible without doing any work! What are they? Unicode shortcuts are 1-byte long unicode characters which expand to longer TeaScript code at compile time. Confusing, here's an example: 13 | 14 | .. code-block:: js 15 | 16 | £lc) // Original Code 17 | xl(#lc) // Code at compile-time 18 | 19 | What if I want to use a unicode character in my code. Unicode characters in literals (i.e. Strings, RegExps, Snippets) are not converted. If for some reason you do want a unicode property name, it can be used by using a ``\\`` before the character 20 | 21 | .. code-block:: js 22 | 23 | \£lc // Original Code 24 | £lc // Code at compile-time 25 | 26 | So how do you use them? You simpily click the ``Auto-Golf`` button. 27 | 28 | Ommiting characters 29 | =================== 30 | 31 | Removing Brackets 32 | ----------------- 33 | 34 | If you have a function, and then a literal, you can ommit the ``(`` before it. You can also ommit ending ``)`` and other brackets 35 | 36 | .. code-block:: js 37 | 38 | MF(32) // Before 39 | MF32 // After 40 | 41 | MF(3,x[32]) // Before 42 | MF3,x[32 // After 43 | 44 | Removing Literal Endings 45 | ------------------------ 46 | 47 | Endings of literal characters can be ommited, this includes Strings, RegExps, and Snippets. 48 | 49 | .. code-block:: js 50 | 51 | "Foo" // Before 52 | "Foo // After 53 | 54 | `Foo` // Before 55 | `Foo // After 56 | 57 | /Fo{2}/ // Before 58 | /Fo{2} // After -------------------------------------------------------------------------------- /docs/basic-examples.rst: -------------------------------------------------------------------------------- 1 | Basic Examples 2 | ************** 3 | 4 | String Tasks 5 | ============= 6 | 7 | Hello, World 8 | ------------- 9 | .. sidebar:: Explanation 10 | 11 | ``"`` begins a string literal. 12 | 13 | Outputs ``Hello, World`` 14 | 15 | .. code-block:: js 16 | 17 | "Hello, World! 18 | 19 | cat 20 | ---- 21 | .. sidebar:: Explanation 22 | 23 | ``x`` contains the input 24 | 25 | Outputs the input 26 | 27 | .. code-block:: js 28 | 29 | x 30 | 31 | Number Tasks 32 | ============= 33 | 34 | Fibonacci 35 | --------- 36 | 37 | .. sidebar:: Explanation 38 | 39 | ``F`` is a Fibonacci function. ``x`` is the input 40 | 41 | Given ``n`` this calculated the ``n``\ th Fibonacci number 42 | 43 | .. code-block:: js 44 | 45 | F(x 46 | 47 | Primality Test 48 | -------------- 49 | 50 | .. sidebar:: Explanation 51 | 52 | ``mP`` is a primality check function 53 | 54 | Calculates whether a given number is prime 55 | 56 | .. code-block:: js 57 | 58 | mP(x 59 | 60 | Array Tasks 61 | =========== 62 | 63 | Cycling Arrays 64 | --------------- 65 | 66 | .. sidebar:: Explanation 67 | 68 | ``C`` cycles an array, ``x`` is the input 69 | 70 | Cycle an array 1 spots 71 | 72 | .. code-block:: js 73 | 74 | xC1 75 | 76 | Average of Numbers 77 | ------------------- 78 | 79 | .. sidebar:: Explanation 80 | 81 | ``x`` is the input, ``x`` is a sum getter. ``n`` is the length. Compiled, this is ``x.x/x.n`` or ``x.sum/x.length`` 82 | 83 | Calculates the average of numbers 84 | 85 | .. code-block:: js 86 | 87 | xx/xn -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # TeaScript documentation build configuration file, created by 4 | # sphinx-quickstart on Sat Dec 26 13:23:03 2015. 5 | # 6 | # This file is execfile()d with the current directory set to its 7 | # containing dir. 8 | # 9 | # Note that not all possible configuration values are present in this 10 | # autogenerated file. 11 | # 12 | # All configuration values have a default; values that are commented out 13 | # serve to show the default. 14 | 15 | import sys 16 | import os 17 | import shlex 18 | import sphinx_rtd_theme 19 | 20 | # If extensions (or modules to document with autodoc) are in another directory, 21 | # add these directories to sys.path here. If the directory is relative to the 22 | # documentation root, use os.path.abspath to make it absolute, like shown here. 23 | #sys.path.insert(0, os.path.abspath('.')) 24 | 25 | # -- General configuration ------------------------------------------------ 26 | 27 | # If your documentation needs a minimal Sphinx version, state it here. 28 | #needs_sphinx = '1.0' 29 | 30 | # Add any Sphinx extension module names here, as strings. They can be 31 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 32 | # ones. 33 | extensions = [] 34 | 35 | # Add any paths that contain templates here, relative to this directory. 36 | templates_path = ['_templates'] 37 | 38 | # The suffix(es) of source filenames. 39 | # You can specify multiple suffix as a list of string: 40 | # source_suffix = ['.rst', '.md'] 41 | source_suffix = '.rst' 42 | 43 | # The encoding of source files. 44 | #source_encoding = 'utf-8-sig' 45 | 46 | # The master toctree document. 47 | master_doc = 'index' 48 | 49 | # General information about the project. 50 | project = u'TeaScript' 51 | copyright = u'2015, Vihan' 52 | author = u'Vihan' 53 | 54 | # The version info for the project you're documenting, acts as replacement for 55 | # |version| and |release|, also used in various other places throughout the 56 | # built documents. 57 | # 58 | # The short X.Y version. 59 | version = u'3' 60 | # The full version, including alpha/beta/rc tags. 61 | release = u'beta' 62 | 63 | # The language for content autogenerated by Sphinx. Refer to documentation 64 | # for a list of supported languages. 65 | # 66 | # This is also used if you do content translation via gettext catalogs. 67 | # Usually you set "language" from the command line for these cases. 68 | language = None 69 | 70 | # There are two options for replacing |today|: either, you set today to some 71 | # non-false value, then it is used: 72 | #today = '' 73 | # Else, today_fmt is used as the format for a strftime call. 74 | #today_fmt = '%B %d, %Y' 75 | 76 | # List of patterns, relative to source directory, that match files and 77 | # directories to ignore when looking for source files. 78 | exclude_patterns = ['_build'] 79 | 80 | # The reST default role (used for this markup: `text`) to use for all 81 | # documents. 82 | #default_role = None 83 | 84 | # If true, '()' will be appended to :func: etc. cross-reference text. 85 | #add_function_parentheses = True 86 | 87 | # If true, the current module name will be prepended to all description 88 | # unit titles (such as .. function::). 89 | #add_module_names = True 90 | 91 | # If true, sectionauthor and moduleauthor directives will be shown in the 92 | # output. They are ignored by default. 93 | #show_authors = False 94 | 95 | # The name of the Pygments (syntax highlighting) style to use. 96 | pygments_style = 'sphinx' 97 | 98 | # A list of ignored prefixes for module index sorting. 99 | #modindex_common_prefix = [] 100 | 101 | # If true, keep warnings as "system message" paragraphs in the built documents. 102 | #keep_warnings = False 103 | 104 | # If true, `todo` and `todoList` produce output, else they produce nothing. 105 | todo_include_todos = False 106 | 107 | 108 | # -- Options for HTML output ---------------------------------------------- 109 | 110 | # The theme to use for HTML and HTML Help pages. See the documentation for 111 | # a list of builtin themes. 112 | html_theme = 'sphinx_rtd_theme' 113 | 114 | # Theme options are theme-specific and customize the look and feel of a theme 115 | # further. For a list of options available for each theme, see the 116 | # documentation. 117 | #html_theme_options = {} 118 | 119 | # Add any paths that contain custom themes here, relative to this directory. 120 | html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] 121 | 122 | # The name for this set of Sphinx documents. If None, it defaults to 123 | # " v documentation". 124 | #html_title = None 125 | 126 | # A shorter title for the navigation bar. Default is the same as html_title. 127 | #html_short_title = None 128 | 129 | # The name of an image file (relative to this directory) to place at the top 130 | # of the sidebar. 131 | #html_logo = None 132 | 133 | # The name of an image file (within the static path) to use as favicon of the 134 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 135 | # pixels large. 136 | #html_favicon = None 137 | 138 | # Add any paths that contain custom static files (such as style sheets) here, 139 | # relative to this directory. They are copied after the builtin static files, 140 | # so a file named "default.css" will overwrite the builtin "default.css". 141 | html_static_path = ['_static'] 142 | 143 | # Add any extra paths that contain custom files (such as robots.txt or 144 | # .htaccess) here, relative to this directory. These files are copied 145 | # directly to the root of the documentation. 146 | #html_extra_path = [] 147 | 148 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 149 | # using the given strftime format. 150 | #html_last_updated_fmt = '%b %d, %Y' 151 | 152 | # If true, SmartyPants will be used to convert quotes and dashes to 153 | # typographically correct entities. 154 | #html_use_smartypants = True 155 | 156 | # Custom sidebar templates, maps document names to template names. 157 | #html_sidebars = {} 158 | 159 | # Additional templates that should be rendered to pages, maps page names to 160 | # template names. 161 | #html_additional_pages = {} 162 | 163 | # If false, no module index is generated. 164 | #html_domain_indices = True 165 | 166 | # If false, no index is generated. 167 | #html_use_index = True 168 | 169 | # If true, the index is split into individual pages for each letter. 170 | #html_split_index = False 171 | 172 | # If true, links to the reST sources are added to the pages. 173 | #html_show_sourcelink = True 174 | 175 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 176 | #html_show_sphinx = True 177 | 178 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 179 | #html_show_copyright = True 180 | 181 | # If true, an OpenSearch description file will be output, and all pages will 182 | # contain a tag referring to it. The value of this option must be the 183 | # base URL from which the finished HTML is served. 184 | #html_use_opensearch = '' 185 | 186 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 187 | #html_file_suffix = None 188 | 189 | # Language to be used for generating the HTML full-text search index. 190 | # Sphinx supports the following languages: 191 | # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' 192 | # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' 193 | #html_search_language = 'en' 194 | 195 | # A dictionary with options for the search language support, empty by default. 196 | # Now only 'ja' uses this config value 197 | #html_search_options = {'type': 'default'} 198 | 199 | # The name of a javascript file (relative to the configuration directory) that 200 | # implements a search results scorer. If empty, the default will be used. 201 | #html_search_scorer = 'scorer.js' 202 | 203 | # Output file base name for HTML help builder. 204 | htmlhelp_basename = 'TeaScriptdoc' 205 | 206 | # -- Options for LaTeX output --------------------------------------------- 207 | 208 | latex_elements = { 209 | # The paper size ('letterpaper' or 'a4paper'). 210 | #'papersize': 'letterpaper', 211 | 212 | # The font size ('10pt', '11pt' or '12pt'). 213 | #'pointsize': '10pt', 214 | 215 | # Additional stuff for the LaTeX preamble. 216 | #'preamble': '', 217 | 218 | # Latex figure (float) alignment 219 | #'figure_align': 'htbp', 220 | } 221 | 222 | # Grouping the document tree into LaTeX files. List of tuples 223 | # (source start file, target name, title, 224 | # author, documentclass [howto, manual, or own class]). 225 | latex_documents = [ 226 | (master_doc, 'TeaScript.tex', u'TeaScript Documentation', 227 | u'Vihan', 'manual'), 228 | ] 229 | 230 | # The name of an image file (relative to this directory) to place at the top of 231 | # the title page. 232 | #latex_logo = None 233 | 234 | # For "manual" documents, if this is true, then toplevel headings are parts, 235 | # not chapters. 236 | #latex_use_parts = False 237 | 238 | # If true, show page references after internal links. 239 | #latex_show_pagerefs = False 240 | 241 | # If true, show URL addresses after external links. 242 | #latex_show_urls = False 243 | 244 | # Documents to append as an appendix to all manuals. 245 | #latex_appendices = [] 246 | 247 | # If false, no module index is generated. 248 | #latex_domain_indices = True 249 | 250 | 251 | # -- Options for manual page output --------------------------------------- 252 | 253 | # One entry per manual page. List of tuples 254 | # (source start file, name, description, authors, manual section). 255 | man_pages = [ 256 | (master_doc, 'teascript', u'TeaScript Documentation', 257 | [author], 1) 258 | ] 259 | 260 | # If true, show URL addresses after external links. 261 | #man_show_urls = False 262 | 263 | 264 | # -- Options for Texinfo output ------------------------------------------- 265 | 266 | # Grouping the document tree into Texinfo files. List of tuples 267 | # (source start file, target name, title, author, 268 | # dir menu entry, description, category) 269 | texinfo_documents = [ 270 | (master_doc, 'TeaScript', u'TeaScript Documentation', 271 | author, 'TeaScript', 'One line description of project.', 272 | 'Miscellaneous'), 273 | ] 274 | 275 | # Documents to append as an appendix to all manuals. 276 | #texinfo_appendices = [] 277 | 278 | # If false, no module index is generated. 279 | #texinfo_domain_indices = True 280 | 281 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 282 | #texinfo_show_urls = 'footnote' 283 | 284 | # If true, do not generate a @detailmenu in the "Top" node's menu. 285 | #atexinfo_no_detailmenu = False 286 | 287 | from recommonmark.parser import CommonMarkParser 288 | 289 | source_parsers = { 290 | '.md': CommonMarkParser, 291 | } 292 | 293 | source_suffix = ['.rst', '.md'] -------------------------------------------------------------------------------- /docs/errors.rst: -------------------------------------------------------------------------------- 1 | Error Handling 2 | ************** 3 | 4 | Approaching Literal Maximum 5 | ============================ 6 | 7 | This is the only error that can be thrown during compilation at the moment. This is caused when a literal (i.e. String, RegEx) is unbalanced. 8 | 9 | .. code-block:: js 10 | 11 | "unclosed string 12 | /unclosed regex 13 | $unclosed snippet 14 | 15 | Dependency not found: babel 16 | =========================== 17 | 18 | ``babeljs``, was not able to be loaded, check your network connection and ensure babel is connected. If you believe this shouldn't be occuring don't hesitate to `report it `_ on Github. 19 | 20 | Existing sub___: Slot used 21 | ============================= 22 | 23 | During enviorment generation, a few errors can occur, this occurs when TeaScript is trying to assign a variable but it has already been assigned. You can override this by force setting ``TEASCRIPT_ENV`` to false, each time enviroment generation takes place 24 | 25 | .. note:: 26 | This is a technical error, you are either using an unsupported browser/enviorment or there is a bug in TeaScript. If you believe it's a bug, don't hesitate to `report it `_ on Github 27 | 28 | Invalid location, ___, error ___ 29 | ================================= 30 | 31 | If this ever occurs, TeaScript has encountered an issue with the ``props.json`` file, possible fixes are reinstalling the ``props.json``. If this continues, don't hesitate to `report it `_ on Github. 32 | 33 | Unexpected Type: ___ at ___ 34 | =========================== 35 | 36 | This is another error with the ``props.json``, check to make sure the json is valid. Try reinstalling the ``props.json``, and if that doesn't work, don't hesitate to `report it `_ on Github. 37 | 38 | Duplicate Getter: ___ 39 | ====================== 40 | 41 | An attempt was made to assign a getter to an already assigned key. To diagnose this, try looking for duplicate getters in the ``props.json`` and change/remove them. 42 | 43 | *Any* other error 44 | ================= 45 | 46 | All other errors are either JS Runtime or syntax errors, which can be solved by entering `Debugging Mode` 47 | 48 | Syntax Errors 49 | -------------- 50 | 51 | A syntax error starts with ``SyntaxError:``, and is an error with the syntax itself, the error should display from where the error originated and by looking at the previous compilation steps, you may be able to identify where the error occured. 52 | 53 | This error could of originated in any of the following compilation stages: 54 | 55 | * String Balancing 56 | * Unicode Shortcuts 57 | * Property Expansion 58 | * Paranthesis Balancing 59 | * babel compilation 60 | 61 | If you believe the error originated during babel compilation, report the error at `babel's Github `_. 62 | 63 | Runtime Errors 64 | -------------- 65 | 66 | Any other error is a JS runtime error which is usually caused by referencing a variable that doesn't exist. Runtime errors are errors with the code itself rather than the syntax. Try to break down your code and try to identify where the error is originating. If you believe this error shouldn't be happening, don't hesitate to `report it `_ on Github. -------------------------------------------------------------------------------- /docs/getting-started.rst: -------------------------------------------------------------------------------- 1 | Getting Started 2 | *************** 3 | 4 | Getting started with TeaScript is *very* easy especially if you have prior JavaScript knowledge. 5 | 6 | This was the main goal of TeaScript was a JavaScript golfing language that *was* JavaScript but with shorter property names. This slowly evolved but TeaScript is backwards compatible so every JavaScript program is a valid TeaScript program 7 | 8 | Literals 9 | ======== 10 | 11 | Literals are very simple in TeaScript as they are the same as JavaScript literals 12 | 13 | Strings 14 | ------- 15 | 16 | They are three types of strings 17 | 18 | .. code-block:: js 19 | 20 | "Double Quoted String Literal" 21 | 'Single Quoted String Literal' 22 | `String templates` 23 | 24 | String templates have a few extra features such as: 25 | 26 | .. code-block:: js 27 | 28 | `String templates support inline 29 | newlines and code such as ${2+1}` 30 | 31 | Numbers 32 | ------- 33 | 34 | Numbers are also, just *numbers*: 35 | 36 | .. code-block:: js 37 | 38 | 12345 // Decimal 39 | 12.34 // Decimal 40 | 1e23) // Scientific Notation 41 | 0xFA) // Hexadecimal 42 | 0b10) // Binary 43 | 0o18) // Octal 44 | 45 | RegExp 46 | ------- 47 | 48 | TeaScript has support for RegExp literals and they're just the same as JavaScript 49 | 50 | .. code-block:: js 51 | 52 | /[A-Za-z]/gi 53 | 54 | By TeaScript 3.1, I hope to have `XRegExp`, implemented which should allow your RegExp literals to look like: 55 | 56 | .. code-block:: js 57 | 58 | /\u{L}+/u 59 | 60 | Functions 61 | --------- 62 | 63 | Functions are the same as JavaScript too. 64 | 65 | .. code-block:: js 66 | 67 | (a,b,c)=>a+b+c // Arguments[a,b,c] adds them together 68 | a=>a // Single argument a, returns a 69 | 70 | This is quite lengthy so I've added the ``#`` operator which automatically expands to ``(l,i,a,b)=>`` at compile time 71 | 72 | .. code-block:: none 73 | 74 | #l+i+a // Arguments[l,i,a,b] adds first 3 75 | 76 | Input 77 | ===== 78 | 79 | Input Options 80 | ------------- 81 | 82 | The user can decide how (s)he wants the input. TeaScript supports all of the following input types: 83 | 84 | - String (default) 85 | - Number 86 | - Array 87 | 88 | Getting the Input 89 | ----------------- 90 | 91 | The input is stored in various variables: 92 | 93 | ======== ============= 94 | Input # Variable Name 95 | ======== ============= 96 | 1 ``x`` 97 | 2 ``y`` 98 | 3 ``z`` 99 | ======== ============= 100 | 101 | Need More inputs? An array of all the inputs is stored in the ``_`` variable. 102 | 103 | .... 104 | 105 | If the input is an array, the 1st input will be split upon ``,`` and each item will become a seperate input. For the code: 106 | 107 | .. code-block:: none 108 | 109 | Input 1,Input 2,Input 3 110 | 111 | The values are: 112 | 113 | =========== ============= 114 | Input Value Variable Name 115 | =========== ============= 116 | ``Input 1`` ``x`` 117 | ``Input 2`` ``y`` 118 | ``Input 3`` ``z`` 119 | =========== ============= -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to TeaScript's documentation! 2 | ===================================== 3 | 4 | TeaScript is a powerful JavaScript golfing language created by StackExchange, PPCG, user `Downgoat `_. TeaScript compiles to JavaScript and contains many helpful features for golfing 5 | 6 | Contents: 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | installation 12 | getting-started 13 | new-features 14 | variables 15 | auto-golf 16 | basic-examples 17 | errors -------------------------------------------------------------------------------- /docs/installation.rst: -------------------------------------------------------------------------------- 1 | .. _label: install 2 | 3 | Installation 4 | *************** 5 | 6 | Running TeaScript is pretty simple, they're multiple ways you can do this 7 | 8 | Web Interface 9 | ============ 10 | 11 | TeaScript has a pretty sweet web interface and is the best enviorment for running TeaScript. All extensions are packaged up and usage is pretty straight-forward. 12 | 13 | * `Web Interface `_ 14 | * `Alternate URL `_ 15 | 16 | Command Line 17 | ============ 18 | 19 | If you wish to run TeaScript from the command line, ensure you have **SpiderMonkey 38** or higher installed. They're multiple ways to get started 20 | 21 | Auto-Install Script 22 | ------------------- 23 | 24 | Install ``teascript`` from the `GitHub `_ 25 | 26 | Give ``teascript`` the correct permissions 27 | 28 | .. code-block:: shell 29 | 30 | $ chmod +x teascript 31 | 32 | Run ``teascript``, and it should install the correct files. Enter the code, and then the input, ``,`` seperated. 33 | 34 | .. code-block:: shell 35 | :linenos: 36 | 37 | $ ./teascript 38 | TeaScript not installed. Installing TeaScript... 39 | # ... 40 | Code: # 41 | Input: # e.g.: Input 1,Input 2,Input 3,... 42 | # 43 | 44 | The next time you run TeaScript, it'll detect the `TeaScript/` folder and won't need to reinstall the dependencies. 45 | 46 | Manual Installation 47 | ------------------- 48 | 49 | You can also manually install/run TeaScript if you're having issues with the script 50 | 51 | Install the following files 52 | 53 | - Everything within `/src/v2 `_ 54 | - ``sh.js`` from `/src/sh/sh.js `_ 55 | 56 | Edit ``teascript.js`` and replace ``window`` with ``this``, and ``/*props.json*/`` with ``JSON.parse(read("props.json"))`` 57 | 58 | .. note:: 59 | Different enviorments might use a different function than ``read`` 60 | 61 | :node.js: ``fs.readFile`` 62 | :rhino: ``readFile`` 63 | :spidermonkey: ``read`` -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. xml to make Docutils-native XML files 37 | echo. pseudoxml to make pseudoxml-XML files for display purposes 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | echo. coverage to run coverage check of the documentation if enabled 41 | goto end 42 | ) 43 | 44 | if "%1" == "clean" ( 45 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 46 | del /q /s %BUILDDIR%\* 47 | goto end 48 | ) 49 | 50 | 51 | REM Check if sphinx-build is available and fallback to Python version if any 52 | %SPHINXBUILD% 1>NUL 2>NUL 53 | if errorlevel 9009 goto sphinx_python 54 | goto sphinx_ok 55 | 56 | :sphinx_python 57 | 58 | set SPHINXBUILD=python -m sphinx.__init__ 59 | %SPHINXBUILD% 2> nul 60 | if errorlevel 9009 ( 61 | echo. 62 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 63 | echo.installed, then set the SPHINXBUILD environment variable to point 64 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 65 | echo.may add the Sphinx directory to PATH. 66 | echo. 67 | echo.If you don't have Sphinx installed, grab it from 68 | echo.http://sphinx-doc.org/ 69 | exit /b 1 70 | ) 71 | 72 | :sphinx_ok 73 | 74 | 75 | if "%1" == "html" ( 76 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 77 | if errorlevel 1 exit /b 1 78 | echo. 79 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 80 | goto end 81 | ) 82 | 83 | if "%1" == "dirhtml" ( 84 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 85 | if errorlevel 1 exit /b 1 86 | echo. 87 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 88 | goto end 89 | ) 90 | 91 | if "%1" == "singlehtml" ( 92 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 93 | if errorlevel 1 exit /b 1 94 | echo. 95 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 96 | goto end 97 | ) 98 | 99 | if "%1" == "pickle" ( 100 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 101 | if errorlevel 1 exit /b 1 102 | echo. 103 | echo.Build finished; now you can process the pickle files. 104 | goto end 105 | ) 106 | 107 | if "%1" == "json" ( 108 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 109 | if errorlevel 1 exit /b 1 110 | echo. 111 | echo.Build finished; now you can process the JSON files. 112 | goto end 113 | ) 114 | 115 | if "%1" == "htmlhelp" ( 116 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 117 | if errorlevel 1 exit /b 1 118 | echo. 119 | echo.Build finished; now you can run HTML Help Workshop with the ^ 120 | .hhp project file in %BUILDDIR%/htmlhelp. 121 | goto end 122 | ) 123 | 124 | if "%1" == "qthelp" ( 125 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 129 | .qhcp project file in %BUILDDIR%/qthelp, like this: 130 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\TeaScript.qhcp 131 | echo.To view the help file: 132 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\TeaScript.ghc 133 | goto end 134 | ) 135 | 136 | if "%1" == "devhelp" ( 137 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 138 | if errorlevel 1 exit /b 1 139 | echo. 140 | echo.Build finished. 141 | goto end 142 | ) 143 | 144 | if "%1" == "epub" ( 145 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 146 | if errorlevel 1 exit /b 1 147 | echo. 148 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 149 | goto end 150 | ) 151 | 152 | if "%1" == "latex" ( 153 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 154 | if errorlevel 1 exit /b 1 155 | echo. 156 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 157 | goto end 158 | ) 159 | 160 | if "%1" == "latexpdf" ( 161 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 162 | cd %BUILDDIR%/latex 163 | make all-pdf 164 | cd %~dp0 165 | echo. 166 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 167 | goto end 168 | ) 169 | 170 | if "%1" == "latexpdfja" ( 171 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 172 | cd %BUILDDIR%/latex 173 | make all-pdf-ja 174 | cd %~dp0 175 | echo. 176 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 177 | goto end 178 | ) 179 | 180 | if "%1" == "text" ( 181 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 182 | if errorlevel 1 exit /b 1 183 | echo. 184 | echo.Build finished. The text files are in %BUILDDIR%/text. 185 | goto end 186 | ) 187 | 188 | if "%1" == "man" ( 189 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 190 | if errorlevel 1 exit /b 1 191 | echo. 192 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 193 | goto end 194 | ) 195 | 196 | if "%1" == "texinfo" ( 197 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 198 | if errorlevel 1 exit /b 1 199 | echo. 200 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 201 | goto end 202 | ) 203 | 204 | if "%1" == "gettext" ( 205 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 206 | if errorlevel 1 exit /b 1 207 | echo. 208 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 209 | goto end 210 | ) 211 | 212 | if "%1" == "changes" ( 213 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 214 | if errorlevel 1 exit /b 1 215 | echo. 216 | echo.The overview file is in %BUILDDIR%/changes. 217 | goto end 218 | ) 219 | 220 | if "%1" == "linkcheck" ( 221 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 222 | if errorlevel 1 exit /b 1 223 | echo. 224 | echo.Link check complete; look for any errors in the above output ^ 225 | or in %BUILDDIR%/linkcheck/output.txt. 226 | goto end 227 | ) 228 | 229 | if "%1" == "doctest" ( 230 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 231 | if errorlevel 1 exit /b 1 232 | echo. 233 | echo.Testing of doctests in the sources finished, look at the ^ 234 | results in %BUILDDIR%/doctest/output.txt. 235 | goto end 236 | ) 237 | 238 | if "%1" == "coverage" ( 239 | %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage 240 | if errorlevel 1 exit /b 1 241 | echo. 242 | echo.Testing of coverage in the sources finished, look at the ^ 243 | results in %BUILDDIR%/coverage/python.txt. 244 | goto end 245 | ) 246 | 247 | if "%1" == "xml" ( 248 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 249 | if errorlevel 1 exit /b 1 250 | echo. 251 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 252 | goto end 253 | ) 254 | 255 | if "%1" == "pseudoxml" ( 256 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 257 | if errorlevel 1 exit /b 1 258 | echo. 259 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 260 | goto end 261 | ) 262 | 263 | :end 264 | -------------------------------------------------------------------------------- /docs/new-features.rst: -------------------------------------------------------------------------------- 1 | New Features 2 | ************ 3 | 4 | As said before, TeaScript is an *extension* of JavaScript meaning it adds features to JavaScript. Here you will learn about some of the features TeaScript 5 | adds to JavaScript 6 | 7 | Modified RegExp 8 | =============== 9 | 10 | RegExp literals have been expanded and are now more powerful than ever with custom character classes and hopefully even more features to come. 11 | 12 | Custom Character Classes 13 | ------------------------ 14 | 15 | TeaScript adds custom character classes (e.g. ``\w``) to a RegExp literal. These are esentially shorthands for character classes, an example 16 | 17 | .. code-block:: js 18 | 19 | /[A-Za-z]/ // Before 20 | /\L/ // After 21 | /[A-Za-z]/ // At compile-time 22 | 23 | .. topic:: New Character Classes 24 | :name: charclasslist 25 | 26 | ======= ============ 27 | Name Value 28 | ======= ============ 29 | ``\\A`` ``[A-Z]`` 30 | ``\\a`` ``[a-z]`` 31 | ``\\L`` ``[A-Za-z]`` 32 | ``\\N`` ``[A-Za-z0-9]`` 33 | ======= ============ 34 | 35 | Operators 36 | ========= 37 | 38 | # Operator 39 | ---------- 40 | 41 | The ``#`` operator is one that is *very* useful. It's a shorthand for function declerations that you can use where ever. ``#`` expands to ``(l,i,a,b)=>`` 42 | 43 | .. code-block:: js 44 | 45 | (a,b,c,d)=>a+b+c+d // Before 46 | #l+i+a+b // After 47 | 48 | @ Operator 49 | ---------- 50 | 51 | The ``@`` operator is similar to the ``#`` operator, but if you ever have two nested lambdas, you can use this. ``@`` expands to ``(q,r,s,t)=>q.`` 52 | 53 | .. code-block:: js 54 | 55 | (a,b,c,d)=>aT2)+b+d // Before 56 | @T2)+r+t // After 57 | 58 | .. _f-operator: 59 | 60 | ƒ Operator 61 | ---------- 62 | 63 | ``ƒ`` expands to ``f=(l,i,a,b)=>``, this can be used to create recursive functions easily without having to manually add a decleration 64 | 65 | .. code-block:: js 66 | 67 | f=(a,b)=>a<1?b:f(a--,b++); // Before 68 | ƒl<1?i:f(l--,i++); // After 69 | 70 | Σ Operator 71 | ---------- 72 | 73 | The ``Σ`` operator can be used to loop through arrays and strings, it expands to ``.l((l,i,a,b)=>``. 74 | 75 | .. code-block:: js 76 | 77 | xΣlc // Maps char codes 78 | xΣi // Generates range 79 | 80 | 81 | 82 | ? Operator 83 | ---------- 84 | 85 | This operator has 2 uses depending on where you use it. 86 | 87 | .. rubric:: Interrupting Property expansion 88 | 89 | If you ever need to use a JavaScript property name and TeaScript thinks it's a TeaScript property, insert a ``?`` after the property 90 | 91 | .. code-block:: js 92 | 93 | x.search(/\A/) // JavaScript 94 | x.search?/\A // TeaScript 95 | 96 | .. rubric:: Closing Parenthesis 97 | 98 | .. code-block:: js 99 | 100 | xl(#lT(2r("foo"[1]))) // Before 101 | xl(#lT(2r("foo"[1? // After -------------------------------------------------------------------------------- /docs/variables.rst: -------------------------------------------------------------------------------- 1 | Variables 2 | ********* 3 | 4 | TeaScript has many variables which are pre-initalized to various values but you can also use them for custom variables: 5 | 6 | Assignment 7 | ========== 8 | 9 | To assign a variable you can easier use a shorthand or the native JavaScript ways. 10 | 11 | Shorthands 12 | ---------- 13 | 14 | .. rubric:: Using ƒ 15 | 16 | This can be used to assign functions both recursive and not. To learn more about this operator, see :ref:`f-operator`. 17 | 18 | .. code-block:: js 19 | 20 | f=(l,i)=>l<1?i:f(l--,i++) // Before 21 | ƒl<1?i:l--:i++ // After 22 | 23 | f=l=>{for(i=0;i=", 156 | "≤": "<=", 157 | "»": "=>", 158 | "¬": "!=", 159 | "⌐": "==", 160 | "║": "||", 161 | "‼": "!!", 162 | "·": "&&", 163 | "┼": "++", 164 | "─": "--", 165 | 166 | "ƒ": "f=(l,i,a,b)=>", 167 | "≡": "===", 168 | "¿": " ?", 169 | "Σ": ".l((l,i,a,b)=>", 170 | "√": "M.s(", 171 | "π": "(3.14159265358979323846)", 172 | "Φ": "(1.61803398874989484820)" 173 | }, 174 | "def": { 175 | "Globals": "window[$1]", 176 | "Prototype": "window[$1].prototype", 177 | "Subglobals": "window[$1]", 178 | "Other": "eval($1)" 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /src/sh/sh.js: -------------------------------------------------------------------------------- 1 | var shoco={compress:String,decompress:String}; 2 | var babel={transform:s=>s}; 3 | var console={warn:print,log:print,error:print}; 4 | -------------------------------------------------------------------------------- /src/sh/teascript: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ ! -d "TeaScript" ]; then 3 | echo "TeaScript not installed. Installing TeaScript..." 4 | mkdir TeaScript 5 | wget -O TeaScript/macros.js https://raw.githubusercontent.com/vihanb/TeaScript/master/macros.js 6 | wget -O TeaScript/props.json https://github.com/vihanb/TeaScript/blob/master/props.json 7 | wget -O TeaScript/teascript.js https://github.com/vihanb/TeaScript/blob/master/v/2/teascript.js 8 | sed -i -e 's/window/this/g' -e 's/\/\*props\.json\*\//JSON.parse(read("props.json"))/g' TeaScript/teascript.js 9 | printf "var shoco={},babel={transform:String},console={warn:print,log:print,error:print}" > TeaScript/sh.js 10 | fi 11 | cd TeaScript; 12 | read -p "Code: " Code 13 | read -p "Input: " Input 14 | js -f sh.js macros.js teascript.js -e "print(TeaScript(\`${Code//\`/\\\`}\`,\"${Input//,/","}\",{}).out)" 15 | -------------------------------------------------------------------------------- /src/sh/teascript_run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | read code; read input; 3 | js -f sh.js macros.js teascript.js -e "print(TeaScript(\`${code//\`/\\\`}\`,\"${input//,/","}\",{}).out)" 4 | -------------------------------------------------------------------------------- /src/v1/teascript.js: -------------------------------------------------------------------------------- 1 | /* Uses babeljs (babeljs.io) to make ES7 -> ES5 */ 2 | 3 | /* Define new built-ins */ 4 | Array.range = function range (n, m) { 5 | return Array((m||n+n)-n).join().split(',').map(function (_, i) { 6 | return (m ? n : 0) + i; 7 | }); 8 | }; 9 | 10 | Array.prototype.cycle = function cycle (int) { 11 | return this.slice(-int) + this.slice(0, -int); 12 | }; 13 | 14 | String.prototype.g_replace = function g_replace (a,b, flag) { 15 | return this.replace( new RegExp(a, 'g' + (flag || '')), b ) 16 | }; 17 | 18 | String.prototype.reverse = function reverse () { 19 | return this.split('').reverse().join(''); 20 | }; 21 | 22 | String.prototype.batchReplace = function batchReplace (form) { 23 | return form.match(/../g).reduce(function (old, format) { 24 | return old.replace( new RegExp('\\'+format[0], 'g'), format[1] ); 25 | }, this); 26 | }; 27 | 28 | String.prototype.loop = function loop (func, delimiter) { 29 | return this.split(delimiter || '').map(func).join(delimiter || ''); 30 | }; 31 | 32 | String.prototype.reduce = function reduce (func, start) { 33 | return this.split('').reduce(func, start || this) 34 | }; 35 | 36 | String.prototype.head = function head (int) { 37 | return this.slice(0, int); 38 | }; 39 | 40 | String.prototype.cycle = function cycle (int) { 41 | return this.slice(-int) + this.slice(0, -int); 42 | }; 43 | 44 | String.prototype.isUpper = function isUpper () { 45 | return /[A-Z]/.test(this); 46 | }; 47 | 48 | String.prototype.isLower = function isLower () { 49 | return /[a-z]/.test(this); 50 | }; 51 | 52 | String.prototype.isDigit = function isDigit() { 53 | return /[0-9]/.test(this); 54 | }; 55 | 56 | String.prototype.alphanum = function alphanum () { 57 | return /[A-Za-z]/.test(this) ? [1, 58 | /[A-Z]/.test(this) ? 59 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" : 60 | "abcdefghijklmnopqrstuvwxyz"] 61 | : /[0-9]/.test(this) ? [2, "0123456789"] 62 | : [0, this] 63 | }; 64 | 65 | String.prototype.sort = function sort() { 66 | return this.split``.sort().join``; 67 | } 68 | 69 | Math.Fib = function Fib (n) { 70 | if (n <= 1) 71 | return n; 72 | return Math.Fib(n-1) + Math.Fib(n-2); 73 | } 74 | 75 | Math.prime = function prime (number) { 76 | var start = 2; 77 | while (start <= Math.sqrt(number)) { 78 | if (number % start++ < 1) return false; 79 | } 80 | return number > 1; 81 | } 82 | 83 | function addItem (a,b) { 84 | document.getElementById('cheat').innerHTML += a+" -> "+b+"
"; 85 | } 86 | 87 | String.Y = "0123456789"; 88 | String.z = "abcdefghijklmnopqrstuvwxyz"; 89 | String.Z = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 90 | 91 | var rules = { 92 | "Math": { 93 | 'p': 'pow', 94 | 'P': 'prime', 95 | 'h': 'hypot', 96 | 's': 'sqrt', 97 | 'a': 'abs', 98 | 'r': 'random', 99 | 'F': 'Fib' 100 | }, 101 | "String": { 102 | 'c': 'fromCharCode' 103 | }, 104 | "Array": { 105 | 'r': 'range' 106 | } 107 | }, proto = { 108 | "String": { 109 | 'B': 'batchReplace', 110 | 'c': 'charCodeAt', 111 | 'C': 'cycle', 112 | 'd': 'reduce', 113 | 'g': 'g_replace', 114 | 'h': 'head', 115 | 'i': 'indexOf', 116 | 'L': 'toLowerCase', 117 | 'l': 'loop', 118 | 'm': 'match', 119 | 'n': 'length', 120 | 'N': 'alphanum', 121 | 'r': 'replace', 122 | 'R': 'repeat', 123 | 's': 'split', 124 | 'S': 'slice', 125 | 'u': 'toUpperCase', 126 | 'v': 'reverse', 127 | 'Y': 'isDigit', 128 | 'z': 'isLower', 129 | 'Z': 'isUpper' 130 | }, 131 | "Array": { 132 | 'C': 'cycle', 133 | 'f': 'fill', 134 | 'i': 'indexOf', 135 | 'j': 'join', 136 | 'k': 'keys', 137 | 'm': 'map', 138 | 'r': 'reverse', 139 | 'R': 'reduce' 140 | } 141 | }, getters = { 142 | 'RegExp': { 143 | 't': 'test' 144 | }, 145 | 'Date': { 146 | 'n': 'now' 147 | }, 148 | 'Math': { 149 | 'R': 'random' 150 | } 151 | }, gettersProto = { 152 | 'String': { 153 | 'O': 'toLowerCase', 154 | 'U': 'toUpperCase', 155 | 'x': 'isLower', 156 | 'X': 'isUpper', 157 | 'y': 'isDigit' 158 | }, 159 | 'Array': { 160 | 'R': 'reverse', 161 | 'S': 'sort' 162 | } 163 | }, enviorment = { 164 | '$': 'Math', 165 | 'S': 'String', 166 | 'A': 'Array', 167 | 'e': 'eval', 168 | 'R': 'RegExp', 169 | 'D': 'Date' 170 | }, noinf = { 171 | 'C': String.fromCharCode, 172 | 'F': Math.Fib, 173 | 'a': Math.abs, 174 | 'r': Array.range 175 | }; 176 | 177 | Object.keys(rules).forEach(function (global) { 178 | Object.keys(rules[global]).forEach(function (prop) { 179 | window[global][prop] = window[global][ rules[global][prop] ]; 180 | addItem(global+'.'+prop, global + '.' + rules[global][prop]); 181 | }); 182 | }); 183 | 184 | Object.keys(proto).forEach(function (global) { 185 | Object.keys(proto[global]).forEach(function (prop) { 186 | window[global].prototype[prop] = window[global].prototype[ proto[global][prop] ] 187 | addItem(global + '.prototope.' + prop, global + '.prototype.' + proto[global][prop]); 188 | }); 189 | }); 190 | 191 | Object.keys(getters).forEach(function (global) { 192 | Object.keys(getters[global]).forEach(function (prop) { 193 | window[global].__defineGetter__(prop, eval('function() { return ' + global + '.' + getters[global][prop] + '() }')); 194 | addItem(global + '.' + prop, global + '.' + getters[global][prop] + '()'); 195 | }); 196 | }); 197 | 198 | Object.keys(gettersProto).forEach(function (global) { 199 | Object.keys(gettersProto[global]).forEach(function (prop) { 200 | window[global].prototype.__defineGetter__(prop, eval('function() { return this.' + gettersProto[global][prop] + '() }')); 201 | addItem(global + '.prototope.' + prop, global + '.prototype.' + gettersProto[global][prop] + '()'); 202 | }); 203 | }); 204 | 205 | Object.keys(enviorment).forEach(function (global) { 206 | window[global] = window[enviorment[global]]; 207 | addItem(global, enviorment[global]); 208 | }); 209 | 210 | Object.keys(noinf).forEach(function (global) { 211 | if (!window[global]) 212 | window[global] = noinf[global]; 213 | else 214 | console.warn("Could not map " + global); 215 | addItem(global, noinf[global].name); 216 | }); 217 | 218 | var TeaScript = function (code, input, rep) { 219 | 220 | // x=y=z= makes y and z global... does that matter? 221 | var b=c=d=""; 222 | var s=g=h=[]; 223 | var i=j=k={}; 224 | var l = String.Y; 225 | var m = String.z; 226 | var n = String.Z; 227 | var o=p=q=0; 228 | // could do anything more with these? 229 | var f = false; // probably useless... ? 230 | var t = true; 231 | var u=v=w=0; 232 | 233 | Object.keys(rep).map(function (key) { 234 | code = code.replace(new RegExp(key, 'g'), rep[key]); 235 | }); 236 | 237 | window['_'] = input; 238 | window['x'] = document.getElementById('int').checked ? +input[0] : input[0]; 239 | window['y'] = document.getElementById('int').checked ? +input[1] : input[1]; 240 | window['z'] = document.getElementById('int').checked ? +input[2] : input[2]; 241 | 242 | var b = babel.transform(code 243 | .replace(/([(,=])#/g,'$1(l,i,a)=>') 244 | .replace(/\(([^)#]+?)#(\d|[A-Za-z])/g,'($1)[$2]') 245 | .replace(/([xliaS$)])([A-Za-z0-9])(?=[(:.+,)]|$)/g,'$1["$2"]') 246 | , { stage: 0 }).code; 247 | console.log(b); 248 | return eval(b); 249 | }; 250 | -------------------------------------------------------------------------------- /src/v2/teascript.js: -------------------------------------------------------------------------------- 1 | (function (global, data) { 2 | 3 | var TeaScript = function (code, inputs, opts, plug) { 4 | 5 | var TEASCRIPT_ENV = false; 6 | 7 | // Reduced Prop names 8 | var _props = Object.keys(data.macros), // Global name 9 | _maps = { g: global }; // Global maps 10 | 11 | /* Enviorment Generation */ 12 | _props.forEach(function (name) { 13 | _maps.$$ = name; // Store current property name 14 | _maps.$_ = data.macros[ name ]; // Store current macro name 15 | 16 | Object.keys( _maps.$_ ).forEach(function ( key ) { 17 | // Reference some important information to private variables 18 | var _key = _maps.$_[key], 19 | _loc = 'return ' + data.def[ _maps.$$ ].replace(/\$/g, "this.$"), // Hacky way of restricting scope 20 | _val; 21 | 22 | _maps.$1 = _key; // Store key for first depth 23 | 24 | if (typeof _key === "object") { 25 | 26 | Object.keys( _key ).forEach(function ( prop ) { 27 | _maps.$1 = key; 28 | 29 | // Lovely try..catch syntax 30 | try { 31 | _val = new Function(_loc).call(_maps); // Attempt to locate specified path for property 32 | 33 | if ( _val) { 34 | if ( !_val[ prop ] || !TEASCRIPT_ENV ) // Error handling for duplicate property names 35 | _val[ prop ] = _val[ _key[prop] ]; 36 | else 37 | console.warn("Enviorment Error: Existing subglobal: Slot used:"); 38 | } 39 | } catch (e) { 40 | console.warn("Enviorment Error: Invalid location " + _maps.$$ + ", error " + e); 41 | } 42 | }); 43 | 44 | } else if (typeof _key === "string") { 45 | try { 46 | _val = new Function(_loc).call(_maps); 47 | if ( _val ) { 48 | if ( !global[ key ] || !TEASCRIPT_ENV ) 49 | global[ key ] = _val; 50 | else 51 | console.warn("Enviorment Error: Existing Global: Slot used"); 52 | } 53 | } catch (e) { 54 | _val = null; 55 | console.warn("Enviorment Error: Invalid location " + _maps.$$ + ", error " + e); 56 | } 57 | } else { 58 | console.warn("Unexpected Type: " + _key + " at " + key); 59 | } 60 | }); 61 | }); 62 | 63 | // Getters 64 | var _getters = Object.keys( data.getters ), 65 | _path = { g: global }; 66 | 67 | _getters.forEach(function (getter) { 68 | _path.$1 = global[ getter ]; 69 | _path.$_ = data.getters[ getter ]; 70 | 71 | Object.keys( _path.$_ ).forEach(function (item) { 72 | // Note current depth 73 | var _key = _path.$_[ item ], 74 | _val; 75 | 76 | if (typeof _key === "object") { 77 | _path.$2 = _path.$1[ item ]; 78 | 79 | Object.keys( _key ).forEach(function ( prop ) { 80 | (function ( _val ){ 81 | if ( !_path.$2[ prop ] || !TEASCRIPT_ENV ) { 82 | try { 83 | Object.defineProperty(_path.$2, prop , { 84 | get: function () { return this[ _val ](); }, 85 | configurable: true 86 | }); 87 | } catch (e) { 88 | console.warn("Enviorment Error: Duplicate Getter: " + e); 89 | } 90 | } else { 91 | console.warn("Enviorment Error: Existing Sub Getter: Slot Used"); 92 | } 93 | }( _key[prop] )) 94 | }); 95 | 96 | } else if (typeof _key === "string") { 97 | if ( !_path.$1[ item ] || !TEASCRIPT_ENV ) { 98 | try { 99 | Object.defineProperty(_path.$1, item , { 100 | get: function () { return this[ _key ](); }, 101 | configurable: true 102 | }); 103 | } catch (e) { 104 | console.warn("Enviorment Error: Duplicate Getter: " + e); 105 | }; 106 | } else { 107 | console.warn("Enviorment Error: Existing Getter: Slot Used"); 108 | } 109 | } else { 110 | console.warn("Unexpected Type: " + _key + " at " + item); 111 | } 112 | 113 | }); 114 | 115 | }); 116 | 117 | TEASCRIPT_ENV = true; // Avoid duplicate enviorment generation 118 | 119 | /* Transpile */ 120 | var INF = { comp: code, out: "", // Compile data 121 | ex: null, safe: [], 122 | gen: code}; 123 | 124 | // Intermedite Compilation 125 | 126 | if (opts.chars === false) { 127 | INF.comp = Object.keys( data.rep ).reduce(function (cmp, key) { 128 | return cmp.replace( new RegExp(key, 'g'), data.rep[ key ] ) 129 | }, INF.comp) || ""; 130 | } 131 | 132 | INF.gen = INF.comp; 133 | 134 | INF.comp = 135 | INF.comp 136 | // .replace(/([A-Za-z])([\/#])/g, "$1($2$3") // ( 137 | .replace(/([(,=])#/g,'$1(l,i,a,b)=>') // => 138 | .replace(/(?![\\#]|^)\[(?!")([^\]]+)\]/g,".G($1)") 139 | // .replace(/([lia_c])(\d)([ :,)+=?\-*\\\/%])/, "$1[$2]$3") // [n] 140 | // Very long RegExp attempting to handle (most) cases to avoid periods. Will perfect in TeaScript 3 141 | .replace(/((?:[^A-Za-z]|^)[xyzliaLIASX_]|[\])$/'"])([A-Za-z])(?=[`\[(:.+,)<>?:/ *-=\|]|$)/g,'$1["$2"]') 142 | .replace(/([abcdfghijklmnopqrstuvwxyz)])([0-9])(?=[(><=),])/gi, '$1[$2]') 143 | 144 | // Babel Transpilation 145 | if (babel) { 146 | try { 147 | INF.comp = babel.transform(INF.comp, { 148 | loose: opts.loose 149 | }).code; 150 | } catch (e) { 151 | INF.ex = e; 152 | } 153 | } else { 154 | console.warn("Dependency not found: babel"); 155 | return "An error occured during compiling."; 156 | } 157 | 158 | /* Execution */ 159 | 160 | // Allocate reserved variables 161 | var _free = { 162 | 'cdghijklmosuvw': 0, 163 | 'f': false, 164 | 'n': 10, 165 | 't': true, 166 | 'b': '', 167 | 'p': ' ', 168 | 'q': [] 169 | }; 170 | 171 | Object.keys( _free ).forEach(function (letters) { 172 | letters.split('').forEach(function (chars) { 173 | //if ( !global[chars] ) { 174 | global[chars] = _free[letters]; 175 | INF.safe.push(chars); 176 | //} 177 | }); 178 | }); 179 | 180 | // Input Variables 181 | if (opts.ar) inputs = (/^[\(\[\{][\S\s]+[\)\]\}]$/.test(inputs[0]) ? inputs[0].slice(1, -1) : inputs[0]).split(","); 182 | if (opts.int) inputs = inputs.map(function(input) { return input instanceof Array ? input.map(Number) : +input }); 183 | 184 | global.x = inputs[0]; 185 | global.y = inputs[1]; 186 | global.z = inputs[2]; 187 | global._ = inputs; 188 | 189 | // Run 190 | if (!INF.ex) { 191 | try { 192 | INF.out = eval(INF.comp); 193 | } catch (er) { 194 | INF.ex = er; 195 | } 196 | } 197 | 198 | return INF; 199 | }; 200 | 201 | /* Globals */ 202 | TeaScript.Golf = function (code, args) { 203 | return Object.keys( data.rep ).reduce(function (cmp, key) { 204 | return cmp.split( args ? key : data.rep[ key ] ).join( args ? data.rep[ key ] : key ); 205 | }, code); 206 | }; 207 | 208 | TeaScript.Data = data; 209 | 210 | global.TeaScript = TeaScript; 211 | 212 | }(window/*, props.json*/)); -------------------------------------------------------------------------------- /src/v3/teascript.es6: -------------------------------------------------------------------------------- 1 | //// 2 | // 3 | // TeaScript 3 - Compiler 4 | // (c) Vihan 2015 5 | // 6 | //// 7 | 8 | (function(global) { 9 | const TeaScript = (Code, Data = { rep: {} }) => { 10 | /// 11 | // 12 | // TeaScript 3 13 | // Compiler Process: 14 | // 15 | // - Generate Enviorment 16 | // - Quote Balancing 17 | // - Unicode Shortcuts 18 | // - Property Expansion 19 | // - Operator Overloading 20 | // - Fix parenthesis 21 | // - Decompress strings 22 | /// 23 | 24 | const GenerationData = { 25 | steps: { 26 | reps: "", 27 | parenfix: "" 28 | }, 29 | Error: "" 30 | }; 31 | 32 | const Warn = desc => GenerationData.Error += `Error: ${desc}.\n`; 33 | const Error = desc => GenerationData.Error += `Critical Error: ${desc}.\n`; 34 | 35 | // CONSTANTS 36 | const MAX_LITERAL = 65536; // 2^16 37 | 38 | const ESCAPES = [ 39 | [`"`,`"`,`\\`], 40 | [`'`,`'`,`\\`], 41 | [`/`,`/`,`\\`], 42 | ["`","`",`\\`], 43 | ]; 44 | const ESCAPES_START = ESCAPES.map(Escape => Escape[0]); 45 | const ESCAPES_END = ESCAPES.map(Escape => Escape[1]); 46 | const ESCAPES_ESC = ESCAPES.map(Escape => Escape[2]); 47 | const ESCAPES_KEEP = ESCAPES.map(Escape => !Escape[3]); 48 | 49 | const COMMENT = [ 50 | [`//`, `\n`], 51 | [`/*`, `*/`] 52 | ]; 53 | 54 | const CLOSE = [ 55 | [`[`, `]`], 56 | [`(`, `)`], 57 | ]; 58 | 59 | const CLOSE_START = CLOSE.map(Item => Item[0]); 60 | const CLOSE_END = CLOSE.map(Item => Item[1]); 61 | 62 | const MATCH_PROP = /[A-Za-z$_][\w$]*/; 63 | const MATCH_NUM = /\d/; 64 | const MATCH_LTRL = /["'`0-9]/; // Literal 65 | const MATCH_LEND = /["'`0-9)/\]]/; // Match any end 66 | const MATCH_STRT = /["'`0-9(#@/ßα+=*/]/; 67 | const MATCH_END = /[)\]]/; 68 | const MATCH_DIV = /[\d\w\/\\`"'\)@$.]/; 69 | 70 | const RESERVED = [`for`, `while`, `let`, `var`, `if`, `const`, `break`, `continue`, `class`, `do`]; 71 | 72 | const REGEX_FLAG = /[gmi]+/; 73 | const REGEX_CLASS = new Map([ 74 | ["A", "[A-Z]"], 75 | ["a", "[a-z]"], 76 | ["L", "[A-Za-z]"], 77 | ["N", "[A-Za-z0-9]"] 78 | ]); 79 | 80 | // Keys 81 | const KEY_POLYGLOT = `[p|`; 82 | const KEY_QUINE = `[q|`; 83 | 84 | /*=== START CODE ===*/ 85 | let DEFINITIONS = new Map(); 86 | 87 | // Unicode Shortcuts & Prop Expansion 88 | { 89 | let EscapeChar = -1; 90 | let PendingProp = ""; 91 | let Definition = 0; // 1, Key, 2, Value 92 | let DefinitionItem = ["", ""]; 93 | for (let i = 0; i < Code.length; i++) { 94 | if (Definition) { 95 | if (Code[i] === "\\") { 96 | // End escape sequence 97 | DEFINITIONS.set(...DefinitionItem); 98 | GenerationData.steps.reps += DefinitionItem[1]; 99 | Definition = 0; 100 | DefinitionItem = ["", ""]; 101 | } else { 102 | if (Code[i] === "=") { 103 | Definition = 2; 104 | } else if (Definition === 1) { 105 | DefinitionItem[0] += Code[i]; 106 | } else if (Definition === 2) { 107 | DefinitionItem[1] += Code[i]; 108 | } 109 | } 110 | } 111 | /* Disable Definitions? 112 | else if (Code[i] === "\\") { 113 | 114 | Definition = 1; 115 | 116 | } // */ 117 | else if ([...DEFINITIONS.keys()].some(DEF => Code.slice(i).indexOf(DEF) === 0)) { 118 | let DEFV = [...DEFINITIONS.keys()].filter(DEF => Code.slice(i).indexOf(DEF) === 0).sort((a,b) => b.length - a.length)[0]; 119 | GenerationData.steps.reps += DEFINITIONS.get(DEFV); 120 | i += DEFV.length - 1; 121 | } else if (PendingProp.length > 0) { // Within a property name 122 | if (MATCH_PROP.test(Code[i])) { 123 | PendingProp += Code[i]; 124 | if (i === Code.length - 1) GenerationData.steps.reps += PendingProp.replace(/(?!^|$)/g, "."); 125 | } else { 126 | let _prop = PendingProp; 127 | PendingProp = ""; 128 | if (Code[i] === "\\") { 129 | GenerationData.steps.reps += _prop + "("; 130 | } else { 131 | if ((MATCH_STRT.test(Code[i]) || MATCH_END.test(Code[i])) && !RESERVED.includes(_prop)) { 132 | GenerationData.steps.reps += _prop.replace(/(?!^|$)/g, "."); 133 | if (Code[i] !== "(" && Code[i] !== ")" && Code[i] !== "`") GenerationData.steps.reps += "("; 134 | } else { 135 | GenerationData.steps.reps += _prop; 136 | } 137 | i--; 138 | } 139 | } 140 | } else { 141 | if (COMMENT.some(Start => Code.slice(i, i + Start[0].length) === Start[0])) { // Comment 142 | let Comment = COMMENT.find(Start => Code.slice(i, i + Start[0].length) === Start[0]); 143 | i += Comment[0].length; 144 | for (let j = i; (i - j) < MAX_LITERAL && Code[i] && Code.slice(i, i + Comment[1].length) !== Comment[1]; i++); 145 | } else if (Code.slice(i).indexOf(`"`+KEY_POLYGLOT) === 0) { // Start Polygot 146 | let CollectedCode = ""; 147 | i++; 148 | for (let j = i; (i - j) < MAX_LITERAL && Code[i] !== '"'; i++) { 149 | CollectedCode += Code[i]; 150 | if (!Code[i + 1]) break; 151 | } 152 | GenerationData.steps.reps = CollectedCode.slice(KEY_POLYGLOT.length); 153 | i = Code.length; 154 | } else if (Code.slice(i).indexOf(KEY_QUINE) === 0) { 155 | let CollectedCode = ""; 156 | i++; 157 | for (let j = i; (i - j) < MAX_LITERAL && Code[i] !== ']'; i++) { 158 | CollectedCode += Code[i]; 159 | if (!Code[i + 1]) break; 160 | } 161 | GenerationData.steps.reps = `v="${Code.replace(/\\/,"\\\\").replace(/"/, `\\"`)}";`+ 162 | TeaScript(`\`${Code.replace(/\\/g,"\\\\").replace(/`/g,"\\`")}\`` + CollectedCode.slice(KEY_QUINE.length)).steps.parenfix; 163 | i = Code.length; 164 | } else if (Code[i] === "/" && !MATCH_DIV.test([...Code.slice(0,i)].reverse().join("").trim()||"")) { // Start custom RegExps 165 | GenerationData.steps.reps += "/"; 166 | i++; 167 | console.log("REGEX STARTED") 168 | for (let j = i; (i - j) < MAX_LITERAL && Code[i] !== "/"; i++) { 169 | if (Code[i] === "\\") { 170 | if (REGEX_CLASS.has(Code[i + 1])) 171 | GenerationData.steps.reps += REGEX_CLASS.get(Code[i++ + 1]); 172 | else 173 | GenerationData.steps.reps += "\\" + Code[++i]; 174 | } else { 175 | GenerationData.steps.reps += Code[i]; 176 | } 177 | if (!Code[i + 1]) Code += "/"; 178 | if (i - j + 1 === MAX_LITERAL) Warn("Approaching Literal Maximum"); 179 | } 180 | GenerationData.steps.reps += "/"; 181 | 182 | // Hacky way of allowing flags 183 | if (!Code.slice(++i).search(REGEX_FLAG)) { // There are flags 184 | GenerationData.steps.reps += Code.slice(i).match(REGEX_FLAG)[0]; 185 | i += Code.slice(i).match(REGEX_FLAG)[0].length; 186 | } 187 | --i; 188 | } else if ( Code[i] === "/" ? !MATCH_DIV.test([...Code.slice(0,i)].reverse().join("").trim()||"") : 189 | ESCAPES_START.includes(Code[i])) { // Found an escape character (string) 190 | EscapeChar = ESCAPES_START.indexOf(Code[i]); 191 | if (ESCAPES_KEEP[EscapeChar]) GenerationData.steps.reps += Code[i]; 192 | i++; 193 | for (let j = i; (i - j) < MAX_LITERAL && Code[i] !== ESCAPES_END[EscapeChar]; i++) { 194 | if (Code[i] === ESCAPES_ESC[EscapeChar]) { 195 | if (ESCAPES_KEEP[EscapeChar]) GenerationData.steps.reps += ESCAPES_ESC[EscapeChar]; 196 | GenerationData.steps.reps += Code[++i]; 197 | } else { 198 | GenerationData.steps.reps += Code[i]; 199 | } 200 | if (!Code[i + 1]) Code += ESCAPES_END[EscapeChar]; 201 | if (i - j + 1 === MAX_LITERAL) Warn("Approaching Literal Maximum"); 202 | } 203 | if (ESCAPES_KEEP[EscapeChar]) GenerationData.steps.reps += Code[i]; 204 | } else if (MATCH_PROP.test(Code[i])) { // Property character 205 | if (MATCH_LEND.test(Code[i - 1])) GenerationData.steps.reps += "."; 206 | if (Code[i + 1]) PendingProp += Code[i]; 207 | else GenerationData.steps.reps += Code[i]; 208 | } else if (Code[i] === "#") { // # Operator 209 | GenerationData.steps.reps += `(l,i,a,b)=>`; 210 | } else if (Code[i] === "@") { // @ Operator 211 | GenerationData.steps.reps += `(q,r,s,t)=>q.`; 212 | } else if (MATCH_NUM.test(Code[i])) { // Number 213 | for (let j = i; (i - j) < MAX_LITERAL && /[\d.]/.test(Code[i]); i++) GenerationData.steps.reps += Code[i]; 214 | GenerationData.steps.reps += " "; --i; 215 | } else if (Data.rep.hasOwnProperty(Code[i])) { // Unicode char 216 | GenerationData.steps.reps += Data.rep[Code[i]]; 217 | } else { // Other 218 | GenerationData.steps.reps += Code[i] 219 | } 220 | } 221 | } 222 | } 223 | // RESERVED: liabxyz_ 224 | 225 | // Adjusts parenthesis 226 | { 227 | const Code_1 = GenerationData.steps.reps; 228 | 229 | let NestOrder = []; 230 | let EscapeChar = -1; 231 | for (let i = 0; i < Code_1.length; i++) { 232 | if (Code_1[i] === "/" ? !MATCH_DIV.test([...Code_1.slice(0,i)].reverse().join("").trim()||"") : 233 | ESCAPES_START.includes(Code_1[i])) { // Found an escape character (string) 234 | EscapeChar = ESCAPES_START.indexOf(Code_1[i]); 235 | if (ESCAPES_KEEP[EscapeChar]) GenerationData.steps.parenfix += Code_1[i]; 236 | i++; 237 | for (let j = i; (i - j) < MAX_LITERAL && Code_1[i] !== ESCAPES_END[EscapeChar]; i++) { 238 | if (Code_1[i] === ESCAPES_ESC[EscapeChar]) { 239 | if (ESCAPES_KEEP[EscapeChar]) GenerationData.steps.parenfix += ESCAPES_ESC[EscapeChar]; 240 | GenerationData.steps.parenfix += Code_1[++i]; 241 | } else { 242 | GenerationData.steps.parenfix += Code_1[i]; 243 | } 244 | if (i - j + 1 === MAX_LITERAL) Warn("Approaching Literal Maximum"); 245 | } 246 | if (ESCAPES_KEEP[EscapeChar]) GenerationData.steps.parenfix += Code_1[i]; 247 | } else if (CLOSE_START.includes(Code_1[i])) { // Open 248 | GenerationData.steps.parenfix += Code_1[i]; 249 | NestOrder.push(Code_1[i]); 250 | } else if (CLOSE_END.includes(Code_1[i])) { // Close 251 | GenerationData.steps.parenfix += Code_1[i]; 252 | NestOrder.pop(); 253 | } else { 254 | GenerationData.steps.parenfix += Code_1[i]; 255 | } 256 | } 257 | NestOrder.reverse().forEach(Key => GenerationData.steps.parenfix += CLOSE_END[CLOSE_START.indexOf(Key)]); 258 | } 259 | 260 | return GenerationData; 261 | }; 262 | 263 | if (global.TeaScript) global.TeaScript.Compile = TeaScript; 264 | else global.TeaScript = TeaScript; 265 | }(window/*, JSON.parse(read("props.json"))*/)); 266 | --------------------------------------------------------------------------------