initial commit taken from gitlab.lrz.de

This commit is contained in:
privatereese
2018-08-24 18:09:42 +02:00
parent ae54ed4c48
commit fc05486403
28494 changed files with 2159823 additions and 0 deletions

22
node_modules/art/lib/ast-js/Demos/helloworld.html generated vendored Normal file
View File

@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>HelloWorld.js</title>
</head>
<body>
<script>var require = function(){return module.exports;}, module={};</script>
<script src="../src/program.js"></script>
<script src="../src/statement.js"></script>
<script src="../src/expression.js"></script>
<script src="../src/block.js"></script>
<script src="../src/literal.js"></script>
<script src="../src/operator.js"></script>
<script src="../src/variable.js"></script>
<script src="../src/property.js"></script>
<script src="../src/assignment.js"></script>
<script src="../src/condition.js"></script>
<script src="../src/function.js"></script>
<script src="../src/call.js"></script>
<script src="helloworld.js"></script>
</body>
</html>

21
node_modules/art/lib/ast-js/Demos/helloworld.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
var a = new AST.Variable('astr');
var b = new AST.Variable('bstr');
var alertFn = new AST.Variable('alert');
var newFn = new AST.Function(
[a, b], null,
alertFn.call(a.add(b))
);
newFn.compile()('Hello', ' world');
var klass = new AST.Variable('Class').construct({
initialize: newFn
});
var ast = new AST(new AST.Variable('MyClass').assign(klass));
alert(ast.toString());

13
node_modules/art/lib/ast-js/README.md generated vendored Normal file
View File

@@ -0,0 +1,13 @@
AST.js
======
Provides an Abstract Syntax Tree (AST) to generate ECMAScript code.
TODO:
- Add parentheses around expressions when necessary
- Nice indented formatting with options
- Rename invalid or scope colliding variable names
- Escape dangerous characters in regular expression literals
- Statements: for, while, do, switch, with, delete, typeof, instanceof
- Comments
- Lexical parser

13
node_modules/art/lib/ast-js/ast.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
var AST = require('./src/program');
require('./src/statement');
require('./src/expression');
require('./src/block');
require('./src/literal');
require('./src/operator');
require('./src/variable');
require('./src/property');
require('./src/assignment');
require('./src/condition');
require('./src/function');
require('./src/call');
module.exports = AST;

21
node_modules/art/lib/ast-js/license.txt generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License
Copyright (c) 2010 Calyptus Life AB <http://calyptus.eu>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

75
node_modules/art/lib/ast-js/src/assignment.js generated vendored Normal file
View File

@@ -0,0 +1,75 @@
var AST = require('./program');
var err = 'Assignment is only possible on variables or properties.',
posterr = 'Only the literal 1 is possible for post assignments.',
assignableOps = /[\+\-\*\/\%]/;
AST.Assignment = function(left, right){
if (!(left instanceof AST.Variable || left instanceof AST.Property)) throw new Error(err);
this.left = left;
this.right = AST.Expression(right);
};
AST.Assignment.prototype = new AST.Expression();
AST.Assignment.prototype.writeTo = function(writer, format){
var left = this.left, right = this.right;
left.writeTo(writer, format);
if (right instanceof AST.Operator && right.left === left && assignableOps.test(right.operator)){
if (right.right instanceof AST.Literal && right.right.value == 1){
if (right.operator == '+'){
writer('++');
return;
} else if (right.operator == '-'){
writer('--');
return;
}
}
writer(' ' + right.operator + '= ');
right = right.right;
} else {
writer(' = ');
}
right.writeTo(writer, format);
};
AST.PostAssignment = function(left, right, operator){
if (!(left instanceof AST.Variable || left instanceof AST.Property)) throw new Error(err);
this.left = left;
this.operator = operator;
this.right = AST.Expression(right);
if (!(this.right instanceof AST.Operator) || this.right.left !== left || !(this.right.right instanceof AST.Literal) || this.right.right.value != 1) throw new Error(posterr);
}
AST.PostAssignment.prototype = new AST.Expression();
AST.PostAssignment.prototype.writeTo = function(writer, format){
this.expression.writeTo(writer, format);
writer(this.operator + this.operator);
};
AST.Expression.prototype.assignTo = function(expr){
return new AST.Assignment(expr, this);
};
AST.Variable.prototype.assign = AST.Property.prototype.assign = function(expr){
return new AST.Assignment(this, expr);
};
AST.Variable.prototype.increment = AST.Property.prototype.increment = function(){
return new AST.Assignment(this, new AST.Add(this, 1));
};
AST.Variable.prototype.decrement = AST.Property.prototype.decrement = function(){
return new AST.Assignment(this, new AST.Subtract(this, 1));
};
AST.Variable.prototype.postIncrement = AST.Property.prototype.postIncrement = function(){
return new AST.PostAssignment(this, new AST.Add(this, 1));
};
AST.Variable.prototype.postDecrement = AST.Property.prototype.postDecrement = function(){
return new AST.PostAssignment(this, new AST.Subtract(this, 1));
};

46
node_modules/art/lib/ast-js/src/block.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
var AST = require('./program');
AST.Block = function(obj){
if (this instanceof AST.Block){
if (Object.prototype.toString.call(obj) == '[object Array]')
this.statements = Array.prototype.slice.call(obj);
else
this.statements = Array.prototype.slice.call(arguments);
return;
}
if (obj instanceof AST.Block) return obj;
var block = new AST.Block();
if (Object.prototype.toString.call(obj) == '[object Array]')
block.statements = Array.prototype.slice.call(obj);
else
block.statements = [obj];
return block;
};
AST.Block.prototype = {
writeTo: function(writer, format, curly){
var body = this.statements;
if (!body || !body.length) return;
for (var i = 0, l = body.length; i < l; i++){
var expr = body[i];
if (!(expr instanceof AST.Statement)) body[i] = expr = new AST.Literal(expr);
if (expr instanceof AST.Assignment && expr.left instanceof AST.Variable) writer('var '); // Temp hack - breaks sometimes
expr.writeTo(writer, format);
writer(';\n');
}
},
toString: function(format){
var output = [];
this.writeTo(function(str){
output.push(str);
}, format);
return output.join('');
}
};
AST.prototype = AST.Block.prototype;

43
node_modules/art/lib/ast-js/src/call.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
var AST = require('./program');
AST.Call = function(expr, args){
this.expression = AST.Expression(expr);
var l = args ? args.length : 0;
this.arguments = new Array(l);
for (var i = 0; i < l; i++) this.arguments[i] = AST.Expression(args[i]);
};
AST.Call.prototype = new AST.Expression();
AST.Call.prototype.writeTo = function(write, format){
this.expression.writeTo(write, format);
write('(');
var args = this.arguments;
if (args.length > 0){
args[0].writeTo(write, format);
for (var i = 1, l = args.length; i < l; i++){
write(', ');
args[i].writeTo(write, format);
}
}
write(')');
};
AST.New = function(){
AST.Call.apply(this, arguments);
};
AST.New.prototype = new AST.Call();
AST.New.prototype.writeTo = function(write, format){
write('new ');
AST.Call.prototype.writeTo.call(this, write, format);
};
AST.Expression.prototype.call = function(){
return new AST.Call(this, arguments);
};
AST.Expression.prototype.construct = function(){
return new AST.New(this, arguments);
};

36
node_modules/art/lib/ast-js/src/condition.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
var AST = require('./program');
AST.Ternary = function(condition, then, els){
this.condition = AST.Expression(condition);
this.then = AST.Expression(then);
this.els = AST.Expression(els);
};
AST.Ternary.prototype = new AST.Expression();
AST.Ternary.prototype.writeTo = function(write, format){
this.condition.writeTo(write, format);
write(' ? ');
this.then.writeTo(write, format);
write(' : ');
this.els.writeTo(write, format);
};
AST.If = function(condition, then, els){
this.condition = condition;
this.then = then;
this.els = els;
};
AST.If.prototype = new AST.Statement();
AST.If.prototype.writeTo = function(write, format){
write('if (');
this.condition.writeTo(write, format);
write(')');
this.then.writeTo(write, format);
if (this.els){
write(' else ');
this.els.writeTo(write, format);
}
};

9
node_modules/art/lib/ast-js/src/expression.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
var AST = require('./program');
AST.Expression = function(obj){
if (arguments.length == 0) return;
if (obj && typeof obj.toExpression == 'function') obj = obj.toExpression();
return obj instanceof AST.Expression ? obj : new AST.Literal(obj);
};
AST.Expression.prototype = new AST.Statement();

44
node_modules/art/lib/ast-js/src/function.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
var AST = require('./program');
AST.Function = function(name, args, variables, statements){
if (typeof name != 'string'){
statements = variables;
variables = args;
args = name;
name = null;
}
if (statements instanceof AST.Expression) statements = new AST.Return(statements);
statements = AST.Block(statements);
this.name = name;
this.arguments = args;
this.statements = statements;
this.variables = variables;
};
AST.Function.prototype = new AST.Expression();
AST.Function.prototype.writeTo = function(write, format){
write(this.name ? 'function ' + this.name + '(' : 'function(');
if (this.arguments){
for (var i = 0, l = this.arguments.length; i < l; i++){
if (i > 0) write(', ');
write(this.arguments[i].name);
}
}
write('){\n');
this.statements.writeTo(write, format);
write('}');
};
AST.Function.prototype.compile = function(){
var l = this.arguments.length,
args = new Array(l + 1),
body = [];
for (var i = 0; i < l; i++) args[i] = this.arguments[i].name;
this.statements.writeTo(function(str){ body.push(str); });
args[l] = body.join('');
return Function.apply(Function, args);
};

75
node_modules/art/lib/ast-js/src/literal.js generated vendored Normal file
View File

@@ -0,0 +1,75 @@
var AST = require('./program');
// Based on the MooTools JSON implementation
var specialChars = {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\'},
escapable = new RegExp('[\\\\"\\x00-\\x1f]', 'g'), // RegExp Literal doesn't work in ExtendScript
replaceChars = function(chr){
return specialChars[chr] || ('\\u00' + Math.floor(chr.charCodeAt() / 16).toString(16) + (chr.charCodeAt() % 16).toString(16));
},
encode = function(write, obj, format){
if (obj === null){
write('null');
return;
}
if (typeof obj === 'undefined'){
write('undefined');
return;
}
if (typeof obj.toExpression == 'function')
{
obj = obj.toExpression();
}
if (obj instanceof AST.Expression){
obj.writeTo(write, format);
return;
}
if (typeof obj == 'string'){
write('"' + obj.replace(escapable, replaceChars) + '"');
return;
}
if (typeof obj == 'object' && Object.prototype.toString.call(obj) != '[object RegExp]'){
var first = true;
if (Object.prototype.toString.call(obj) == '[object Array]'){
write('[');
for (var i = 0, l = obj.length; i < l; i++){
if (!Object.hasOwnProperty.call(obj, key)) continue;
if (first) first = false; else write(', ');
encode(write, obj, format);
}
write(']');
} else {
write('{');
for (var key in obj){
if (!Object.hasOwnProperty.call(obj, key)) continue;
if (first) first = false; else write(', ');
encode(write, key, format);
write(': ');
encode(write, obj[key], format);
}
write('}');
}
return;
}
write(String(obj));
};
AST.Literal = function(value){
this.value = value;
};
AST.Literal.prototype = new AST.Expression();
AST.Literal.prototype.writeTo = function(writer, format){
encode(writer, this.value, format);
};

72
node_modules/art/lib/ast-js/src/operator.js generated vendored Normal file
View File

@@ -0,0 +1,72 @@
var AST = require('./program');
AST.Operator = function(left, operator, right){
this.left = AST.Expression(left);
this.operator = operator;
this.right = AST.Expression(right);
};
AST.Operator.prototype = new AST.Expression();
AST.Operator.prototype.writeTo = function(write, format){
this.left.writeTo(write, format);
write(' ' + this.operator + ' ');
this.right.writeTo(write, format);
};
AST.Not = function(expr){
this.expression = expr;
};
AST.Not.prototype = new AST.Expression();
AST.Not.prototype.writeTo = function(write, format){
write('!');
this.expression.writeTo(write, format);
};
AST.Expression.prototype.not = function(){
return new AST.Not(this);
};
var operators = {
Equals: '==',
NotEquals: '!=',
StrictEquals: '===',
StrictNotEquals: '!==',
LessThan: '<',
MoreThan: '>',
LessThanOrEquals: '<=',
MoreThanOrEquals: '>=',
And: '&&',
Or: '||',
BitwiseAnd: '&',
BitwiseOr: '|',
BitwiseXor: '^',
LeftShift: '<<',
RightShift: '>>',
ZeroFillRightShift: '>>>',
Add: '+',
Subtract: '-',
Multiply: '*',
Divide: '/',
Mod: '%'
};
for (var key in operators) (function(name, cname, op){
AST[name] = function(left, right){
return new AST.Operator(left, op, right);
};
AST.Expression.prototype[cname] = function(expr){
return new AST[name](this, expr);
};
})(key, key.substr(0, 1).toLowerCase() + key.substr(1), operators[key]);

7
node_modules/art/lib/ast-js/src/program.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
var AST = function(){
return AST.Block.apply(this, arguments);
};
module.exports = AST;

26
node_modules/art/lib/ast-js/src/property.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
var AST = require('./program');
AST.Property = function(expr, name){
this.expression = AST.Expression(expr);
this.name = AST.Expression(name);
};
AST.Property.prototype = new AST.Expression();
AST.Property.prototype.writeTo = function(write, format){
this.expression.writeTo(write, format);
if (this.name instanceof AST.Literal && this.name.value){
write('.');
write(String(this.name.value));
return;
}
write('[');
this.name.writeTo(write, format);
write(']');
};
AST.Expression.prototype.property = function(name){
return new AST.Property(this, name);
};

41
node_modules/art/lib/ast-js/src/statement.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
var AST = require('./program');
AST.Statement = function(label){
this.label = label;
};
AST.Statement.prototype = {
writeTo: function(compressed){ },
toString: function(compressed){
var output = [];
this.writeTo(function(str){
output.push(str);
}, compressed);
return output.join('');
}
};
AST.Return = function(expr){
if (arguments.length) this.expression = AST.Expression(expr);
};
AST.Return.prototype = new AST.Statement();
AST.Return.prototype.writeTo = function(write, format){
write('return');
if (!this.expression) return;
write(' ');
this.expression.writeTo(write, format);
};
AST.Break = function(){
};
AST.Break.prototype = new AST.Statement();
AST.Break.prototype.writeTo = function(write, format){
write('break');
};

20
node_modules/art/lib/ast-js/src/variable.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
var AST = require('./program');
AST.Variable = function(name){
this.name = name;
};
AST.Variable.prototype = new AST.Expression();
AST.Variable.prototype.writeTo = function(write){
write(this.name);
};
AST.This = function(){
};
AST.This.prototype = new AST.Expression();
AST.This.prototype.writeTo = function(write){
write('this');
};