:: prototype accessor done. npm published.
This commit is contained in:
parent
00623e5e4c
commit
1382b1c8e9
24
README.md
24
README.md
|
|
@ -2,6 +2,26 @@
|
|||
|
||||
ColaScript is a language that compiles in JavaScript. This language is similar to Dart, CoffeeScript, Python and PHP, with some original ideas. Compiler based on [UglifyJS2](https://github.com/mishoo/UglifyJS2). In present time compiler in development. Play with language you can [here](http://develop.trigen.pro/cola/).
|
||||
|
||||
# Install
|
||||
|
||||
First make sure you have installed the latest version of [node.js](http://nodejs.org/)
|
||||
(You may need to restart your computer after this step).
|
||||
|
||||
From NPM for use as a command line app:
|
||||
|
||||
npm install cola-script -g
|
||||
|
||||
From NPM for programmatic use:
|
||||
|
||||
npm install cola-script
|
||||
|
||||
From Git:
|
||||
|
||||
git clone git://github.com/TrigenSoftware/ColaScript.git
|
||||
cd ColaScript
|
||||
npm link .
|
||||
|
||||
|
||||
# to do:
|
||||
|
||||
- semicolon is always required, status: done
|
||||
|
|
@ -93,7 +113,7 @@ ColaScript is a language that compiles in JavaScript. This language is similar t
|
|||
|
||||
@include "./app/my.js"
|
||||
|
||||
- `@use`
|
||||
- `@use`, status: done
|
||||
|
||||
@use strict
|
||||
@use asmjs
|
||||
|
|
@ -311,4 +331,4 @@ ColaScript is a language that compiles in JavaScript. This language is similar t
|
|||
### Statistic
|
||||
|
||||
- 33 features ( without classes )
|
||||
- 30 done
|
||||
- 33 done
|
||||
|
|
|
|||
|
|
@ -687,6 +687,15 @@ Cola.AST_Dot = Cola.DEFNODE("Dot", null, {
|
|||
}
|
||||
}, Cola.AST_PropAccess);
|
||||
|
||||
Cola.AST_Proto = Cola.DEFNODE("Proto", null, {
|
||||
$documentation: "Accessor to prototype",
|
||||
_walk: function(visitor) {
|
||||
return visitor._visit(this, function(){
|
||||
this.expression._walk(visitor);
|
||||
});
|
||||
}
|
||||
}, Cola.AST_PropAccess);
|
||||
|
||||
Cola.AST_Cascade = Cola.DEFNODE("Cascade", "expression subexpressions", {
|
||||
$documentation: "Base class for properties access expressions, i.e. `a..foo..bar`",
|
||||
$propdoc: {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,17 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>ColaScript Playground</title>
|
||||
<script src="../cola.js"></script>
|
||||
<script src="../demo.cola" type="text/colascript"></script>
|
||||
<script src="./utils.js"></script>
|
||||
<script src="./ast.js"></script>
|
||||
<script src="./parse.js"></script>
|
||||
<script src="./transform.js"></script>
|
||||
<script src="./scope.js"></script>
|
||||
<script src="./output.js"></script>
|
||||
<script src="./compress.js"></script>
|
||||
<script src="./sourcemap.js"></script>
|
||||
<script src="./mozilla-ast.js"></script>
|
||||
<script src="./translate.js"></script>
|
||||
<script src="./std.js"></script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
|
|
|
|||
19
lib/parse.js
19
lib/parse.js
|
|
@ -146,6 +146,7 @@ Cola.COMPARISON = Cola.makePredicate("< > <= >= == === != !==");
|
|||
|
||||
Cola.WHITESPACE_CHARS = Cola.makePredicate(Cola.characters(" \u00a0\n\r\t\f\u000b\u200b\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000"));
|
||||
|
||||
Cola.cPUNC_BEFORE_EXPRESSION = Cola.makePredicate(Cola.characters("[{(,.;:").concat(["::"]));
|
||||
Cola.PUNC_BEFORE_EXPRESSION = Cola.makePredicate(Cola.characters("[{(,.;:"));
|
||||
|
||||
Cola.PUNC_CHARS = Cola.makePredicate(Cola.characters("[]{}(),;:"));
|
||||
|
|
@ -274,12 +275,14 @@ Cola.Tokenizer = function ($TEXT, filename, is_js, html5_comments) {
|
|||
this.OPERATORS = Cola.OPERATORS;
|
||||
this.UNARY_POSTFIX = Cola.UNARY_POSTFIX;
|
||||
this.KEYWORDS_BEFORE_EXPRESSION = Cola.KEYWORDS_BEFORE_EXPRESSION;
|
||||
this.PUNC_BEFORE_EXPRESSION = Cola.PUNC_BEFORE_EXPRESSION;
|
||||
} else {
|
||||
this.KEYWORDS = Cola.cKEYWORDS;
|
||||
this.KEYWORDS_ATOM = Cola.cKEYWORDS_ATOM;
|
||||
this.OPERATORS = Cola.cOPERATORS;
|
||||
this.UNARY_POSTFIX = Cola.cUNARY_POSTFIX;
|
||||
this.KEYWORDS_BEFORE_EXPRESSION = Cola.cKEYWORDS_BEFORE_EXPRESSION;
|
||||
this.PUNC_BEFORE_EXPRESSION = Cola.cPUNC_BEFORE_EXPRESSION;
|
||||
}
|
||||
|
||||
this.is_js = !!is_js;
|
||||
|
|
@ -356,8 +359,8 @@ Cola.Tokenizer.prototype.start_token = function () {
|
|||
Cola.Tokenizer.prototype.token = function (type, value, is_comment) {
|
||||
this.S.regex_allowed = ((type == "operator" && !this.UNARY_POSTFIX(value)) ||
|
||||
(type == "keyword" && this.KEYWORDS_BEFORE_EXPRESSION(value)) ||
|
||||
(type == "punc" && Cola.PUNC_BEFORE_EXPRESSION(value)));
|
||||
this.prev_was_dot = (type == "punc" && value == ".");
|
||||
(type == "punc" && this.PUNC_BEFORE_EXPRESSION(value)));
|
||||
this.prev_was_dot = (type == "punc" && value == ".") || (!this.is_js && type == "punc" && value == "::");
|
||||
var ret = {
|
||||
type : type,
|
||||
value : value,
|
||||
|
|
@ -704,6 +707,9 @@ Cola.Tokenizer.prototype.next_token = function (force_regexp) {
|
|||
}
|
||||
if (Cola.is_digit(code)) return this.read_num();
|
||||
if (Cola.PUNC_CHARS(ch)){
|
||||
|
||||
if (!this.is_js && ch == ":" && this.peek(1) == ":") return this.next(), this.next(), this.token("punc", "::");
|
||||
|
||||
if (!this.is_js && this.S.string.at[this.S.string.level].inside && (this.S.string.at[this.S.string.level].inside_at || this.S.string.at[this.S.string.level].inside_braces)) {
|
||||
if (ch == '{') this.S.string.at[this.S.string.level].balance++;
|
||||
else if (ch == '}') this.S.string.at[this.S.string.level].balance--;
|
||||
|
|
@ -2004,6 +2010,15 @@ Cola.Parser.prototype.subscripts = function(expr, allow_calls) {
|
|||
end : this.prev()
|
||||
}), allow_calls);
|
||||
}
|
||||
if (this.is("punc", "::") && !this.is_js) {
|
||||
this.next();
|
||||
return this.subscripts(new Cola.AST_Proto({
|
||||
start : start,
|
||||
expression : expr,
|
||||
property : this.as_name(),
|
||||
end : this.prev()
|
||||
}), allow_calls);
|
||||
}
|
||||
if (this.is("punc", "[")) {
|
||||
this.next();
|
||||
|
||||
|
|
|
|||
|
|
@ -1678,7 +1678,7 @@ Cola.AST_Toplevel.prototype.toJavaScript = function(options){
|
|||
if(node instanceof Cola.AST_When){
|
||||
node = new Cola.AST_Case(node);
|
||||
node.body.push(new Cola.AST_Break);
|
||||
}
|
||||
} else
|
||||
|
||||
/*
|
||||
switch (g) {
|
||||
|
|
@ -1706,7 +1706,26 @@ Cola.AST_Toplevel.prototype.toJavaScript = function(options){
|
|||
}
|
||||
|
||||
node = branches;
|
||||
}
|
||||
} else
|
||||
|
||||
/*
|
||||
MyClass::prop = (){
|
||||
|
||||
};
|
||||
|
||||
to
|
||||
|
||||
MyClass.prototype.prop = (){
|
||||
|
||||
};
|
||||
|
||||
*/
|
||||
if(node instanceof Cola.AST_Proto){
|
||||
props = new Cola.AST_Dot(node);
|
||||
props.expression = new Cola.AST_Dot(node);
|
||||
props.expression.property = "prototype";
|
||||
node = props;
|
||||
} else
|
||||
|
||||
/*
|
||||
"test @a @{b} {{c}}"
|
||||
|
|
|
|||
27
package.json
27
package.json
|
|
@ -1,30 +1,25 @@
|
|||
{
|
||||
"name": "uglify-js",
|
||||
"description": "JavaScript parser, mangler/compressor and beautifier toolkit",
|
||||
"homepage": "http://lisperator.net/uglifyjs",
|
||||
"name": "cola-script",
|
||||
"description": "ColaScript translator / parser / mangler / compressor / beautifier toolkit",
|
||||
"homepage": "https://github.com/TrigenSoftware/ColaScript",
|
||||
"main": "tools/node.js",
|
||||
"version": "2.4.12",
|
||||
"version": "0.5.0",
|
||||
"engines": { "node" : ">=0.4.0" },
|
||||
"maintainers": [{
|
||||
"name": "Mihai Bazon",
|
||||
"email": "mihai.bazon@gmail.com",
|
||||
"web": "http://lisperator.net/"
|
||||
"name": "Dan Onoshko (dangreen)",
|
||||
"email": "danpn0404@gmail.com",
|
||||
"web": "http://trigen.pro/"
|
||||
}],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mishoo/UglifyJS2.git"
|
||||
"url": "https://github.com/TrigenSoftware/ColaScript.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"async" : "~0.2.6",
|
||||
"source-map" : "~0.1.33",
|
||||
"optimist" : "~0.3.5",
|
||||
"uglify-to-browserify": "~1.0.0"
|
||||
},
|
||||
"browserify": {
|
||||
"transform": [ "uglify-to-browserify" ]
|
||||
"optimist" : "~0.3.5"
|
||||
},
|
||||
"bin": {
|
||||
"uglifyjs" : "bin/uglifyjs"
|
||||
},
|
||||
"scripts": {"test": "node test/run-tests.js"}
|
||||
"cola" : "bin/cola"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user