Skip to content

Instantly share code, notes, and snippets.

@jlturner
Created November 16, 2015 20:50
Show Gist options
  • Save jlturner/204082d98fbcf5ee07a7 to your computer and use it in GitHub Desktop.
Save jlturner/204082d98fbcf5ee07a7 to your computer and use it in GitHub Desktop.
Tiny Demo w/ touch events (Nov 16, 2015)
<!DOCTYPE html>
<html>
<head>
<style>
body {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
align-items: bottom;
justify-content: center;
}
canvas {
-webkit-scroll-snap-coordinate:0%0%;
}
html, body, canvas {
-webkit-scroll-snap-type: mandatory;
margin:0px;
padding:0px;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
cursor: default;
background-color: black;
}
</style>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
</head>
<script type="text/tiny">
$init = {
color(3)
clear()
$ball_size = [10, 10]
$ball_pos = &dimensions / 2
$ball_velocity = [0,0]
$gravity = [0,0.06]
$pball_size = [5,5]
$pball_pos = $ball_pos
}
run $init
$constrain_ball_velocity = {
$ball_velocity = $ball_velocity # [[-2.5,2.5],[-2.5,2.5]]
}
$move_ball = {
$top_left = $ball_pos + $ball_velocity
$bottom_right = $ball_pos + $ball_velocity
if $top_left[0] < 0 or $bottom_right[0] > &dimensions[0] {
$ball_velocity = $ball_velocity * [-1, 0]
}
if $top_left[1] < 0 {
$ball_velocity = $ball_velocity * [0, -1]
}
if $bottom_right[1] - $ball_velocity[1] >= &dimensions[1] {
run $init
}
$ball_pos = ($ball_pos + $ball_velocity) # [[0, &dimensions[0]], [0, &dimensions[1]]]
$ball_velocity = $ball_velocity + $gravity
run $constrain_ball_velocity
}
draw {
if &touch and &last_touch[0] >= ($ball_pos - ($ball_size / 2))[0] and &last_touch[0] <= ($ball_pos + ($ball_size / 2))[0] and &last_touch[1] >= ($ball_pos - ($ball_size / 2))[1] and &last_touch[1] <= ($ball_pos + ($ball_size / 2))[1] {
$base = $ball_pos - &last_touch
$mag = sqrt($base[0] * $base[0] + $base[1] * $base[1])
$normalized = $base / $mag
$ball_velocity = [$normalized[0] * 0.3, abs($normalized[1]) * -1] * 5
run $constrain_ball_velocity
}
color(rand(3))
rect(($pball_pos - ($pball_size / 2)) : $pball_size)
color(0)
rect(($ball_pos - ($pball_size / 2)) : $pball_size)
$pball_pos = $ball_pos
run $move_ball
print(&touch)
}
</script>
<body>
<canvas></canvas>
<script>
(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<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
/*
* Hashcode.js 1.0.2
* https://github.com/stuartbannerman/hashcode
*
* Copyright 2013 Stuart Bannerman (me@stuartbannerman.com)
* Released under the MIT license
*
* Date: 07-04-2013
*
* packaged as npm module by
* A. Siebert, ask@touchableheroes.com
*
* usage:
* ------------------------------------
* var encode = require( 'hashcode' ).hashCode;
* var hash = encode().value( "my string value" );
*/
exports.hashCode = function () {
// Hashes a string
var hash = function (string) {
var string = string.toString(), hash = 0, i;
for (i = 0; i < string.length; i++) {
hash = (((hash << 5) - hash) + string.charCodeAt(i)) & 0xFFFFFFFF;
}
return hash;
};
// Deep hashes an object
var object = function (obj) {
var result = 0;
for (var property in obj) {
if (obj.hasOwnProperty(property)) {
result += hash(property + value(obj[property]));
}
}
return result;
};
// Does a type check on the passed in value and calls the appropriate hash method
var value = function (value) {
var types =
{
'string': hash,
'number': hash,
'boolean': hash,
'object': object
// functions are excluded because they are not representative of the state of an object
// types 'undefined' or 'null' will have a hash of 0
};
var type = typeof value;
return value != null && types[type] ? types[type](value) + hash(type) : 0;
};
return {
value: value
};
};
},{}],2:[function(require,module,exports){
/*
https://github.com/banksean wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace
so it's better encapsulated. Now you can have multiple random number generators
and they won't stomp all over eachother's state.
If you want to use this as a substitute for Math.random(), use the random()
method like so:
var m = new MersenneTwister();
var randomNumber = m.random();
You can also call the other genrand_{foo}() methods on the instance.
If you want to use a specific seed in order to get a repeatable random
sequence, pass an integer into the constructor:
var m = new MersenneTwister(123);
and that will always produce the same random sequence.
Sean McCullough (banksean@gmail.com)
*/
/*
A C-program for MT19937, with initialization improved 2002/1/26.
Coded by Takuji Nishimura and Makoto Matsumoto.
Before using, initialize the state by using init_seed(seed)
or init_by_array(init_key, key_length).
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The names of its contributors may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Any feedback is very welcome.
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
*/
var MersenneTwister = function(seed) {
if (seed == undefined) {
seed = new Date().getTime();
}
/* Period parameters */
this.N = 624;
this.M = 397;
this.MATRIX_A = 0x9908b0df; /* constant vector a */
this.UPPER_MASK = 0x80000000; /* most significant w-r bits */
this.LOWER_MASK = 0x7fffffff; /* least significant r bits */
this.mt = new Array(this.N); /* the array for the state vector */
this.mti=this.N+1; /* mti==N+1 means mt[N] is not initialized */
this.init_seed(seed);
}
/* initializes mt[N] with a seed */
/* origin name init_genrand */
MersenneTwister.prototype.init_seed = function(s) {
this.mt[0] = s >>> 0;
for (this.mti=1; this.mti<this.N; this.mti++) {
var s = this.mt[this.mti-1] ^ (this.mt[this.mti-1] >>> 30);
this.mt[this.mti] = (((((s & 0xffff0000) >>> 16) * 1812433253) << 16) + (s & 0x0000ffff) * 1812433253)
+ this.mti;
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
/* In the previous versions, MSBs of the seed affect */
/* only MSBs of the array mt[]. */
/* 2002/01/09 modified by Makoto Matsumoto */
this.mt[this.mti] >>>= 0;
/* for >32 bit machines */
}
}
/* initialize by an array with array-length */
/* init_key is the array for initializing keys */
/* key_length is its length */
/* slight change for C++, 2004/2/26 */
MersenneTwister.prototype.init_by_array = function(init_key, key_length) {
var i, j, k;
this.init_seed(19650218);
i=1; j=0;
k = (this.N>key_length ? this.N : key_length);
for (; k; k--) {
var s = this.mt[i-1] ^ (this.mt[i-1] >>> 30)
this.mt[i] = (this.mt[i] ^ (((((s & 0xffff0000) >>> 16) * 1664525) << 16) + ((s & 0x0000ffff) * 1664525)))
+ init_key[j] + j; /* non linear */
this.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */
i++; j++;
if (i>=this.N) { this.mt[0] = this.mt[this.N-1]; i=1; }
if (j>=key_length) j=0;
}
for (k=this.N-1; k; k--) {
var s = this.mt[i-1] ^ (this.mt[i-1] >>> 30);
this.mt[i] = (this.mt[i] ^ (((((s & 0xffff0000) >>> 16) * 1566083941) << 16) + (s & 0x0000ffff) * 1566083941))
- i; /* non linear */
this.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */
i++;
if (i>=this.N) { this.mt[0] = this.mt[this.N-1]; i=1; }
}
this.mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */
}
/* generates a random number on [0,0xffffffff]-interval */
/* origin name genrand_int32 */
MersenneTwister.prototype.random_int = function() {
var y;
var mag01 = new Array(0x0, this.MATRIX_A);
/* mag01[x] = x * MATRIX_A for x=0,1 */
if (this.mti >= this.N) { /* generate N words at one time */
var kk;
if (this.mti == this.N+1) /* if init_seed() has not been called, */
this.init_seed(5489); /* a default initial seed is used */
for (kk=0;kk<this.N-this.M;kk++) {
y = (this.mt[kk]&this.UPPER_MASK)|(this.mt[kk+1]&this.LOWER_MASK);
this.mt[kk] = this.mt[kk+this.M] ^ (y >>> 1) ^ mag01[y & 0x1];
}
for (;kk<this.N-1;kk++) {
y = (this.mt[kk]&this.UPPER_MASK)|(this.mt[kk+1]&this.LOWER_MASK);
this.mt[kk] = this.mt[kk+(this.M-this.N)] ^ (y >>> 1) ^ mag01[y & 0x1];
}
y = (this.mt[this.N-1]&this.UPPER_MASK)|(this.mt[0]&this.LOWER_MASK);
this.mt[this.N-1] = this.mt[this.M-1] ^ (y >>> 1) ^ mag01[y & 0x1];
this.mti = 0;
}
y = this.mt[this.mti++];
/* Tempering */
y ^= (y >>> 11);
y ^= (y << 7) & 0x9d2c5680;
y ^= (y << 15) & 0xefc60000;
y ^= (y >>> 18);
return y >>> 0;
}
/* generates a random number on [0,0x7fffffff]-interval */
/* origin name genrand_int31 */
MersenneTwister.prototype.random_int31 = function() {
return (this.random_int()>>>1);
}
/* generates a random number on [0,1]-real-interval */
/* origin name genrand_real1 */
MersenneTwister.prototype.random_incl = function() {
return this.random_int()*(1.0/4294967295.0);
/* divided by 2^32-1 */
}
/* generates a random number on [0,1)-real-interval */
MersenneTwister.prototype.random = function() {
return this.random_int()*(1.0/4294967296.0);
/* divided by 2^32 */
}
/* generates a random number on (0,1)-real-interval */
/* origin name genrand_real3 */
MersenneTwister.prototype.random_excl = function() {
return (this.random_int() + 0.5)*(1.0/4294967296.0);
/* divided by 2^32 */
}
/* generates a random number on [0,1) with 53-bit resolution*/
/* origin name genrand_res53 */
MersenneTwister.prototype.random_long = function() {
var a=this.random_int()>>>5, b=this.random_int()>>>6;
return(a*67108864.0+b)*(1.0/9007199254740992.0);
}
/* These real versions are due to Isaku Wada, 2002/01/09 added */
module.exports = MersenneTwister;
},{}],3:[function(require,module,exports){
var parse = require('./parser.js').parse;
function quote(str) {
return "'" + str + "'"
}
function parens(str) {
return "(" + str + ")";
}
function square_br(str) {
return "[" + str + "]";
}
function curly_br(str) {
return "{" + str + "}";
}
function eol(str) {
return str + ';';
}
function func(funcName, params) {
return parens(funcName + parens(params.join(',')));
}
function self_executing(str) {
return parens(parens('function()'+curly_br(str)) + "()");
}
var compileStmt = function(stmt) {
var val;
if (stmt === undefined) return eol("");
switch(stmt.tag) {
case 'expression': // Expression
return eol('__r=' + compileExpr(stmt.body));
case 'assignment': // Assignment
return (function(){
var variableJsStr = 'user' + square_br(quote(stmt.name.identifier));
var valueJsStr = compileExpr(stmt.body);
var funcParams = [variableJsStr, valueJsStr];
var out;
switch(stmt.operator) {
case "=":
out = valueJsStr;
break;
case ":=":
out = func('concat',funcParams);
break;
case "^=":
out = func('powOp',funcParams);
break;
case '+=':
out = func('additionOp',funcParams);
break;
case '-=':
out = func('subtractionOp',funcParams);
break;
case '*=':
out = func('multiplicationOp',funcParams);
break;
case '/=':
out = func('divisionOp',funcParams);
break;
case '%=':
out = func('moduloOp',funcParams);
break;
case '|=':
out = func('intersection', funcParams);
break;
case '##=':
out = func('wrap', funcParams);
break;
case '#=':
out = func('clamp', funcParams);
break;
case ':=':
out = func('concat', funcParams);
break;
default:
throw "unknown operator: " + stmt.operator;
}
return eol('__r=' + out ) + eol(variableJsStr + '=__r');
})();
case 'list_index_assignment': // Assignment of list element
return eol('__r=' + compileExpr(stmt.body)) +
eol('user' + square_br(quote(stmt.name.identifier)) + stmt.index_accessors.map(function(index_accessor){ return square_br(compileExpr(index_accessor)); }).join('') + '=__r');
case 'conditional': // if ... else if ... else
return eol(
'if' + parens(compileExpr(stmt.condition) + '===true') +
curly_br(compileStatements(stmt.body)) +
(stmt.else_body !== undefined ? 'else' + curly_br(compileStatements(stmt.else_body)) : ''));
case 'iterate': // each iterable { }
return eol(
parens('ensureList' + parens(compileExpr(stmt.iterable))) +
'.slice().forEach(function(v,i,a){pushEnv({value:a[i],index:i});' +
compileStatements(stmt.body) +
'popEnv();})'
);
case 'loop':
return eol('while' + parens(compileExpr(stmt.condition) + '===true') + curly_br(compileStatements(stmt.body)));
return val;
case 'draw':
return eol('drawFunc(function(){' +
compileStatements(stmt.body) +
'})');
case 'run': // run $some_block
return eol(parens(compileExpr(stmt.body)) + '.apply(null,[])');
case 'native': // native "setTimeout(function(){alert('yo!');}, 50);"
return eol(stmt.body);
}
};
var compileStatements = function(statements) {
if (statements === undefined) return ';';
return statements.map(compileStmt).join('');
}
var compileExpr = function(expr) {
if (typeof expr === 'number' || typeof expr === 'boolean') {
return expr.toString();
}
if (typeof expr === 'string') {
return quote(expr.replace(/'/gmi, "\\'"));
}
switch(expr.tag) {
// Block
case 'block':
return "function(){" + compileStatements(expr.body) + "}";
// List
case 'list':
return square_br(expr.values.map(function(v){ return compileExpr(v); }).join(','));
case 'list_access':
return expr.index_accessors.reduce(function(v, index){ return v + square_br(compileExpr(index)); }, compileExpr(expr.list));
case 'list_slice':
return func('slice', [compileExpr(expr.list), expr.start === null ? '0' : compileExpr(expr.start), expr.end === null ? '0' : compileExpr(expr.end)]);
case 'nothing':
return "undefined";
// Unary operations
case 'not':
return parens("!" + compileExpr(expr.expr));
// Boolean operations
case 'and':
return parens(compileExpr(expr.left) + "&&" +
compileExpr(expr.right));
case 'or':
return parens(compileExpr(expr.left) + "||" +
compileExpr(expr.right));
// intersection operation
case '|':
return func('intersection', [compileExpr(expr.left), compileExpr(expr.right)]);
// wrap operation
case '##':
return func('wrap', [compileExpr(expr.left), compileExpr(expr.right)]);
// clamp operation
case '#':
return func('clamp', [compileExpr(expr.left), compileExpr(expr.right)]);
// concat operation
case ':':
return func('concat', [compileExpr(expr.left), compileExpr(expr.right)]);
case '..':
return func('range', [expr.start === null ? "undefined" : compileExpr(expr.start), compileExpr(expr.end)]);
case '...':
return func('slice', [func('range', [expr.start === null ? "undefined" : compileExpr(expr.start), compileExpr(expr.end)]), 0, -1]);
case '<':
case '<=':
case '>':
case '>=':
return parens(compileExpr(expr.left) + expr.tag +
compileExpr(expr.right));
case '+':
return func('additionOp', [compileExpr(expr.left), compileExpr(expr.right)]);
case '-':
return func('subtractionOp', [compileExpr(expr.left), compileExpr(expr.right)]);
case '*':
return func('multiplicationOp', [compileExpr(expr.left), compileExpr(expr.right)]);
case '/':
return func('divisionOp', [compileExpr(expr.left), compileExpr(expr.right)]);
case '^':
return func('powOp', [compileExpr(expr.left), compileExpr(expr.right)]);
case '%':
return func('moduloOp', [compileExpr(expr.left), compileExpr(expr.right)]);
case '==':
return func('deepEqual', [compileExpr(expr.left), compileExpr(expr.right)]);
case '!=':
return func('!deepEqual', [compileExpr(expr.left), compileExpr(expr.right)]);
// Built-in Function Call
case 'call':
return'(lookup(functions,' + quote(expr.name) + ').apply(null,[' +
expr.args.map(function(arg){ return compileExpr(arg) }).join(",")
+ ']))';
// Variable lookup
case 'var':
if(expr.scope === "system") {
return parens('copy(lookup(system,' + quote(expr.identifier) + '))');
} else if(expr.scope === "user") {
return parens('copy(user[' + quote(expr.identifier) + '])');
} else if(expr.scope === "asset") {
return parens('copy(asset[' + quote(expr.identifier) + '])');
} else {
throw "Unknown scope " + expr.scope;
}
}
}
var compile = function(code, verbose) {
verbose = verbose;
if(verbose === true) console.log(code);
var out = "(function(){" + eol('var __r') + compileStatements(parse(code)) + eol('return __r') + "})()";
verbose = false;
return out;
}
module.exports.compile = compile;
},{"./parser.js":4}],4:[function(require,module,exports){
// auto-generated using `compile_grammar.rb` at 14/11/2015 11:25
var parser = (function() {
/*
* Generated by PEG.js 0.8.0.
*
* http://pegjs.majda.cz/
*/
function peg$subclass(child, parent) {
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor();
}
function SyntaxError(message, expected, found, offset, line, column) {
this.message = message;
this.expected = expected;
this.found = found;
this.offset = offset;
this.line = line;
this.column = column;
this.name = "SyntaxError";
}
peg$subclass(SyntaxError, Error);
function parse(input) {
var options = arguments.length > 1 ? arguments[1] : {},
peg$FAILED = {},
peg$startRuleFunctions = { start: peg$parsestart },
peg$startRuleFunction = peg$parsestart,
peg$c0 = "",
peg$c1 = function() { return undefined; },
peg$c2 = /^[ \t]/,
peg$c3 = { type: "class", value: "[ \\t]", description: "[ \\t]" },
peg$c4 = [],
peg$c5 = /^[\n\r]/,
peg$c6 = { type: "class", value: "[\\n\\r]", description: "[\\n\\r]" },
peg$c7 = peg$FAILED,
peg$c8 = null,
peg$c9 = ";",
peg$c10 = { type: "literal", value: ";", description: "\";\"" },
peg$c11 = function(first, rest) { return [first].concat(rest); },
peg$c12 = function() { return []; },
peg$c13 = function(statement) { return statement; },
peg$c14 = function(expression) { return { tag:"expression", body:expression}; },
peg$c15 = "=",
peg$c16 = { type: "literal", value: "=", description: "\"=\"" },
peg$c17 = "+=",
peg$c18 = { type: "literal", value: "+=", description: "\"+=\"" },
peg$c19 = "-=",
peg$c20 = { type: "literal", value: "-=", description: "\"-=\"" },
peg$c21 = "*=",
peg$c22 = { type: "literal", value: "*=", description: "\"*=\"" },
peg$c23 = "/=",
peg$c24 = { type: "literal", value: "/=", description: "\"/=\"" },
peg$c25 = "%=",
peg$c26 = { type: "literal", value: "%=", description: "\"%=\"" },
peg$c27 = "^=",
peg$c28 = { type: "literal", value: "^=", description: "\"^=\"" },
peg$c29 = "##=",
peg$c30 = { type: "literal", value: "##=", description: "\"##=\"" },
peg$c31 = "#=",
peg$c32 = { type: "literal", value: "#=", description: "\"#=\"" },
peg$c33 = "|=",
peg$c34 = { type: "literal", value: "|=", description: "\"|=\"" },
peg$c35 = ":=",
peg$c36 = { type: "literal", value: ":=", description: "\":=\"" },
peg$c37 = function(v, operator, expr) { return { tag:"assignment", name:v, operator:operator, body:expr }; },
peg$c38 = "[",
peg$c39 = { type: "literal", value: "[", description: "\"[\"" },
peg$c40 = "]",
peg$c41 = { type: "literal", value: "]", description: "\"]\"" },
peg$c42 = function(expr) { return expr; },
peg$c43 = function(v, index_accessors, expr) { return { tag:"list_index_assignment", name:v, index_accessors:index_accessors, body:expr }; },
peg$c44 = "run",
peg$c45 = { type: "literal", value: "run", description: "\"run\"" },
peg$c46 = function(expr) { return { tag:"run", body:expr }; },
peg$c47 = "native",
peg$c48 = { type: "literal", value: "native", description: "\"native\"" },
peg$c49 = function(expr) { return { tag:"native", body:expr }; },
peg$c50 = "if",
peg$c51 = { type: "literal", value: "if", description: "\"if\"" },
peg$c52 = "{",
peg$c53 = { type: "literal", value: "{", description: "\"{\"" },
peg$c54 = "}",
peg$c55 = { type: "literal", value: "}", description: "\"}\"" },
peg$c56 = "else",
peg$c57 = { type: "literal", value: "else", description: "\"else\"" },
peg$c58 = function(condition_expr, statements, else_conditional) { return {tag:"conditional", condition:condition_expr, body:statements, else_body:[else_conditional]}; },
peg$c59 = function(condition_expr, statements, else_statements) { return {tag:"conditional", condition:condition_expr, body:statements, else_body:else_statements}; },
peg$c60 = function(condition_expr, statements) { return {tag:"conditional", condition:condition_expr, body:statements, else_body:undefined}; },
peg$c61 = "each",
peg$c62 = { type: "literal", value: "each", description: "\"each\"" },
peg$c63 = function(iterable, statements) { return {tag:"iterate", iterable:iterable, body:statements}; },
peg$c64 = "while",
peg$c65 = { type: "literal", value: "while", description: "\"while\"" },
peg$c66 = function(condition_expr, statements) { return {tag:"loop", condition:condition_expr, body:statements}; },
peg$c67 = "draw",
peg$c68 = { type: "literal", value: "draw", description: "\"draw\"" },
peg$c69 = function(statements) { return {tag:"draw", body:statements}; },
peg$c70 = "and",
peg$c71 = { type: "literal", value: "and", description: "\"and\"" },
peg$c72 = "or",
peg$c73 = { type: "literal", value: "or", description: "\"or\"" },
peg$c74 = function(left, op, right) { return {tag: op, left:left, right:right}; },
peg$c75 = "<=",
peg$c76 = { type: "literal", value: "<=", description: "\"<=\"" },
peg$c77 = ">=",
peg$c78 = { type: "literal", value: ">=", description: "\">=\"" },
peg$c79 = "!=",
peg$c80 = { type: "literal", value: "!=", description: "\"!=\"" },
peg$c81 = "==",
peg$c82 = { type: "literal", value: "==", description: "\"==\"" },
peg$c83 = "<",
peg$c84 = { type: "literal", value: "<", description: "\"<\"" },
peg$c85 = ">",
peg$c86 = { type: "literal", value: ">", description: "\">\"" },
peg$c87 = "|",
peg$c88 = { type: "literal", value: "|", description: "\"|\"" },
peg$c89 = "##",
peg$c90 = { type: "literal", value: "##", description: "\"##\"" },
peg$c91 = "#",
peg$c92 = { type: "literal", value: "#", description: "\"#\"" },
peg$c93 = ":",
peg$c94 = { type: "literal", value: ":", description: "\":\"" },
peg$c95 = "+",
peg$c96 = { type: "literal", value: "+", description: "\"+\"" },
peg$c97 = function(left, op, right) { return {tag:op, left:left, right:right}; },
peg$c98 = "-",
peg$c99 = { type: "literal", value: "-", description: "\"-\"" },
peg$c100 = "*",
peg$c101 = { type: "literal", value: "*", description: "\"*\"" },
peg$c102 = "/",
peg$c103 = { type: "literal", value: "/", description: "\"/\"" },
peg$c104 = "%",
peg$c105 = { type: "literal", value: "%", description: "\"%\"" },
peg$c106 = "^",
peg$c107 = { type: "literal", value: "^", description: "\"^\"" },
peg$c108 = "!",
peg$c109 = { type: "literal", value: "!", description: "\"!\"" },
peg$c110 = function(expr) { return {tag:"not", expr:expr}; },
peg$c111 = ",",
peg$c112 = { type: "literal", value: ",", description: "\",\"" },
peg$c113 = function(list, start, end) { return {tag:"list_slice", list:list, start:start, end:end}; },
peg$c114 = function(list, index_accessors) { return {tag:"list_access", list:list, index_accessors:index_accessors}; },
peg$c115 = "(",
peg$c116 = { type: "literal", value: "(", description: "\"(\"" },
peg$c117 = ")",
peg$c118 = { type: "literal", value: ")", description: "\")\"" },
peg$c119 = /^[a-z_]/,
peg$c120 = { type: "class", value: "[a-z_]", description: "[a-z_]" },
peg$c121 = function(chars) { return chars.join(''); },
peg$c122 = function(v) { return {tag:"call", name:v, args:[]}; },
peg$c123 = function(v, args) { return {tag:"call", name:v, args:args}; },
peg$c124 = /^[0-9a-z_]/,
peg$c125 = { type: "class", value: "[0-9a-z_]", description: "[0-9a-z_]" },
peg$c126 = function(first, rest) { return [first].concat(rest).join(''); },
peg$c127 = "$",
peg$c128 = { type: "literal", value: "$", description: "\"$\"" },
peg$c129 = function() { return "user" },
peg$c130 = function(scope, variable_identifier) { return {tag:"var", scope:scope, identifier:variable_identifier}},
peg$c131 = "&",
peg$c132 = { type: "literal", value: "&", description: "\"&\"" },
peg$c133 = function() { return "system" },
peg$c134 = "@",
peg$c135 = { type: "literal", value: "@", description: "\"@\"" },
peg$c136 = function() { return "asset" },
peg$c137 = "true",
peg$c138 = { type: "literal", value: "true", description: "\"true\"" },
peg$c139 = function() { return true; },
peg$c140 = "false",
peg$c141 = { type: "literal", value: "false", description: "\"false\"" },
peg$c142 = function() { return false; },
peg$c143 = "nothing",
peg$c144 = { type: "literal", value: "nothing", description: "\"nothing\"" },
peg$c145 = function() { return {tag:"nothing"}; },
peg$c146 = function() { return parseFloat(text()); },
peg$c147 = /^[0-9]/,
peg$c148 = { type: "class", value: "[0-9]", description: "[0-9]" },
peg$c149 = /^[0-9a-f]/i,
peg$c150 = { type: "class", value: "[0-9a-f]i", description: "[0-9a-f]i" },
peg$c151 = ".",
peg$c152 = { type: "literal", value: ".", description: "\".\"" },
peg$c153 = /^[1-9]/,
peg$c154 = { type: "class", value: "[1-9]", description: "[1-9]" },
peg$c155 = /^[eE]/,
peg$c156 = { type: "class", value: "[eE]", description: "[eE]" },
peg$c157 = "0",
peg$c158 = { type: "literal", value: "0", description: "\"0\"" },
peg$c159 = function(chars) { return chars.join(""); },
peg$c160 = "\"",
peg$c161 = { type: "literal", value: "\"", description: "\"\\\"\"" },
peg$c162 = "\\",
peg$c163 = { type: "literal", value: "\\", description: "\"\\\\\"" },
peg$c164 = "b",
peg$c165 = { type: "literal", value: "b", description: "\"b\"" },
peg$c166 = function() { return "\b"; },
peg$c167 = "f",
peg$c168 = { type: "literal", value: "f", description: "\"f\"" },
peg$c169 = function() { return "\f"; },
peg$c170 = "n",
peg$c171 = { type: "literal", value: "n", description: "\"n\"" },
peg$c172 = function() { return "\n"; },
peg$c173 = "r",
peg$c174 = { type: "literal", value: "r", description: "\"r\"" },
peg$c175 = function() { return "\r"; },
peg$c176 = "t",
peg$c177 = { type: "literal", value: "t", description: "\"t\"" },
peg$c178 = function() { return "\t"; },
peg$c179 = "u",
peg$c180 = { type: "literal", value: "u", description: "\"u\"" },
peg$c181 = function(digits) {
return String.fromCharCode(parseInt(digits, 16));
},
peg$c182 = function(sequence) { return sequence; },
peg$c183 = /^[ -!#-[\]-\u10FFFF]/,
peg$c184 = { type: "class", value: "[ -!#-[\\]-\\u10FFFF]", description: "[ -!#-[\\]-\\u10FFFF]" },
peg$c185 = function(v) { return v; },
peg$c186 = function(values) { return {tag:"list", values:(values !== null ? values : [])}; },
peg$c187 = function(statements) { return {tag:"block", body:statements}; },
peg$currPos = 0,
peg$reportedPos = 0,
peg$cachedPos = 0,
peg$cachedPosDetails = { line: 1, column: 1, seenCR: false },
peg$maxFailPos = 0,
peg$maxFailExpected = [],
peg$silentFails = 0,
peg$cache = {},
peg$result;
if ("startRule" in options) {
if (!(options.startRule in peg$startRuleFunctions)) {
throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
}
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
}
function text() {
return input.substring(peg$reportedPos, peg$currPos);
}
function offset() {
return peg$reportedPos;
}
function line() {
return peg$computePosDetails(peg$reportedPos).line;
}
function column() {
return peg$computePosDetails(peg$reportedPos).column;
}
function expected(description) {
throw peg$buildException(
null,
[{ type: "other", description: description }],
peg$reportedPos
);
}
function error(message) {
throw peg$buildException(message, null, peg$reportedPos);
}
function peg$computePosDetails(pos) {
function advance(details, startPos, endPos) {
var p, ch;
for (p = startPos; p < endPos; p++) {
ch = input.charAt(p);
if (ch === "\n") {
if (!details.seenCR) { details.line++; }
details.column = 1;
details.seenCR = false;
} else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
details.line++;
details.column = 1;
details.seenCR = true;
} else {
details.column++;
details.seenCR = false;
}
}
}
if (peg$cachedPos !== pos) {
if (peg$cachedPos > pos) {
peg$cachedPos = 0;
peg$cachedPosDetails = { line: 1, column: 1, seenCR: false };
}
advance(peg$cachedPosDetails, peg$cachedPos, pos);
peg$cachedPos = pos;
}
return peg$cachedPosDetails;
}
function peg$fail(expected) {
if (peg$currPos < peg$maxFailPos) { return; }
if (peg$currPos > peg$maxFailPos) {
peg$maxFailPos = peg$currPos;
peg$maxFailExpected = [];
}
peg$maxFailExpected.push(expected);
}
function peg$buildException(message, expected, pos) {
function cleanupExpected(expected) {
var i = 1;
expected.sort(function(a, b) {
if (a.description < b.description) {
return -1;
} else if (a.description > b.description) {
return 1;
} else {
return 0;
}
});
while (i < expected.length) {
if (expected[i - 1] === expected[i]) {
expected.splice(i, 1);
} else {
i++;
}
}
}
function buildMessage(expected, found) {
function stringEscape(s) {
function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
return s
.replace(/\\/g, '\\\\')
.replace(/"/g, '\\"')
.replace(/\x08/g, '\\b')
.replace(/\t/g, '\\t')
.replace(/\n/g, '\\n')
.replace(/\f/g, '\\f')
.replace(/\r/g, '\\r')
.replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
.replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
.replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
.replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); });
}
var expectedDescs = new Array(expected.length),
expectedDesc, foundDesc, i;
for (i = 0; i < expected.length; i++) {
expectedDescs[i] = expected[i].description;
}
expectedDesc = expected.length > 1
? expectedDescs.slice(0, -1).join(", ")
+ " or "
+ expectedDescs[expected.length - 1]
: expectedDescs[0];
foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input";
return "Expected " + expectedDesc + " but " + foundDesc + " found.";
}
var posDetails = peg$computePosDetails(pos),
found = pos < input.length ? input.charAt(pos) : null;
if (expected !== null) {
cleanupExpected(expected);
}
return new SyntaxError(
message !== null ? message : buildMessage(expected, found),
expected,
found,
pos,
posDetails.line,
posDetails.column
);
}
function peg$parsestart() {
var s0, s1;
var key = peg$currPos * 86 + 0,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$parsestatements();
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$c0;
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c1();
}
s0 = s1;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsewhitespace_character() {
var s0;
var key = peg$currPos * 86 + 1,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (peg$c2.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c3); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsews() {
var s0, s1;
var key = peg$currPos * 86 + 2,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = [];
s1 = peg$parsewhitespace_character();
while (s1 !== peg$FAILED) {
s0.push(s1);
s1 = peg$parsewhitespace_character();
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsenewline_character() {
var s0;
var key = peg$currPos * 86 + 3,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (peg$c5.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c6); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsenewline_ws() {
var s0, s1, s2, s3;
var key = peg$currPos * 86 + 4,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parsews();
if (s1 !== peg$FAILED) {
s2 = peg$parsenewline_character();
if (s2 !== peg$FAILED) {
s3 = peg$parsenewline_ws();
if (s3 === peg$FAILED) {
s3 = peg$c8;
}
if (s3 !== peg$FAILED) {
s1 = [s1, s2, s3];
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$parsews();
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseexplicit_statement_delimiter() {
var s0;
var key = peg$currPos * 86 + 5,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.charCodeAt(peg$currPos) === 59) {
s0 = peg$c9;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c10); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsestatement_end() {
var s0, s1, s2, s3, s4;
var key = peg$currPos * 86 + 6,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parsews();
if (s1 !== peg$FAILED) {
s2 = peg$parseexplicit_statement_delimiter();
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$parsestatement_end();
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = peg$parsestatement_end();
}
if (s3 !== peg$FAILED) {
s1 = [s1, s2, s3];
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parsews();
if (s1 !== peg$FAILED) {
s2 = peg$parsenewline_character();
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$parsestatement_end();
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = peg$parsestatement_end();
}
if (s3 !== peg$FAILED) {
s1 = [s1, s2, s3];
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsedelimiter_ws() {
var s0;
var key = peg$currPos * 86 + 7,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$parsestatement_end();
if (s0 === peg$FAILED) {
s0 = peg$parsews();
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsestatements() {
var s0, s1, s2, s3, s4;
var key = peg$currPos * 86 + 8,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parsedelimiter_ws();
if (s1 !== peg$FAILED) {
s2 = peg$parsestatement();
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$parsenext_statement();
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = peg$parsenext_statement();
}
if (s3 !== peg$FAILED) {
s4 = peg$parsedelimiter_ws();
if (s4 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c11(s2, s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parsedelimiter_ws();
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c12();
}
s0 = s1;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsenext_statement() {
var s0, s1, s2, s3;
var key = peg$currPos * 86 + 9,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parsestatement_end();
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parsestatement();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c13(s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsestatement() {
var s0, s1;
var key = peg$currPos * 86 + 10,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$parseassignment();
if (s0 === peg$FAILED) {
s0 = peg$parseindex_assignment();
if (s0 === peg$FAILED) {
s0 = peg$parserun();
if (s0 === peg$FAILED) {
s0 = peg$parsenative();
if (s0 === peg$FAILED) {
s0 = peg$parseconditional();
if (s0 === peg$FAILED) {
s0 = peg$parseiterate();
if (s0 === peg$FAILED) {
s0 = peg$parseloop();
if (s0 === peg$FAILED) {
s0 = peg$parsedraw();
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parseexpression();
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c14(s1);
}
s0 = s1;
}
}
}
}
}
}
}
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseassignment_operator() {
var s0;
var key = peg$currPos * 86 + 11,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.charCodeAt(peg$currPos) === 61) {
s0 = peg$c15;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c16); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c17) {
s0 = peg$c17;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c18); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c19) {
s0 = peg$c19;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c20); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c21) {
s0 = peg$c21;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c22); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c23) {
s0 = peg$c23;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c24); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c25) {
s0 = peg$c25;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c26); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c27) {
s0 = peg$c27;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c28); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 3) === peg$c29) {
s0 = peg$c29;
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c30); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c31) {
s0 = peg$c31;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c32); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c33) {
s0 = peg$c33;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c34); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c35) {
s0 = peg$c35;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c36); }
}
}
}
}
}
}
}
}
}
}
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseassignment() {
var s0, s1, s2, s3, s4, s5;
var key = peg$currPos * 86 + 12,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parseuser_variable();
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseassignment_operator();
if (s3 !== peg$FAILED) {
s4 = peg$parsews();
if (s4 !== peg$FAILED) {
s5 = peg$parseexpression();
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c37(s1, s3, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseindex_accessors() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13;
var key = peg$currPos * 86 + 13,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 91) {
s1 = peg$c38;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c39); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseexpression();
if (s3 !== peg$FAILED) {
s4 = peg$parsews();
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 93) {
s5 = peg$c40;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c41); }
}
if (s5 !== peg$FAILED) {
s6 = [];
s7 = peg$currPos;
s8 = peg$parsews();
if (s8 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 91) {
s9 = peg$c38;
peg$currPos++;
} else {
s9 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c39); }
}
if (s9 !== peg$FAILED) {
s10 = peg$parsews();
if (s10 !== peg$FAILED) {
s11 = peg$parseexpression();
if (s11 !== peg$FAILED) {
s12 = peg$parsews();
if (s12 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 93) {
s13 = peg$c40;
peg$currPos++;
} else {
s13 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c41); }
}
if (s13 !== peg$FAILED) {
peg$reportedPos = s7;
s8 = peg$c42(s11);
s7 = s8;
} else {
peg$currPos = s7;
s7 = peg$c7;
}
} else {
peg$currPos = s7;
s7 = peg$c7;
}
} else {
peg$currPos = s7;
s7 = peg$c7;
}
} else {
peg$currPos = s7;
s7 = peg$c7;
}
} else {
peg$currPos = s7;
s7 = peg$c7;
}
} else {
peg$currPos = s7;
s7 = peg$c7;
}
while (s7 !== peg$FAILED) {
s6.push(s7);
s7 = peg$currPos;
s8 = peg$parsews();
if (s8 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 91) {
s9 = peg$c38;
peg$currPos++;
} else {
s9 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c39); }
}
if (s9 !== peg$FAILED) {
s10 = peg$parsews();
if (s10 !== peg$FAILED) {
s11 = peg$parseexpression();
if (s11 !== peg$FAILED) {
s12 = peg$parsews();
if (s12 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 93) {
s13 = peg$c40;
peg$currPos++;
} else {
s13 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c41); }
}
if (s13 !== peg$FAILED) {
peg$reportedPos = s7;
s8 = peg$c42(s11);
s7 = s8;
} else {
peg$currPos = s7;
s7 = peg$c7;
}
} else {
peg$currPos = s7;
s7 = peg$c7;
}
} else {
peg$currPos = s7;
s7 = peg$c7;
}
} else {
peg$currPos = s7;
s7 = peg$c7;
}
} else {
peg$currPos = s7;
s7 = peg$c7;
}
} else {
peg$currPos = s7;
s7 = peg$c7;
}
}
if (s6 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c11(s3, s6);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseindex_assignment() {
var s0, s1, s2, s3, s4, s5, s6, s7;
var key = peg$currPos * 86 + 14,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parseuser_variable();
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseindex_accessors();
if (s3 !== peg$FAILED) {
s4 = peg$parsews();
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 61) {
s5 = peg$c15;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c16); }
}
if (s5 !== peg$FAILED) {
s6 = peg$parsews();
if (s6 !== peg$FAILED) {
s7 = peg$parseexpression();
if (s7 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c43(s1, s3, s7);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parserun() {
var s0, s1, s2, s3;
var key = peg$currPos * 86 + 15,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
if (input.substr(peg$currPos, 3) === peg$c44) {
s1 = peg$c44;
peg$currPos += 3;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c45); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseexpression();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c46(s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsenative() {
var s0, s1, s2, s3;
var key = peg$currPos * 86 + 16,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
if (input.substr(peg$currPos, 6) === peg$c47) {
s1 = peg$c47;
peg$currPos += 6;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c48); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseexpression();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c49(s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseconditional() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15;
var key = peg$currPos * 86 + 17,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c50) {
s1 = peg$c50;
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c51); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseexpression();
if (s3 !== peg$FAILED) {
s4 = peg$parsenewline_ws();
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 123) {
s5 = peg$c52;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c53); }
}
if (s5 !== peg$FAILED) {
s6 = peg$parsenewline_ws();
if (s6 !== peg$FAILED) {
s7 = peg$parsestatements();
if (s7 !== peg$FAILED) {
s8 = peg$parsenewline_ws();
if (s8 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 125) {
s9 = peg$c54;
peg$currPos++;
} else {
s9 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c55); }
}
if (s9 !== peg$FAILED) {
s10 = peg$parsenewline_ws();
if (s10 !== peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c56) {
s11 = peg$c56;
peg$currPos += 4;
} else {
s11 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c57); }
}
if (s11 !== peg$FAILED) {
s12 = peg$parsenewline_ws();
if (s12 !== peg$FAILED) {
s13 = peg$parseconditional();
if (s13 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c58(s3, s7, s13);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c50) {
s1 = peg$c50;
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c51); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseexpression();
if (s3 !== peg$FAILED) {
s4 = peg$parsenewline_ws();
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 123) {
s5 = peg$c52;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c53); }
}
if (s5 !== peg$FAILED) {
s6 = peg$parsenewline_ws();
if (s6 !== peg$FAILED) {
s7 = peg$parsestatements();
if (s7 !== peg$FAILED) {
s8 = peg$parsenewline_ws();
if (s8 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 125) {
s9 = peg$c54;
peg$currPos++;
} else {
s9 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c55); }
}
if (s9 !== peg$FAILED) {
s10 = peg$parsenewline_ws();
if (s10 !== peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c56) {
s11 = peg$c56;
peg$currPos += 4;
} else {
s11 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c57); }
}
if (s11 !== peg$FAILED) {
s12 = peg$parsenewline_ws();
if (s12 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 123) {
s13 = peg$c52;
peg$currPos++;
} else {
s13 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c53); }
}
if (s13 !== peg$FAILED) {
s14 = peg$parsestatements();
if (s14 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 125) {
s15 = peg$c54;
peg$currPos++;
} else {
s15 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c55); }
}
if (s15 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c59(s3, s7, s14);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c50) {
s1 = peg$c50;
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c51); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseexpression();
if (s3 !== peg$FAILED) {
s4 = peg$parsenewline_ws();
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 123) {
s5 = peg$c52;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c53); }
}
if (s5 !== peg$FAILED) {
s6 = peg$parsenewline_ws();
if (s6 !== peg$FAILED) {
s7 = peg$parsestatements();
if (s7 !== peg$FAILED) {
s8 = peg$parsenewline_ws();
if (s8 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 125) {
s9 = peg$c54;
peg$currPos++;
} else {
s9 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c55); }
}
if (s9 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c60(s3, s7);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
}
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseiterate() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
var key = peg$currPos * 86 + 18,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
if (input.substr(peg$currPos, 4) === peg$c61) {
s1 = peg$c61;
peg$currPos += 4;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c62); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseexpression();
if (s3 !== peg$FAILED) {
s4 = peg$parsenewline_ws();
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 123) {
s5 = peg$c52;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c53); }
}
if (s5 !== peg$FAILED) {
s6 = peg$parsedelimiter_ws();
if (s6 !== peg$FAILED) {
s7 = peg$parsestatements();
if (s7 !== peg$FAILED) {
s8 = peg$parsedelimiter_ws();
if (s8 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 125) {
s9 = peg$c54;
peg$currPos++;
} else {
s9 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c55); }
}
if (s9 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c63(s3, s7);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseloop() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
var key = peg$currPos * 86 + 19,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
if (input.substr(peg$currPos, 5) === peg$c64) {
s1 = peg$c64;
peg$currPos += 5;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c65); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseexpression();
if (s3 !== peg$FAILED) {
s4 = peg$parsenewline_ws();
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 123) {
s5 = peg$c52;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c53); }
}
if (s5 !== peg$FAILED) {
s6 = peg$parsedelimiter_ws();
if (s6 !== peg$FAILED) {
s7 = peg$parsestatements();
if (s7 !== peg$FAILED) {
s8 = peg$parsedelimiter_ws();
if (s8 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 125) {
s9 = peg$c54;
peg$currPos++;
} else {
s9 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c55); }
}
if (s9 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c66(s3, s7);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsedraw() {
var s0, s1, s2, s3, s4, s5, s6, s7;
var key = peg$currPos * 86 + 20,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
if (input.substr(peg$currPos, 4) === peg$c67) {
s1 = peg$c67;
peg$currPos += 4;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c68); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parsenewline_ws();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 123) {
s3 = peg$c52;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c53); }
}
if (s3 !== peg$FAILED) {
s4 = peg$parsedelimiter_ws();
if (s4 !== peg$FAILED) {
s5 = peg$parsestatements();
if (s5 !== peg$FAILED) {
s6 = peg$parsedelimiter_ws();
if (s6 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 125) {
s7 = peg$c54;
peg$currPos++;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c55); }
}
if (s7 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c69(s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseexpression() {
var s0, s1;
var key = peg$currPos * 86 + 21,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parseboolean_operation();
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c42(s1);
}
s0 = s1;
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseboolean_operator() {
var s0;
var key = peg$currPos * 86 + 22,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.substr(peg$currPos, 3) === peg$c70) {
s0 = peg$c70;
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c71); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c72) {
s0 = peg$c72;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c73); }
}
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseboolean_operation() {
var s0, s1, s2, s3, s4, s5;
var key = peg$currPos * 86 + 23,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parsecomparison_operation();
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseboolean_operator();
if (s3 !== peg$FAILED) {
s4 = peg$parsews();
if (s4 !== peg$FAILED) {
s5 = peg$parseboolean_operation();
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c74(s1, s3, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$parsecomparison_operation();
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsecomparison_operator() {
var s0;
var key = peg$currPos * 86 + 24,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.substr(peg$currPos, 2) === peg$c75) {
s0 = peg$c75;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c76); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c77) {
s0 = peg$c77;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c78); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c79) {
s0 = peg$c79;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c80); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c81) {
s0 = peg$c81;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c82); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 60) {
s0 = peg$c83;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c84); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 62) {
s0 = peg$c85;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c86); }
}
}
}
}
}
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsecomparison_operation() {
var s0, s1, s2, s3, s4, s5;
var key = peg$currPos * 86 + 25,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parseintersection_operation();
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parsecomparison_operator();
if (s3 !== peg$FAILED) {
s4 = peg$parsews();
if (s4 !== peg$FAILED) {
s5 = peg$parsecomparison_operation();
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c74(s1, s3, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$parseintersection_operation();
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseintersection_operator() {
var s0;
var key = peg$currPos * 86 + 26,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.charCodeAt(peg$currPos) === 124) {
s0 = peg$c87;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c88); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseintersection_operation() {
var s0, s1, s2, s3, s4, s5;
var key = peg$currPos * 86 + 27,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parsewrap_operation();
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseintersection_operation();
if (s3 !== peg$FAILED) {
s4 = peg$parsews();
if (s4 !== peg$FAILED) {
s5 = peg$parseintersection_operation();
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c74(s1, s3, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$parsewrap_operation();
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsewrap_operator() {
var s0;
var key = peg$currPos * 86 + 28,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.substr(peg$currPos, 2) === peg$c89) {
s0 = peg$c89;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c90); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsewrap_operation() {
var s0, s1, s2, s3, s4, s5;
var key = peg$currPos * 86 + 29,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parseclamp_operation();
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parsewrap_operator();
if (s3 !== peg$FAILED) {
s4 = peg$parsews();
if (s4 !== peg$FAILED) {
s5 = peg$parsewrap_operation();
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c74(s1, s3, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$parseclamp_operation();
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseclamp_operator() {
var s0;
var key = peg$currPos * 86 + 30,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.charCodeAt(peg$currPos) === 35) {
s0 = peg$c91;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c92); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseclamp_operation() {
var s0, s1, s2, s3, s4, s5;
var key = peg$currPos * 86 + 31,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parseconcat_operation();
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseclamp_operator();
if (s3 !== peg$FAILED) {
s4 = peg$parsews();
if (s4 !== peg$FAILED) {
s5 = peg$parseclamp_operation();
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c74(s1, s3, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$parseconcat_operation();
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseconcat_operator() {
var s0;
var key = peg$currPos * 86 + 32,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.charCodeAt(peg$currPos) === 58) {
s0 = peg$c93;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c94); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseconcat_operation() {
var s0, s1, s2, s3, s4, s5;
var key = peg$currPos * 86 + 33,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parseadditive_operation();
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseconcat_operator();
if (s3 !== peg$FAILED) {
s4 = peg$parsews();
if (s4 !== peg$FAILED) {
s5 = peg$parseconcat_operation();
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c74(s1, s3, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$parseadditive_operation();
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseadditive_operator() {
var s0;
var key = peg$currPos * 86 + 34,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.charCodeAt(peg$currPos) === 43) {
s0 = peg$c95;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c96); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseadditive_operation() {
var s0, s1, s2, s3, s4, s5;
var key = peg$currPos * 86 + 35,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parsesubtractive_operation();
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseadditive_operator();
if (s3 !== peg$FAILED) {
s4 = peg$parsews();
if (s4 !== peg$FAILED) {
s5 = peg$parseadditive_operation();
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c97(s1, s3, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$parsesubtractive_operation();
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsesubtractive_operator() {
var s0;
var key = peg$currPos * 86 + 36,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.charCodeAt(peg$currPos) === 45) {
s0 = peg$c98;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c99); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsesubtractive_operation() {
var s0, s1, s2, s3, s4, s5;
var key = peg$currPos * 86 + 37,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parsemultiplicative_operation();
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parsesubtractive_operator();
if (s3 !== peg$FAILED) {
s4 = peg$parsews();
if (s4 !== peg$FAILED) {
s5 = peg$parsesubtractive_operation();
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c97(s1, s3, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$parsemultiplicative_operation();
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsemultiplicative_operator() {
var s0;
var key = peg$currPos * 86 + 38,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.charCodeAt(peg$currPos) === 42) {
s0 = peg$c100;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c101); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsemultiplicative_operation() {
var s0, s1, s2, s3, s4, s5;
var key = peg$currPos * 86 + 39,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parsequotient_operation();
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parsemultiplicative_operator();
if (s3 !== peg$FAILED) {
s4 = peg$parsews();
if (s4 !== peg$FAILED) {
s5 = peg$parsemultiplicative_operation();
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c97(s1, s3, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$parsequotient_operation();
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsequotient_operator() {
var s0;
var key = peg$currPos * 86 + 40,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.charCodeAt(peg$currPos) === 47) {
s0 = peg$c102;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c103); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 37) {
s0 = peg$c104;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c105); }
}
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsequotient_operation() {
var s0, s1, s2, s3, s4, s5;
var key = peg$currPos * 86 + 41,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parseexponential_operation();
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parsequotient_operator();
if (s3 !== peg$FAILED) {
s4 = peg$parsews();
if (s4 !== peg$FAILED) {
s5 = peg$parsequotient_operation();
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c97(s1, s3, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$parseexponential_operation();
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseexponential_operator() {
var s0;
var key = peg$currPos * 86 + 42,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.charCodeAt(peg$currPos) === 94) {
s0 = peg$c106;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c107); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseexponential_operation() {
var s0, s1, s2, s3, s4, s5;
var key = peg$currPos * 86 + 43,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parseunary_operation();
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseexponential_operator();
if (s3 !== peg$FAILED) {
s4 = peg$parsews();
if (s4 !== peg$FAILED) {
s5 = peg$parseexponential_operation();
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c97(s1, s3, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$parseunary_operation();
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseunary_operator() {
var s0;
var key = peg$currPos * 86 + 44,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.charCodeAt(peg$currPos) === 33) {
s0 = peg$c108;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c109); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseunary_operation() {
var s0, s1, s2, s3;
var key = peg$currPos * 86 + 45,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parseunary_operator();
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseexpression();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c110(s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$parselist_operation();
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parselist_slice() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11;
var key = peg$currPos * 86 + 46,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parsegrouped_expression();
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 91) {
s3 = peg$c38;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c39); }
}
if (s3 !== peg$FAILED) {
s4 = peg$parsenewline_ws();
if (s4 !== peg$FAILED) {
s5 = peg$parseexpression();
if (s5 === peg$FAILED) {
s5 = peg$c8;
}
if (s5 !== peg$FAILED) {
s6 = peg$parsenewline_ws();
if (s6 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 44) {
s7 = peg$c111;
peg$currPos++;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c112); }
}
if (s7 !== peg$FAILED) {
s8 = peg$parsenewline_ws();
if (s8 !== peg$FAILED) {
s9 = peg$parseexpression();
if (s9 === peg$FAILED) {
s9 = peg$c8;
}
if (s9 !== peg$FAILED) {
s10 = peg$parsenewline_ws();
if (s10 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 93) {
s11 = peg$c40;
peg$currPos++;
} else {
s11 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c41); }
}
if (s11 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c113(s1, s5, s9);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parselist_access() {
var s0, s1, s2, s3;
var key = peg$currPos * 86 + 47,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parsegrouped_expression();
if (s1 !== peg$FAILED) {
s2 = peg$parsews();
if (s2 !== peg$FAILED) {
s3 = peg$parseindex_accessors();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c114(s1, s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parselist_operation() {
var s0;
var key = peg$currPos * 86 + 48,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$parselist_slice();
if (s0 === peg$FAILED) {
s0 = peg$parselist_access();
if (s0 === peg$FAILED) {
s0 = peg$parsegrouped_expression();
}
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsegrouped_expression() {
var s0, s1, s2, s3, s4, s5;
var key = peg$currPos * 86 + 49,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 40) {
s1 = peg$c115;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c116); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parsenewline_ws();
if (s2 !== peg$FAILED) {
s3 = peg$parseexpression();
if (s3 !== peg$FAILED) {
s4 = peg$parsenewline_ws();
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 41) {
s5 = peg$c117;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c118); }
}
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c42(s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$parseprimary();
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseprimary() {
var s0;
var key = peg$currPos * 86 + 50,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$parseprimitive();
if (s0 === peg$FAILED) {
s0 = peg$parseany_variable();
if (s0 === peg$FAILED) {
s0 = peg$parsefunction_call();
}
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsearglist() {
var s0, s1, s2, s3, s4, s5, s6;
var key = peg$currPos * 86 + 51,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parseexpression();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 44) {
s4 = peg$c111;
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c112); }
}
if (s4 !== peg$FAILED) {
s5 = peg$parsenewline_ws();
if (s5 !== peg$FAILED) {
s6 = peg$parseexpression();
if (s6 !== peg$FAILED) {
peg$reportedPos = s3;
s4 = peg$c42(s6);
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$c7;
}
} else {
peg$currPos = s3;
s3 = peg$c7;
}
} else {
peg$currPos = s3;
s3 = peg$c7;
}
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 44) {
s4 = peg$c111;
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c112); }
}
if (s4 !== peg$FAILED) {
s5 = peg$parsenewline_ws();
if (s5 !== peg$FAILED) {
s6 = peg$parseexpression();
if (s6 !== peg$FAILED) {
peg$reportedPos = s3;
s4 = peg$c42(s6);
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$c7;
}
} else {
peg$currPos = s3;
s3 = peg$c7;
}
} else {
peg$currPos = s3;
s3 = peg$c7;
}
}
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c11(s1, s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsefunction_identifier() {
var s0, s1, s2;
var key = peg$currPos * 86 + 52,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = [];
if (peg$c119.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c120); }
}
if (s2 !== peg$FAILED) {
while (s2 !== peg$FAILED) {
s1.push(s2);
if (peg$c119.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c120); }
}
}
} else {
s1 = peg$c7;
}
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c121(s1);
}
s0 = s1;
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsefunction_call() {
var s0, s1, s2, s3, s4, s5, s6, s7;
var key = peg$currPos * 86 + 53,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parsefunction_identifier();
if (s1 !== peg$FAILED) {
s2 = peg$parsenewline_ws();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 40) {
s3 = peg$c115;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c116); }
}
if (s3 !== peg$FAILED) {
s4 = peg$parsenewline_ws();
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 41) {
s5 = peg$c117;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c118); }
}
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c122(s1);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parsefunction_identifier();
if (s1 !== peg$FAILED) {
s2 = peg$parsenewline_ws();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 40) {
s3 = peg$c115;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c116); }
}
if (s3 !== peg$FAILED) {
s4 = peg$parsenewline_ws();
if (s4 !== peg$FAILED) {
s5 = peg$parsearglist();
if (s5 !== peg$FAILED) {
s6 = peg$parsenewline_ws();
if (s6 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 41) {
s7 = peg$c117;
peg$currPos++;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c118); }
}
if (s7 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c123(s1, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsevalid_variable_first_char() {
var s0;
var key = peg$currPos * 86 + 54,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (peg$c119.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c120); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsevalid_variable_char() {
var s0;
var key = peg$currPos * 86 + 55,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (peg$c124.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c125); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsevariable_identifier() {
var s0, s1, s2, s3;
var key = peg$currPos * 86 + 56,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parsevalid_variable_first_char();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parsevalid_variable_char();
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parsevalid_variable_char();
}
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c126(s1, s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseany_variable() {
var s0;
var key = peg$currPos * 86 + 57,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$parseuser_variable();
if (s0 === peg$FAILED) {
s0 = peg$parsesystem_variable();
if (s0 === peg$FAILED) {
s0 = peg$parseasset_variable();
}
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseuser_variable_identifier() {
var s0, s1;
var key = peg$currPos * 86 + 58,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 36) {
s1 = peg$c127;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c128); }
}
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c129();
}
s0 = s1;
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseuser_variable() {
var s0, s1, s2;
var key = peg$currPos * 86 + 59,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parseuser_variable_identifier();
if (s1 !== peg$FAILED) {
s2 = peg$parsevariable_identifier();
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c130(s1, s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsesystem_variable_identifier() {
var s0, s1;
var key = peg$currPos * 86 + 60,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 38) {
s1 = peg$c131;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c132); }
}
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c133();
}
s0 = s1;
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsesystem_variable() {
var s0, s1, s2;
var key = peg$currPos * 86 + 61,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parsesystem_variable_identifier();
if (s1 !== peg$FAILED) {
s2 = peg$parsevariable_identifier();
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c130(s1, s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseasset_variable_identifier() {
var s0, s1;
var key = peg$currPos * 86 + 62,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 64) {
s1 = peg$c134;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c135); }
}
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c136();
}
s0 = s1;
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseasset_variable() {
var s0, s1, s2;
var key = peg$currPos * 86 + 63,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parseasset_variable_identifier();
if (s1 !== peg$FAILED) {
s2 = peg$parsevariable_identifier();
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c130(s1, s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseprimitive() {
var s0;
var key = peg$currPos * 86 + 64,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$parseboolean();
if (s0 === peg$FAILED) {
s0 = peg$parsenothing();
if (s0 === peg$FAILED) {
s0 = peg$parsenumber();
if (s0 === peg$FAILED) {
s0 = peg$parsestring();
if (s0 === peg$FAILED) {
s0 = peg$parselist();
if (s0 === peg$FAILED) {
s0 = peg$parseblock();
}
}
}
}
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseboolean() {
var s0, s1;
var key = peg$currPos * 86 + 65,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
if (input.substr(peg$currPos, 4) === peg$c137) {
s1 = peg$c137;
peg$currPos += 4;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c138); }
}
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c139();
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.substr(peg$currPos, 5) === peg$c140) {
s1 = peg$c140;
peg$currPos += 5;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c141); }
}
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c142();
}
s0 = s1;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsenothing() {
var s0, s1;
var key = peg$currPos * 86 + 66,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
if (input.substr(peg$currPos, 7) === peg$c143) {
s1 = peg$c143;
peg$currPos += 7;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c144); }
}
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c145();
}
s0 = s1;
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsenumber() {
var s0, s1, s2, s3, s4;
var key = peg$currPos * 86 + 67,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parseminus();
if (s1 === peg$FAILED) {
s1 = peg$c8;
}
if (s1 !== peg$FAILED) {
s2 = peg$parseint();
if (s2 !== peg$FAILED) {
s3 = peg$parsefrac();
if (s3 === peg$FAILED) {
s3 = peg$c8;
}
if (s3 !== peg$FAILED) {
s4 = peg$parseexp();
if (s4 === peg$FAILED) {
s4 = peg$c8;
}
if (s4 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c146();
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsedigit() {
var s0;
var key = peg$currPos * 86 + 68,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (peg$c147.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c148); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsehexdigit() {
var s0;
var key = peg$currPos * 86 + 69,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (peg$c149.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c150); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsedecimal_point() {
var s0;
var key = peg$currPos * 86 + 70,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.charCodeAt(peg$currPos) === 46) {
s0 = peg$c151;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c152); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsedigit1_9() {
var s0;
var key = peg$currPos * 86 + 71,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (peg$c153.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c154); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsee() {
var s0;
var key = peg$currPos * 86 + 72,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (peg$c155.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c156); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseexp() {
var s0, s1, s2, s3, s4;
var key = peg$currPos * 86 + 73,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parsee();
if (s1 !== peg$FAILED) {
s2 = peg$parseminus();
if (s2 === peg$FAILED) {
s2 = peg$parseplus();
}
if (s2 === peg$FAILED) {
s2 = peg$c8;
}
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$parsedigit();
if (s4 !== peg$FAILED) {
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = peg$parsedigit();
}
} else {
s3 = peg$c7;
}
if (s3 !== peg$FAILED) {
s1 = [s1, s2, s3];
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsefrac() {
var s0, s1, s2, s3;
var key = peg$currPos * 86 + 74,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parsedecimal_point();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parsedigit();
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parsedigit();
}
} else {
s2 = peg$c7;
}
if (s2 !== peg$FAILED) {
s1 = [s1, s2];
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseint() {
var s0, s1, s2, s3;
var key = peg$currPos * 86 + 75,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$parsezero();
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parsedigit1_9();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parsedigit();
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parsedigit();
}
if (s2 !== peg$FAILED) {
s1 = [s1, s2];
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseminus() {
var s0;
var key = peg$currPos * 86 + 76,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.charCodeAt(peg$currPos) === 45) {
s0 = peg$c98;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c99); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseplus() {
var s0;
var key = peg$currPos * 86 + 77,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.charCodeAt(peg$currPos) === 43) {
s0 = peg$c95;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c96); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsezero() {
var s0;
var key = peg$currPos * 86 + 78,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.charCodeAt(peg$currPos) === 48) {
s0 = peg$c157;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c158); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsestring() {
var s0, s1, s2, s3;
var key = peg$currPos * 86 + 79,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parsequotation_mark();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parsechar();
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parsechar();
}
if (s2 !== peg$FAILED) {
s3 = peg$parsequotation_mark();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c159(s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsechar() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
var key = peg$currPos * 86 + 80,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$parseunescaped();
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parseescape();
if (s1 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 34) {
s2 = peg$c160;
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c161); }
}
if (s2 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 92) {
s2 = peg$c162;
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c163); }
}
if (s2 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 47) {
s2 = peg$c102;
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c103); }
}
if (s2 === peg$FAILED) {
s2 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 98) {
s3 = peg$c164;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c165); }
}
if (s3 !== peg$FAILED) {
peg$reportedPos = s2;
s3 = peg$c166();
}
s2 = s3;
if (s2 === peg$FAILED) {
s2 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 102) {
s3 = peg$c167;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c168); }
}
if (s3 !== peg$FAILED) {
peg$reportedPos = s2;
s3 = peg$c169();
}
s2 = s3;
if (s2 === peg$FAILED) {
s2 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 110) {
s3 = peg$c170;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c171); }
}
if (s3 !== peg$FAILED) {
peg$reportedPos = s2;
s3 = peg$c172();
}
s2 = s3;
if (s2 === peg$FAILED) {
s2 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 114) {
s3 = peg$c173;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c174); }
}
if (s3 !== peg$FAILED) {
peg$reportedPos = s2;
s3 = peg$c175();
}
s2 = s3;
if (s2 === peg$FAILED) {
s2 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 116) {
s3 = peg$c176;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c177); }
}
if (s3 !== peg$FAILED) {
peg$reportedPos = s2;
s3 = peg$c178();
}
s2 = s3;
if (s2 === peg$FAILED) {
s2 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 117) {
s3 = peg$c179;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c180); }
}
if (s3 !== peg$FAILED) {
s4 = peg$currPos;
s5 = peg$currPos;
s6 = peg$parsehexdigit();
if (s6 !== peg$FAILED) {
s7 = peg$parsehexdigit();
if (s7 !== peg$FAILED) {
s8 = peg$parsehexdigit();
if (s8 !== peg$FAILED) {
s9 = peg$parsehexdigit();
if (s9 !== peg$FAILED) {
s6 = [s6, s7, s8, s9];
s5 = s6;
} else {
peg$currPos = s5;
s5 = peg$c7;
}
} else {
peg$currPos = s5;
s5 = peg$c7;
}
} else {
peg$currPos = s5;
s5 = peg$c7;
}
} else {
peg$currPos = s5;
s5 = peg$c7;
}
if (s5 !== peg$FAILED) {
s5 = input.substring(s4, peg$currPos);
}
s4 = s5;
if (s4 !== peg$FAILED) {
peg$reportedPos = s2;
s3 = peg$c181(s4);
s2 = s3;
} else {
peg$currPos = s2;
s2 = peg$c7;
}
} else {
peg$currPos = s2;
s2 = peg$c7;
}
}
}
}
}
}
}
}
}
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c182(s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseescape() {
var s0;
var key = peg$currPos * 86 + 81,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.charCodeAt(peg$currPos) === 92) {
s0 = peg$c162;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c163); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsequotation_mark() {
var s0;
var key = peg$currPos * 86 + 82,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (input.charCodeAt(peg$currPos) === 34) {
s0 = peg$c160;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c161); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseunescaped() {
var s0;
var key = peg$currPos * 86 + 83,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
if (peg$c183.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c184); }
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parselist() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
var key = peg$currPos * 86 + 84,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 91) {
s1 = peg$c38;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c39); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parsenewline_ws();
if (s2 !== peg$FAILED) {
s3 = peg$currPos;
s4 = peg$parseexpression();
if (s4 !== peg$FAILED) {
s5 = [];
s6 = peg$currPos;
s7 = peg$parsenewline_ws();
if (s7 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 44) {
s8 = peg$c111;
peg$currPos++;
} else {
s8 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c112); }
}
if (s8 !== peg$FAILED) {
s9 = peg$parsenewline_ws();
if (s9 !== peg$FAILED) {
s10 = peg$parseexpression();
if (s10 !== peg$FAILED) {
peg$reportedPos = s6;
s7 = peg$c185(s10);
s6 = s7;
} else {
peg$currPos = s6;
s6 = peg$c7;
}
} else {
peg$currPos = s6;
s6 = peg$c7;
}
} else {
peg$currPos = s6;
s6 = peg$c7;
}
} else {
peg$currPos = s6;
s6 = peg$c7;
}
while (s6 !== peg$FAILED) {
s5.push(s6);
s6 = peg$currPos;
s7 = peg$parsenewline_ws();
if (s7 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 44) {
s8 = peg$c111;
peg$currPos++;
} else {
s8 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c112); }
}
if (s8 !== peg$FAILED) {
s9 = peg$parsenewline_ws();
if (s9 !== peg$FAILED) {
s10 = peg$parseexpression();
if (s10 !== peg$FAILED) {
peg$reportedPos = s6;
s7 = peg$c185(s10);
s6 = s7;
} else {
peg$currPos = s6;
s6 = peg$c7;
}
} else {
peg$currPos = s6;
s6 = peg$c7;
}
} else {
peg$currPos = s6;
s6 = peg$c7;
}
} else {
peg$currPos = s6;
s6 = peg$c7;
}
}
if (s5 !== peg$FAILED) {
peg$reportedPos = s3;
s4 = peg$c11(s4, s5);
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$c7;
}
} else {
peg$currPos = s3;
s3 = peg$c7;
}
if (s3 === peg$FAILED) {
s3 = peg$c8;
}
if (s3 !== peg$FAILED) {
s4 = peg$parsenewline_ws();
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 93) {
s5 = peg$c40;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c41); }
}
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c186(s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseblock() {
var s0, s1, s2, s3, s4, s5;
var key = peg$currPos * 86 + 85,
cached = peg$cache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 123) {
s1 = peg$c52;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c53); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parsedelimiter_ws();
if (s2 !== peg$FAILED) {
s3 = peg$parsestatements();
if (s3 !== peg$FAILED) {
s4 = peg$parsedelimiter_ws();
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 125) {
s5 = peg$c54;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c55); }
}
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c187(s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
} else {
peg$currPos = s0;
s0 = peg$c7;
}
peg$cache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
peg$result = peg$startRuleFunction();
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
return peg$result;
} else {
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
peg$fail({ type: "end", description: "end of input" });
}
throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos);
}
}
return {
SyntaxError: SyntaxError,
parse: parse
};
})();
function parse(code) {
try {
return parser.parse(code);}
catch (e) { throw 'Syntax Error: Line ' + e.line + ', Column ' + e.column + ', expected: ' + JSON.stringify(e.expected) + ', got: '+ e.found + '.'; }}
if (typeof exports !== 'undefined') { if (typeof module !== 'undefined' && module.exports) { module.exports.parse = parse; } }
},{}],5:[function(require,module,exports){
var compile = require('./compiler.js').compile;
var shared = require('./shared.js');
function copy(v) {
if (v instanceof Array) {
return v.slice();
} else {
return v;
}
}
function ensureList(v) {
return v instanceof Array ? v : [v];
}
function _wrap_clamp_internal(name, func, v, bounds){
/*
x # [low,high]
[x,y] # [low,high]
[x,y] # [[lowX, highX],[lowY,highY]]
[x,y,r] # [low,high]
[x,y,r] # [[lowX, highX],[lowY,highY],[lowR,highR]]
[x,y,r] # [[lowX, highX],[lowY,highY]]
[x,y,w,h] # [low,high]
[x,y,w,h] # [[lowX, highX],[lowY,highY],[lowW,highW],[lowH,highH]]
[[x1,y1], [x2,y2]] # [low, high]
[[x1,y1], [x2,y2]] # [[[lowX1, highX1],[lowY,highY1]],[[lowX2,highX2],[lowY2,highY2]]]
[[x1,y1,w1,h1], [x2,y2]] # [[[lowX1, highX1],[lowY,highY1],[lowW, highW], [lowH, highH]],[[lowX2,highX2],[lowY2,highY2]]]
[[x1,y1,w1,h1], [x2,y2]] # [[low1,high1],[low2,high2]]
*/
if(!(v instanceof Array)) {
if(typeof v !== 'number') {
throw name + " only implemented for numeric values";
}
if (bounds instanceof Array && bounds.length === 2 && bounds.reduce(function(ok,g){return ok && (typeof g === 'number')},true)) {
// TODO: Sanitize bounds: 0 should be lower than 1, if both equal return the value of the equal bounds
return func(v, bounds);
} else {
throw name + "'s bounds should be a list containing two numbers, a low value and a high value";
}
}
if(bounds.length === 2 && typeof bounds[0] === 'number') {
return v.map(function(g){return clamp(g,bounds);});
} else if (bounds.length === v.length) {
return v.map(function(g,i){return clamp(g,bounds[i]);});
} else {
throw name + "'s bounds structure mismatch";
}
}
function clamp(v, bounds){
return _wrap_clamp_internal(
"clamp",
function(v, bounds){
return Math.max(bounds[0], Math.min(bounds[1], v));
}, v, bounds);
}
function wrap(v, bounds){
return _wrap_clamp_internal(
"wrap",
function(v, bounds){
var vPrime = v;
var boundsDelta = (bounds[1] - bounds[0]);
while (vPrime < bounds[0]) {
vPrime += boundsDelta;
}
if (vPrime >= bounds[1]) {
return vPrime - boundsDelta;
}
return vPrime;
}, v, bounds);
}
function intersection(a, b){
// This will be a very general purpose intersection function
/*
Point: [x,y]
Line: [[x1,y1], [x2,y2]]
Circle: [x, y, r]
Rect: [x, y, w, h]
Convex Polygon (Triangle, Trapezoid, Pentagon, etc.): [[x1, y1], [x2, y2], [xN, yN]...]
*/
// todo: finish
throw 'not implemented';
}
function slice(list, _start, _end){
var start = _start
if(start < 0) {
start = list.length + start;
}
var end = _end
if(end <= 0) {
end = list.length + end;
}
return list.slice(start,end);
}
function range(a,b) {
return shared.range(a,b);
}
function concat(a, b) {
return ensureList(a).concat(ensureList(b));
}
function baseOp(a,b,f,opName) {
var aA = a instanceof Array;
var bA = b instanceof Array;
if(aA || bA){
// Add scalar
if ((aA && !bA) || (bA && !aA)) {
// add scalar to all vectors
var scalar = (aA ? b : a);
return (aA ? a : b).map(function(v){
return f(v, scalar);
});
}
if(a.length !== b.length) {
throw "Cannot " + opName + " vectors of different lengths";
}
return a.map(function(v,i){ return f(v, b[i]); });
} else {
return f(a,b);
}
}
function additionOp(a,b){
return baseOp(a,b,
function(a,b){
return a + b;
}, "add");
}
function subtractionOp(a,b){
return baseOp(a,b,
function(a,b){
return a - b;
}, "subtract");
}
function divisionOp(a,b){
return baseOp(a,b,
function(a,b){
return a / b;
}, "divide");
}
function multiplicationOp(a,b){
return baseOp(a,b,
function(a,b){
return a * b;
}, "multiply");
}
function moduloOp(a,b){
return baseOp(a,b,
function(a,b){
return a % b;
}, "modulo");
}
function powOp(a,b){
return baseOp(a,b,
function(a,b){
return Math.pow(a, b);
}, "raise the power of");
}
function deepEqual(a,b) {
if(typeof a !== typeof b) return false;
if(a instanceof Array){
if (!(b instanceof Array) || a.length !== b.length) return false;
var eq = true;
var i = 0;
while(eq && i < a.length) {
eq = deepEqual(a[i],b[i]);
i++;
}
return eq;
}
// catch all for primitives and function references
return a === b;
}
var lookup = function(env, identifier) {
if(env.bindings && env.bindings[identifier] !== undefined) {
return env.bindings[identifier];
} else if(env.outer !== undefined) {
return lookup(env.outer, identifier);
} else {
return undefined;
}
};
function run(compiledCode, functions, user, system, assets, draw_implementation) {
functions = functions || {};
user = user || {};
system = system || {};
assets = assets || {};
draw_implementation = draw_implementation ||function(f){
while(true){ f(); }
};
// Execute Draw Loop as implemented by environment
function drawFunc(f){
if(isInDrawLoop===true){
throw "Can only call draw once";
}
isInDrawLoop = true;
draw_implementation(f);
}
functions = {bindings:functions, outer:undefined};
var isInDrawLoop = false;
var pushEnv = function(bindings) {
system = {bindings:bindings, outer:system};
}
var popEnv = function() {
if(system !== undefined) system = system.outer;
}
// Prime the onion variables for system
pushEnv(system, undefined);
return {value:eval(compiledCode), state:user};
}
function compileAndRun(code, verbose) {
var compiled = compile(code, verbose);
return run.apply(null, [compiled].concat(Array.prototype.slice.call(arguments,2)));
}
module.exports.run = run;
module.exports.compileAndRun = compileAndRun;
module.exports.deepEqual = deepEqual;
},{"./compiler.js":3,"./shared.js":6}],6:[function(require,module,exports){
function range(_start,end,_step) {
var start = _start;
var step = (_step === undefined ? 1 : _step);
var range = [];
var typeofStart = typeof start;
var typeofEnd = typeof end;
function onlyStringsAndNumbers(){
throw TypeError("Only string and number types are supported");
};
if (typeofEnd === "undefined") {
throw TypeError("Must pass end argument.");
} else if (typeofStart === "undefined") {
if (typeofEnd === "number") {
start = 0;
} else if (typeofEnd === "string") {
start = " ";
} else {
onlyStringsAndNumbers();
}
} else if (typeofStart !== typeofEnd) {
throw TypeError("Start and end arguments must be of same type.");
}
if (end < start) {
step = -step;
}
if (typeofEnd === "number") {
while (step > 0 ? end >= start : end <= start) {
range.push(start);
start += step;
}
} else if (typeofEnd === "string") {
if (start.length != 1 || end.length != 1) {
throw TypeError("Only strings with one character are supported.");
}
start = start.charCodeAt(0);
end = end.charCodeAt(0);
while (step > 0 ? end >= start : end <= start) {
range.push(String.fromCharCode(start));
start += step;
}
} else {
onlyStringsAndNumbers();
}
return range;
}
module.exports.range = range;
},{}],7:[function(require,module,exports){
var shared = require('./shared.js');
var MersenneTwister = require('mersenne-twister');
var hashcode = require('hashcode').hashCode().value;
var rng = new MersenneTwister();
var stdlib = {
// Write to the console
print:function(msg){ console.log(msg); },
// Crash the program
panic:function(msg) {
throw msg;
},
// Create a range of numbers as a list
range:function(start,end,step) {
return shared.range(start,end,step);
},
// Math
abs:Math.abs,
acos:Math.acos,
asin:Math.asin,
atan:Math.atan,
atan2:Math.atan2,
ceil:Math.ceil,
cos:Math.cos,
exp:Math.exp,
floor:Math.floor,
log:Math.log,
max:Math.max,
min:Math.min,
pow:Math.pow,
round:Math.round,
sign:function(v){ return typeof v !== 'number' ? (function(){throw 'can only get the sign of numbers'})() : (v === 0 ? 0 : (v < 0 ? -1 : 1))},
sin:Math.sin,
sqrt:Math.sqrt,
tan:Math.tan,
// Random
rand:function(_low, _high) {
var low = _low;
var high = _high;
if (low === undefined) {
high = 1;
low = 0;
} else if (high === undefined) {
high = low;
low = 0;
}
return (rng.random() * (high - low)) + low;
},
rand_int:function(low,high){ return Math.floor(rand(low,high+1)); },
rand_seed:function(seed) {
rng.init_seed(hashcode(seed));
}
// More math (interpolation!), Random, noise, string processing, look at processing and basic std libs!
}
module.exports.stdlib = stdlib;
},{"./shared.js":6,"hashcode":1,"mersenne-twister":2}],8:[function(require,module,exports){
var evaluate = require("../lib/runtime.js").compileAndRun;
var stdlib = require('../lib/stdlib.js').stdlib;
var state = {};
var system = {};
var assets = {};
var config = {
orientation:"portrait",
scale:5,
palette:["#162424","#456354","#9CB1A0","#DCEBE2"]
};
var dimensions = config.orientation === "landscape" ? [128,64] : (config.orientation === "portrait" ? [64,128] : [0,0]);
function orientationChanged() {
document.body.style["-webkit-transform"] = (window.orientation % 0 == 180 ? '' : 'rotate(-90deg);');
}
window.onorientationchange = orientationChanged;
window.setTimeout(orientationChanged, 1);
system['dimensions'] = dimensions;
system['width'] = dimensions[0];
system['height'] = dimensions[1];
var canvas = document.querySelector("canvas");
canvas.width = dimensions[0] * config.scale;
canvas.height = dimensions[1] * config.scale;
var canvasContext = canvas.getContext("2d");
canvasContext.mozImageSmoothingEnabled = false;
canvasContext.msImageSmoothingEnabled = false;
canvasContext.webkitImageSmoothingEnabled = false;
canvasContext.imageSmoothingEnabled = false;
var renderCanvas = document.createElement("canvas");
renderCanvas.width = dimensions[0];
renderCanvas.height = dimensions[1];
var ctx = renderCanvas.getContext("2d");
// Initialize palette
var palette = config.palette;
ctx.fillStyle = palette[0];
stdlib['color'] = function(color) {
if(typeof color === "number") {
var c = Math.floor(color);
if(c < 0 >= palette.length) {
throw "color value must be between palette size (0-" + (palette.length - 1) + ")";
}
ctx.fillStyle = palette[c];
} else {
throw "fill function expected number, got " + typeof color;
}
}
stdlib['clear'] = function() {
stdlib['rect']([0,0,canvas.width,canvas.height]);
}
stdlib['rect'] = function(r) {
ctx.fillRect(Math.round(r[0]),Math.round(r[1]),Math.round(r[2]),Math.round(r[3]));
}
// Touch events
function mapOffsetToPixel(offset, min, max){
return Math.max(min, Math.min(max, Math.floor(offset / config.scale)));
}
system['touch'] = undefined;
system['ptouch'] = undefined;
system['last_touch'] = undefined;
canvas.addEventListener('touchstart', function(e) {
system['touch'] = [mapOffsetToPixel(e.targetTouches[0].pageX - canvas.offsetLeft, 0, dimensions[0]), mapOffsetToPixel(e.targetTouches[0].pageY - canvas.offsetTop, 0, dimensions[1])];
system['last_touch'] = system['touch'];
e.preventDefault();
});
canvas.addEventListener('touchend', function(e) {
console.log(e);
system['touch'] = undefined;
e.preventDefault();
});
canvas.addEventListener('touchmove', function(e) {
if(system['touch'] !== undefined) {
system['touch'] = [mapOffsetToPixel(e.targetTouches[0].pageX - canvas.offsetLeft, 0, dimensions[0]), mapOffsetToPixel(e.targetTouches[0].pageY - canvas.offsetTop, 0, dimensions[1])];
system['last_touch'] = system['touch'];
}
e.preventDefault();
});
function draw_function(f) {
var draw_func = function(){
f();
canvasContext.drawImage(renderCanvas, 0, 0, canvas.width, canvas.height);
system['ptouch'] = system['touch'];
window.requestAnimationFrame(draw_func);
};
window.requestAnimationFrame(draw_func);
};
var gameCode = document.querySelector("script[type=\"text/tiny\"]").textContent;
evaluate(gameCode, false, stdlib, state, system, assets, draw_function);
},{"../lib/runtime.js":5,"../lib/stdlib.js":7}]},{},[8]);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment