From 869e1f86aad6cf31a8fe3a0c6b477b871d3fcdbd Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 14 Dec 2013 19:37:24 +0400 Subject: [PATCH 1/8] cleanup d mode --- lib/ace/mode/d_highlight_rules.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ace/mode/d_highlight_rules.js b/lib/ace/mode/d_highlight_rules.js index b0a0923e..843bcec6 100644 --- a/lib/ace/mode/d_highlight_rules.js +++ b/lib/ace/mode/d_highlight_rules.js @@ -191,7 +191,7 @@ var DHighlightRules = function() { "star-comment" : [ { token : "comment", // closing comment - regex : ".*?\\*\\/", + regex : "\\*\\/", next : "start" }, { defaultToken: 'comment' @@ -200,7 +200,7 @@ var DHighlightRules = function() { "plus-comment" : [ { token : "comment", // closing comment - regex : ".*?\\+\\/", + regex : "\\+\\/", next : "start" }, { defaultToken: 'comment' @@ -211,7 +211,7 @@ var DHighlightRules = function() { stringEscapesSeq, { token : "string", - regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"[cdw]?', + regex : '"[cdw]?', next : "start" }, { defaultToken: 'string' @@ -222,7 +222,7 @@ var DHighlightRules = function() { stringEscapesSeq, { token : "string", - regex : '(?:(?:\\\\.)|(?:[^`\\\\]))*?`[cdw]?', + regex : '`[cdw]?', next : "start" }, { defaultToken: 'string' @@ -234,7 +234,7 @@ var DHighlightRules = function() { onMatch: function(value, currentState, state) { value = value.substring(value.length-2, value.length-1); var map = {'>':'<',']':'[',')':'(','}':'{'}; - if(Object.keys(map).indexOf(value) != -1) + if(Object.keys(map).indexOf(value) != -1) value = map[value]; if(value != state[1]) return "string"; state.shift(); From 61591eee5d1a5e714661635567285864b686561c Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 14 Dec 2013 19:41:44 +0400 Subject: [PATCH 2/8] add tests --- lib/ace/mode/_test/tokens_ada.json | 39 + lib/ace/mode/_test/tokens_cobol.json | 4 + lib/ace/mode/_test/tokens_d.json | 111 ++ lib/ace/mode/_test/tokens_handlebars.json | 81 + lib/ace/mode/_test/tokens_jack.json | 1786 +++++++++++++++++++ lib/ace/mode/_test/tokens_mel.json | 257 +++ lib/ace/mode/_test/tokens_protobuf.json | 136 ++ lib/ace/mode/_test/tokens_sjs.json | 276 +++ lib/ace/mode/_test/tokens_soy_template.json | 287 +++ lib/ace/mode/_test/tokens_space.json | 322 ++++ lib/ace/mode/_test/tokens_verilog.json | 113 ++ lib/ace/mode/_test/tokens_vhdl.json | 271 +++ 12 files changed, 3683 insertions(+) create mode 100644 lib/ace/mode/_test/tokens_ada.json create mode 100644 lib/ace/mode/_test/tokens_cobol.json create mode 100644 lib/ace/mode/_test/tokens_d.json create mode 100644 lib/ace/mode/_test/tokens_handlebars.json create mode 100644 lib/ace/mode/_test/tokens_jack.json create mode 100644 lib/ace/mode/_test/tokens_mel.json create mode 100644 lib/ace/mode/_test/tokens_protobuf.json create mode 100644 lib/ace/mode/_test/tokens_sjs.json create mode 100644 lib/ace/mode/_test/tokens_soy_template.json create mode 100644 lib/ace/mode/_test/tokens_space.json create mode 100644 lib/ace/mode/_test/tokens_verilog.json create mode 100644 lib/ace/mode/_test/tokens_vhdl.json diff --git a/lib/ace/mode/_test/tokens_ada.json b/lib/ace/mode/_test/tokens_ada.json new file mode 100644 index 00000000..bdef7256 --- /dev/null +++ b/lib/ace/mode/_test/tokens_ada.json @@ -0,0 +1,39 @@ +[[ + "start", + ["keyword","with"], + ["text"," "], + ["identifier","Ada"], + ["text","."], + ["identifier","Text_IO"], + ["text","; "], + ["keyword","use"], + ["text"," "], + ["identifier","Ada"], + ["text","."], + ["identifier","Text_IO"], + ["text",";"] +],[ + "start", + ["keyword","procedure"], + ["text"," "], + ["identifier","Hello"], + ["text"," "], + ["keyword","is"] +],[ + "start", + ["keyword","begin"] +],[ + "start", + ["text"," "], + ["identifier","Put_Line"], + ["paren.lparen","("], + ["string","\"Hello, world!\""], + ["paren.rparen",")"], + ["text",";"] +],[ + "start", + ["keyword","end"], + ["text"," "], + ["identifier","Hello"], + ["text",";"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_cobol.json b/lib/ace/mode/_test/tokens_cobol.json new file mode 100644 index 00000000..9909eadd --- /dev/null +++ b/lib/ace/mode/_test/tokens_cobol.json @@ -0,0 +1,4 @@ +[[ + "start", + ["identifier","TODO"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_d.json b/lib/ace/mode/_test/tokens_d.json new file mode 100644 index 00000000..85831cc3 --- /dev/null +++ b/lib/ace/mode/_test/tokens_d.json @@ -0,0 +1,111 @@ +[[ + "start", + ["comment.shebang","#!/usr/bin/env rdmd"] +],[ + "start", + ["comment","// Computes average line length for standard input."] +],[ + "start", + ["keyword","import"], + ["text"," "], + ["variable.module","std.stdio"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["keyword.type","void"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword.type","ulong"], + ["text"," "], + ["identifier","lines"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.type","double"], + ["text"," "], + ["identifier","sumLength"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.control","foreach"], + ["text"," "], + ["paren.lparen","("], + ["identifier","line"], + ["punctuation.operator",";"], + ["text"," "], + ["identifier","stdin"], + ["punctuation.operator","."], + ["identifier","byLine"], + ["paren.lparen","("], + ["paren.rparen","))"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword.operator","++"], + ["identifier","lines"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["identifier","sumLength"], + ["text"," "], + ["keyword.operator","+="], + ["text"," "], + ["identifier","line"], + ["punctuation.operator","."], + ["identifier","length"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["identifier","writeln"], + ["paren.lparen","("], + ["string","\"Average line length: \""], + ["punctuation.operator",","] +],[ + "start", + ["text"," "], + ["identifier","lines"], + ["text"," "], + ["keyword.operator","?"], + ["text"," "], + ["identifier","sumLength"], + ["text"," "], + ["keyword.operator","/"], + ["text"," "], + ["identifier","lines"], + ["text"," "], + ["punctuation.operator",":"], + ["text"," "], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["paren.rparen","}"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_handlebars.json b/lib/ace/mode/_test/tokens_handlebars.json new file mode 100644 index 00000000..babcd88b --- /dev/null +++ b/lib/ace/mode/_test/tokens_handlebars.json @@ -0,0 +1,81 @@ +[[ + "start", + ["comment.start","{{!--"], + ["comment"," Ace + :-}} "], + ["comment.end","--}}"] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.begin","<"], + ["meta.tag.name","div"], + ["text"," "], + ["entity.other.attribute-name","id"], + ["keyword.operator.separator","="], + ["string","\"comments\""], + ["meta.tag.punctuation.end",">"] +],[ + "start", + ["text"," "], + ["storage.type.start","{{#"], + ["variable.parameter","each"], + ["text"," "], + ["variable.parameter","comments"], + ["storage.type.end","}}"] +],[ + "start", + ["text"," "], + ["meta.tag.punctuation.begin","<"], + ["meta.tag.name","h2"], + ["meta.tag.punctuation.end",">"], + ["meta.tag.punctuation.begin","<"], + ["meta.tag.name.anchor","a"], + ["text"," "], + ["entity.other.attribute-name","href"], + ["keyword.operator.separator","="], + ["string","\"/posts/"], + ["storage.type.start","{{"], + ["text","../"], + ["variable.parameter","permalink"], + ["storage.type.end","}}"], + ["string","#"], + ["storage.type.start","{{"], + ["variable.parameter","id"], + ["storage.type.end","}}"], + ["string","\""], + ["meta.tag.punctuation.end",">"], + ["storage.type.start","{{"], + ["variable.parameter","title"], + ["storage.type.end","}}"], + ["meta.tag.punctuation.begin",""], + ["meta.tag.punctuation.begin",""] +],[ + "start", + ["text"," "], + ["meta.tag.punctuation.begin","<"], + ["meta.tag.name","div"], + ["meta.tag.punctuation.end",">"], + ["storage.type.start","{{"], + ["variable.parameter","body"], + ["storage.type.end","}}"], + ["meta.tag.punctuation.begin",""] +],[ + "start", + ["text"," "], + ["storage.type.start","{{/"], + ["variable.parameter","each"], + ["storage.type.end","}}"] +],[ + "start", + ["meta.tag.punctuation.begin",""] +],[ + "start" +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_jack.json b/lib/ace/mode/_test/tokens_jack.json new file mode 100644 index 00000000..c3d694dd --- /dev/null +++ b/lib/ace/mode/_test/tokens_jack.json @@ -0,0 +1,1786 @@ +[[ + "start", + ["keyword","vars"], + ["text"," "], + ["variable","it"], + ["text",", "], + ["variable","p"] +],[ + "start" +],[ + "start", + ["variable","p"], + ["text"," = "], + ["paren.lparen","{"], + ["variable","label"], + ["text",", "], + ["variable","value"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\""], + ["constant.language.escape","\\n"], + ["string","\""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","label"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["language.builtin","inspect"], + ["paren.lparen","("], + ["variable","value"], + ["paren.rparen","))"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start", + ["comment","-- Create an array from 0 to 15"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"range\""], + ["text",", "], + ["language.builtin","i-collect"], + ["paren.lparen","("], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","5"], + ["paren.rparen",")))"] +],[ + "start" +],[ + "start", + ["comment","-- Create an array from 0 to 15 and break up in chunks of 4"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"chunked range\""], + ["text",", "], + ["language.builtin","i-collect"], + ["paren.lparen","("], + ["language.builtin","i-chunk"], + ["paren.lparen","("], + ["constant.numeric","4"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","16"], + ["paren.rparen","))))"] +],[ + "start" +],[ + "start", + ["comment","-- Check if all or none items in stream pass test."] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"all < 60 in range(60)\""], + ["text",", "], + ["variable","i-all?"], + ["paren.lparen","({"], + ["variable","i"], + ["text","|"], + ["variable","i"], + ["keyword.operator","<"], + ["constant.numeric","60"], + ["paren.rparen","}"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","60"], + ["paren.rparen",")))"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"any < 60 in range(60)\""], + ["text",", "], + ["variable","i-any?"], + ["paren.lparen","({"], + ["variable","i"], + ["text","|"], + ["variable","i"], + ["keyword.operator",">"], + ["constant.numeric","60"], + ["paren.rparen","}"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","60"], + ["paren.rparen",")))"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"all < 60 in range(70)\""], + ["text",", "], + ["variable","i-all?"], + ["paren.lparen","({"], + ["variable","i"], + ["text","|"], + ["variable","i"], + ["keyword.operator","<"], + ["constant.numeric","60"], + ["paren.rparen","}"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","70"], + ["paren.rparen",")))"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"any < 60 in range(70)\""], + ["text",", "], + ["variable","i-any?"], + ["paren.lparen","({"], + ["variable","i"], + ["text","|"], + ["variable","i"], + ["keyword.operator",">"], + ["constant.numeric","60"], + ["paren.rparen","}"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","70"], + ["paren.rparen",")))"] +],[ + "start" +],[ + "start", + ["comment","-- Zip three different collections together"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"zipped\""], + ["text",", "], + ["language.builtin","i-collect"], + ["paren.lparen","("], + ["language.builtin","i-zip"], + ["paren.lparen","("] +],[ + "start", + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["paren.rparen",")"], + ["text",","] +],[ + "start", + ["text"," "], + ["paren.lparen","["], + ["constant.numeric","1"], + ["text",","], + ["constant.numeric","2"], + ["text",","], + ["constant.numeric","3"], + ["text",","], + ["constant.numeric","4"], + ["text",","], + ["constant.numeric","5"], + ["paren.rparen","]"], + ["text",","] +],[ + "start", + ["text"," "], + ["language.builtin","i-map"], + ["paren.lparen","({"], + ["variable","i"], + ["text","|"], + ["variable","i"], + ["keyword.operator","*"], + ["variable","i"], + ["paren.rparen","}"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["paren.rparen","))"] +],[ + "start", + ["paren.rparen",")))"] +],[ + "start" +],[ + "start", + ["keyword","vars"], + ["text"," "], + ["variable","names"], + ["text",", "], + ["variable","person"], + ["text",", "], + ["variable","i"], + ["text",", "], + ["variable","doubles"], + ["text",", "], + ["variable","lengths"], + ["text",", "], + ["variable","cubeRange"] +],[ + "start", + ["variable","names"], + ["text"," = "], + ["paren.lparen","["], + ["string","\"Thorin\""], + ["text",", "], + ["string","\"Dwalin\""], + ["text",", "], + ["string","\"Balin\""], + ["text",", "], + ["string","\"Bifur\""], + ["text",", "], + ["string","\"Bofur\""], + ["text",", "], + ["string","\"Bombur\""], + ["text",", "], + ["string","\"Oin\""], + ["text",","] +],[ + "start", + ["text"," "], + ["string","\"Gloin\""], + ["text",", "], + ["string","\"Ori\""], + ["text",", "], + ["string","\"Nori\""], + ["text",", "], + ["string","\"Dori\""], + ["text",", "], + ["string","\"Fili\""], + ["text",", "], + ["string","\"Kili\""], + ["text",", "], + ["string","\"Bilbo\""], + ["text",", "], + ["string","\"Gandalf\""], + ["paren.rparen","]"] +],[ + "start" +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["variable","names"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","!="], + ["text"," "], + ["string","\"Bilbo\""], + ["text"," "], + ["keyword.operator","&&"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","!="], + ["text"," "], + ["string","\"Gandalf\""], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["variable","person"], + ["text"," = "], + ["paren.lparen","{"], + ["variable","name"], + ["text",": "], + ["string","\"Tim\""], + ["text",", "], + ["variable","age"], + ["text",": "], + ["constant.numeric","30"], + ["paren.rparen","}"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","key"], + ["text",", "], + ["variable","value"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["variable","person"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","key"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\" = \""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","value"], + ["paren.rparen",")"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["variable","i"], + ["text"," = "], + ["constant.numeric","0"] +],[ + "start", + ["keyword","while"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword.operator","<"], + ["text"," "], + ["constant.numeric","10"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","i"], + ["text"," = "], + ["variable","i"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","i"], + ["paren.rparen",")"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\"range\""], + ["paren.rparen",")"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","i"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"], + ["paren.rparen",")"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["text"," "], + ["keyword.operator","-"], + ["text"," "], + ["variable","i"], + ["paren.rparen",")"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["comment","-- Dynamic object that gives the first 10 doubles"] +],[ + "start", + ["variable","doubles"], + ["text"," = "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["storage.form","@len"], + ["text",": "], + ["paren.lparen","{"], + ["text","| "], + ["constant.numeric","10"], + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["storage.form","@get"], + ["text",": "], + ["paren.lparen","{"], + ["variable","key"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","key"], + ["text"," "], + ["keyword","is"], + ["text"," "], + ["storage.type","Integer"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["variable","key"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["variable","key"], + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\"#doubles\""], + ["text",", "], + ["keyword.operator","#"], + ["variable","doubles"], + ["paren.rparen",")"] +],[ + "start" +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\"Doubles\""], + ["paren.rparen",")"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["variable","doubles"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["paren.rparen","])"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["comment","-- Dynamic object that has names list as keys and string lenth as values"] +],[ + "start", + ["variable","lengths"], + ["text"," = "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["storage.form","@keys"], + ["text",": "], + ["paren.lparen","{"], + ["text","| "], + ["variable","names"], + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["storage.form","@get"], + ["text",": "], + ["paren.lparen","{"], + ["variable","key"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","key"], + ["text"," "], + ["keyword","is"], + ["text"," "], + ["storage.type","String"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["keyword.operator","#"], + ["variable","key"], + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["language.builtin","print"], + ["text"," "], + ["paren.lparen","("], + ["string","\"Lengths\""], + ["paren.rparen",")"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["variable","lengths"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["paren.rparen","])"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["variable","cubeRange"], + ["text"," = "], + ["paren.lparen","{"], + ["variable","n"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","vars"], + ["text"," "], + ["variable","i"], + ["text",", "], + ["variable","v"] +],[ + "start", + ["text"," "], + ["variable","i"], + ["text"," = "], + ["constant.numeric","0"] +],[ + "start", + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["storage.form","@call"], + ["text",": "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["variable","v"], + ["text"," = "], + ["variable","i"] +],[ + "start", + ["text"," "], + ["variable","i"], + ["text"," = "], + ["variable","i"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","v"], + ["text"," "], + ["keyword.operator","<"], + ["text"," "], + ["variable","n"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["variable","v"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["variable","v"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["variable","v"], + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\"Cubes\""], + ["paren.rparen",")"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["variable","cubeRange"], + ["paren.lparen","("], + ["constant.numeric","5"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["paren.rparen","])"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\"String\""], + ["paren.rparen",")"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["string","\"Hello World\""], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["paren.rparen","])"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","i"], + ["text"," "], + ["keyword","for"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["paren.rparen",")])"] +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","i"], + ["text"," "], + ["keyword","for"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","20"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword.operator","%"], + ["text"," "], + ["constant.numeric","3"], + ["paren.rparen","])"] +],[ + "start" +],[ + "start" +],[ + "start" +],[ + "start", + ["comment","-- Example showing how to do parallel work using split..and"] +],[ + "start", + ["variable","base"], + ["text"," = "], + ["paren.lparen","{"], + ["variable","bootstrap"], + ["text",", "], + ["variable","target-dir"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","split"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","copy"], + ["paren.lparen","("], + ["string","\"res\""], + ["text",", "], + ["variable","target-dir"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword","and"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","newer"], + ["paren.lparen","("], + ["string","\"src/*.less\""], + ["text",", "], + ["variable","target-dir"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\"/style.css\""], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","lessc"], + ["paren.lparen","("], + ["string","\"src/\""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","bootstrap"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\".less\""], + ["text",", "], + ["variable","target-dir"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\"/style.css\""], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword","and"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","build"], + ["paren.lparen","("], + ["string","\"src/\""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","bootstrap"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\".js\""], + ["text",", "], + ["variable","target-dir"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\"/app.js\""], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["keyword","vars"], + ["text"," "], + ["variable","Dragon"], + ["text",", "], + ["variable","pet"] +],[ + "start" +],[ + "start", + ["variable","Dragon"], + ["text"," = "], + ["paren.lparen","{"], + ["variable","name"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","vars"], + ["text"," "], + ["variable","asleep"], + ["text",", "], + ["variable","stuff-in-belly"], + ["text",", "], + ["variable","stuff-in-intestine"], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","feed"], + ["text",", "], + ["variable","walk"], + ["text",", "], + ["variable","put-to-bed"], + ["text",", "], + ["variable","toss"], + ["text",", "], + ["variable","rock"], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","hungry?"], + ["text",", "], + ["variable","poopy?"], + ["text",", "], + ["variable","passage-of-time"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-belly"], + ["text"," = "], + ["constant.numeric","10"], + ["text"," "], + ["comment","-- He's full."] +],[ + "start", + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," = "], + ["constant.numeric","0"], + ["text"," "], + ["comment","-- He doesn't need to go."] +],[ + "start" +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' is born.'"], + ["paren.rparen",")"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","feed"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'You feed '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","'.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-belly"], + ["text"," = "], + ["constant.numeric","10"] +],[ + "start", + ["text"," "], + ["variable","passage-of-time"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","walk"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'You walk '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\".\""], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," = "], + ["constant.numeric","0"] +],[ + "start", + ["text"," "], + ["variable","passage-of-time"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","put-to-bed"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'You put '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' to bed.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","true"] +],[ + "start", + ["text"," "], + ["keyword","for"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","3"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","passage-of-time"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' snores, filling the room with smoke.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' wakes up slowly.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","toss"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'You toss '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' up into the air.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'He giggles, which singes your eyebrows.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","passage-of-time"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","rock"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'You rock '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' gently.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","true"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'He briefly dozes off...'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","passage-of-time"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'...but wakes when you stop.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","hungry?"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-belly"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["constant.numeric","2"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","poopy?"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," "], + ["keyword.operator",">="], + ["text"," "], + ["constant.numeric","8"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","passage-of-time"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","stuff-in-belly"], + ["text"," "], + ["keyword.operator",">"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["comment","-- Move food from belly to intestine"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-belly"], + ["text"," = "], + ["variable","stuff-in-belly"], + ["text"," "], + ["keyword.operator","-"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," = "], + ["variable","stuff-in-intestine"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword","else"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["comment","-- Our dragon is starving!"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'He wakes up suddenly!'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' is starving! In desperation, he ate YOU!'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","abort"], + ["text"," "], + ["string","\"died\""] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," "], + ["keyword.operator",">="], + ["text"," "], + ["constant.numeric","10"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," = "], + ["constant.numeric","0"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'Whoops! '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' had an accident...'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","hungry?"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'He wakes up suddenly!'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\"'s stomach grumbles...\""], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","poopy?"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'He wakes up suddenly!'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' does the potty dance...'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["comment","-- Export the public interface to this closure object."] +],[ + "start", + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","feed"], + ["text",": "], + ["variable","feed"] +],[ + "start", + ["text"," "], + ["variable","walk"], + ["text",": "], + ["variable","walk"] +],[ + "start", + ["text"," "], + ["variable","put-to-bed"], + ["text",": "], + ["variable","put-to-bed"] +],[ + "start", + ["text"," "], + ["variable","toss"], + ["text",": "], + ["variable","toss"] +],[ + "start", + ["text"," "], + ["variable","rock"], + ["text",": "], + ["variable","rock"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["variable","pet"], + ["text"," = "], + ["variable","Dragon"], + ["paren.lparen","("], + ["string","'Norbert'"], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","feed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","toss"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","walk"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","put-to-bed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","rock"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","put-to-bed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","put-to-bed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","put-to-bed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","put-to-bed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start" +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_mel.json b/lib/ace/mode/_test/tokens_mel.json new file mode 100644 index 00000000..a2d618a9 --- /dev/null +++ b/lib/ace/mode/_test/tokens_mel.json @@ -0,0 +1,257 @@ +[[ + "start", + ["comment.line.double-slash.mel","//"], + ["punctuation.definition.comment.mel"," animated duplicates, instances script"] +],[ + "start", + ["meta.function.mel","proc"], + ["keyword.other.mel"," "], + ["storage.type.mel","animatedDuplication"], + ["entity.name.function.mel"," ("], + ["punctuation.section.function.mel","("], + ["meta.function.mel","int $rangeStart, int $rangeEnd, int $numOfDuplicates, int $duplicateOrInstance"], + ["punctuation.section.function.mel",")"], + "proc animatedDuplication (int $rangeStart, int $rangeEnd, int $numOfDuplicates, int $duplicateOrInstance)" +],[ + "start", + ["text","{"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_start"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","rangeStart"], + ["text",";"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_end"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","rangeEnd"], + ["text",";"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","num_of_duplicates"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","numOfDuplicates"], + ["text",";"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","step_size"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," ("], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_end"], + ["text"," "], + ["keyword.operator.symbolic.mel","-"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_start"], + ["text",") "], + ["keyword.operator.symbolic.mel","/"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","num_of_duplicates"], + ["text",";"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","i"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["constant.numeric.mel","0"], + ["text",";"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","temp"], + ["text",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["support.function.mel","currentTime"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_start"], + ["text","; "], + ["comment.line.double-slash.mel","//"], + ["punctuation.definition.comment.mel"," set to range start"] +],[ + "start" +],[ + "start", + ["text"," "], + ["storage.type.mel","string"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","selectedObjects"], + ["text","[]; "], + ["comment.line.double-slash.mel","//"], + ["punctuation.definition.comment.mel"," to store selected objects"] +],[ + "start", + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","selectedObjects"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," `"], + ["support.function.mel","ls"], + ["text"," "], + ["keyword.operator.symbolic.mel","-"], + ["text","sl`; "], + ["comment.line.double-slash.mel","//"], + ["punctuation.definition.comment.mel"," store selected objects"] +],[ + "start", + ["text"," "], + ["support.function.mel","select"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","selectedObjects"], + ["text",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword.control.mel","while"], + ["text"," ("], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","i"], + ["text"," <"], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","num_of_duplicates"], + ["text",")"] +],[ + "start", + ["text"," {"] +],[ + "start", + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","temp"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_start"], + ["text"," "], + ["keyword.operator.symbolic.mel","+"], + ["text"," ("], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","step_size"], + ["text"," "], + ["keyword.operator.symbolic.mel","*"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","i"], + ["text",");"] +],[ + "start", + ["text"," "], + ["support.function.mel","currentTime"], + ["text"," ("], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","temp"], + ["text",");"] +],[ + "start", + ["text"," "], + ["comment.line.double-slash.mel","//"], + ["punctuation.definition.comment.mel"," seleced the objects to duplicate or instance"] +],[ + "start", + ["text"," "], + ["support.function.mel","select"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","selectedObjects"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.control.mel","if"], + ["text","("], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","duplicateOrInstance"], + ["text"," "], + ["keyword.operator.symbolic.mel","=="], + ["text"," "], + ["constant.numeric.mel","0"], + ["text",")"] +],[ + "start", + ["text"," {"] +],[ + "start", + ["text"," "], + ["support.function.mel","duplicate"], + ["text",";"] +],[ + "start", + ["text"," }"] +],[ + "start", + ["text"," "], + ["keyword.control.mel","else"] +],[ + "start", + ["text"," {"] +],[ + "start", + ["text"," "], + ["support.function.mel","instance"], + ["text",";"] +],[ + "start", + ["text"," }"] +],[ + "start", + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","i"], + ["keyword.operator.symbolic.mel","++"], + ["text",";"] +],[ + "start", + ["text"," }"] +],[ + "start", + ["text","}"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_protobuf.json b/lib/ace/mode/_test/tokens_protobuf.json new file mode 100644 index 00000000..469dba06 --- /dev/null +++ b/lib/ace/mode/_test/tokens_protobuf.json @@ -0,0 +1,136 @@ +[[ + "start", + ["keyword.declaration.protobuf","message"], + ["text"," "], + ["identifier","Point"], + ["text"," {"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","required"], + ["text"," "], + ["support.type","int32"], + ["text"," "], + ["identifier","x"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","1"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","required"], + ["text"," "], + ["support.type","int32"], + ["text"," "], + ["identifier","y"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","2"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","optional"], + ["text"," "], + ["support.type","string"], + ["text"," "], + ["identifier","label"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","3"], + ["text",";"] +],[ + "start", + ["text","}"] +],[ + "start" +],[ + "start", + ["keyword.declaration.protobuf","message"], + ["text"," "], + ["identifier","Line"], + ["text"," {"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","required"], + ["text"," "], + ["identifier","Point"], + ["text"," "], + ["identifier","start"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","1"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","required"], + ["text"," "], + ["identifier","Point"], + ["text"," "], + ["identifier","end"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","2"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","optional"], + ["text"," "], + ["support.type","string"], + ["text"," "], + ["identifier","label"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","3"], + ["text",";"] +],[ + "start", + ["text","}"] +],[ + "start" +],[ + "start", + ["keyword.declaration.protobuf","message"], + ["text"," "], + ["identifier","Polyline"], + ["text"," {"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","repeated"], + ["text"," "], + ["identifier","Point"], + ["text"," "], + ["identifier","point"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","1"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","optional"], + ["text"," "], + ["support.type","string"], + ["text"," "], + ["identifier","label"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","2"], + ["text",";"] +],[ + "start", + ["text","}"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_sjs.json b/lib/ace/mode/_test/tokens_sjs.json new file mode 100644 index 00000000..5cd96451 --- /dev/null +++ b/lib/ace/mode/_test/tokens_sjs.json @@ -0,0 +1,276 @@ +[[ + "start", + ["storage.type","var"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["identifier","each"], + ["punctuation.operator",","], + ["text"," "], + ["identifier","map"], + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","require"], + ["paren.lparen","("], + ["string","'sjs:sequence'"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["storage.type","var"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["keyword","get"], + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","require"], + ["paren.lparen","("], + ["string","'sjs:http'"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["storage.type","function"], + ["text"," "], + ["entity.name.function","foo"], + ["paren.lparen","("], + ["variable.parameter","items"], + ["punctuation.operator",", "], + ["variable.parameter","nada"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["no_regex"], + ["text"," "], + ["storage.type","var"], + ["text"," "], + ["identifier","component"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["identifier","name"], + ["punctuation.operator",":"], + ["text"," "], + ["string","\"Ace\""], + ["punctuation.operator",","], + ["text"," "], + ["identifier","role"], + ["punctuation.operator",":"], + ["text"," "], + ["string","\"Editor\""], + ["text"," "], + ["paren.rparen","}"], + ["punctuation.operator",";"] +],[ + ["qqstring","no_regex"], + ["text"," "], + ["storage.type","console"], + ["punctuation.operator","."], + ["support.function.firebug","log"], + ["paren.lparen","("], + ["string","\""] +],[ + ["qqstring","no_regex"], + ["string"," Welcome, "], + ["paren.lparen","#{"], + ["identifier","component"], + ["text","."], + ["identifier","name"], + ["paren.rparen","}"] +],[ + ["no_regex"], + ["string"," \""], + ["punctuation.operator","."], + ["identifier","trim"], + ["paren.lparen","("], + ["paren.rparen","))"], + ["punctuation.operator",";"] +],[ + ["no_regex"] +],[ + ["no_regex"], + ["text"," "], + ["identifier","logging"], + ["punctuation.operator","."], + ["identifier","debug"], + ["paren.lparen","("], + ["string","`Component added: "], + ["paren.lparen","$"], + ["identifier","String"], + ["paren.lparen","("], + ["identifier","component"], + ["paren.rparen",")"], + ["string"," ("], + ["paren.lparen","${"], + ["identifier","component"], + ["paren.rparen","}"], + ["string",")`"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + ["no_regex"] +],[ + ["bstring","no_regex"], + ["text"," "], + ["storage.type","console"], + ["punctuation.operator","."], + ["support.function.firebug","log"], + ["paren.lparen","("], + ["string","`"] +],[ + ["string_interp","string_interp","bstring","no_regex"], + ["string"," Welcome, {"], + ["paren.lparen","${"], + ["storage.type","function"], + ["text","() "], + ["paren.lparen","{"] +],[ + ["string_interp","string_interp","bstring","no_regex"], + ["text"," "], + ["keyword","return"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["identifier","x"], + ["text",": "], + ["constant.numeric","1"], + ["text",", "], + ["identifier","y"], + ["text",": "], + ["string","\"why?}\""], + ["paren.rparen","}"], + ["text",";"] +],[ + ["bstring","no_regex"], + ["text"," "], + ["paren.rparen","}"], + ["text","()"], + ["paren.rparen","}"] +],[ + ["no_regex"], + ["string"," `"], + ["punctuation.operator","."], + ["identifier","trim"], + ["paren.lparen","("], + ["paren.rparen","))"], + ["punctuation.operator",";"] +],[ + ["no_regex"] +],[ + ["no_regex"], + ["text"," "], + ["keyword","waitfor"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["no_regex"], + ["text"," "], + ["identifier","items"], + ["text"," "], + ["keyword.operator",".."], + ["text"," "], + ["identifier","each"], + ["punctuation.operator","."], + ["identifier","par"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["paren.rparen","|"], + ["variable.parameter","item"], + ["paren.rparen","|"] +],[ + ["no_regex"], + ["text"," "], + ["keyword","get"], + ["paren.lparen","("], + ["identifier","item"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + ["no_regex"], + ["text"," "], + ["paren.rparen","}"] +],[ + ["no_regex"], + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword","and"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["no_regex"], + ["text"," "], + ["storage.type","var"], + ["text"," "], + ["identifier","lengths"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","items"], + ["text"," "], + ["keyword.operator",".."], + ["text"," "], + ["identifier","map"], + ["paren.lparen","("], + ["identifier","i"], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["identifier","i"], + ["punctuation.operator","."], + ["support.constant","length"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + ["no_regex"], + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword","or"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["no_regex"], + ["text"," "], + ["variable.language","hold"], + ["paren.lparen","("], + ["constant.numeric","1500"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + ["no_regex"], + ["text"," "], + ["keyword","throw"], + ["text"," "], + ["keyword","new"], + ["text"," "], + ["variable.language","Error"], + ["paren.lparen","("], + ["string","\"timed out\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + ["no_regex"], + ["text"," "], + ["paren.rparen","}"] +],[ + ["no_regex"], + ["paren.rparen","}"], + ["text","\t"], + ["comment","// Real Tab."] +],[ + ["no_regex"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_soy_template.json b/lib/ace/mode/_test/tokens_soy_template.json new file mode 100644 index 00000000..f100dd6b --- /dev/null +++ b/lib/ace/mode/_test/tokens_soy_template.json @@ -0,0 +1,287 @@ +[[ + "punctuation.definition.comment.begin.soy1", + ["punctuation.definition.comment.begin.soy","/**"] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * Greets a person using \"Hello\" by default."] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * "], + ["support.type.soy","@param"], + ["text"," "], + ["variable.parameter.soy","name"], + ["comment.block.documentation.soy"," The name of the person."] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * "], + ["support.type.soy","@param?"], + ["text"," "], + ["variable.parameter.soy","greetingWord"], + ["comment.block.documentation.soy"," Optional greeting word to use instead of \"Hello\"."] +],[ + "start", + ["comment.block.documentation.soy"," "], + ["punctuation.definition.comment.end.soy","*/"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","template"], + ["text"," "], + ["entity.name.function.soy",".helloName"], + ["meta.tag.template.soy"," #eee"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","if"], + ["meta.tag.if.soy"," "], + ["keyword.operator.soy","not"], + ["meta.tag.if.soy"," "], + ["variable.other.soy","$greetingWord"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text"," Hello "], + ["punctuation.definition.tag.begin.soy","{"], + ["variable.other.soy","$name"], + ["punctuation.definition.tag.end.soy","}"], + ["text","!"] +],[ + "start", + ["text"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["text","else"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["variable.other.soy","$greetingWord"], + ["punctuation.definition.tag.end.soy","}"], + ["text"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["variable.other.soy","$name"], + ["punctuation.definition.tag.end.soy","}"], + ["text","!"] +],[ + "start", + ["text"," "], + ["punctuation.definition.tag.begin.soy","{/"], + ["entity.name.tag.soy","if"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{/"], + ["meta.tag.template.soy","template"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start" +],[ + "punctuation.definition.comment.begin.soy1", + ["punctuation.definition.comment.begin.soy","/**"] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * Greets a person and optionally a list of other people."] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * "], + ["support.type.soy","@param"], + ["text"," "], + ["variable.parameter.soy","name"], + ["comment.block.documentation.soy"," The name of the person."] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * "], + ["support.type.soy","@param"], + ["text"," "], + ["variable.parameter.soy","additionalNames"], + ["comment.block.documentation.soy"," The additional names to greet. May be an empty list."] +],[ + "start", + ["comment.block.documentation.soy"," "], + ["punctuation.definition.comment.end.soy","*/"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","template"], + ["text"," "], + ["entity.name.function.soy",".helloNames"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["comment.line.double-slash.soy"," "], + ["punctuation.definition.comment.soy","//"], + ["comment.line.double-slash.soy"," Greet the person."] +],[ + "start", + ["text"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","call"], + ["variable.parameter.soy"," .helloName"], + ["meta.tag.call.soy"," "], + ["entity.other.attribute-name.soy","data"], + ["keyword.operator.soy","="], + ["string.quoted.double","\"all\""], + ["meta.tag.call.soy"," /"], + ["punctuation.definition.tag.end.soy","}"], + ["meta.tag.punctuation.begin","<"], + ["meta.tag.name","br"], + ["meta.tag.punctuation.end",">"] +],[ + "start", + ["comment.line.double-slash.soy"," "], + ["punctuation.definition.comment.soy","//"], + ["comment.line.double-slash.soy"," Greet the additional people."] +],[ + "start", + ["text"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","foreach"], + ["meta.tag.foreach.soy"," "], + ["variable.other.soy","$additionalName"], + ["meta.tag.foreach.soy"," "], + ["keyword.operator.soy","in"], + ["meta.tag.foreach.soy"," "], + ["variable.other.soy","$additionalNames"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","call"], + ["variable.parameter.soy"," .helloName"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","param"], + ["text"," "], + ["entity.other.attribute-name.soy","name"], + ["keyword.operator.soy",":"], + ["meta.tag.param.soy"," "], + ["variable.other.soy","$additionalName"], + ["text"," "], + ["meta.tag.param.soy","/"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text"," "], + ["punctuation.definition.tag.begin.soy","{/"], + ["meta.tag.call.soy","call"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","if"], + ["meta.tag.if.soy"," "], + ["keyword.operator.soy","not"], + ["meta.tag.if.soy"," "], + ["support.function.soy","isLast"], + ["meta.tag.if.soy","("], + ["variable.other.soy","$additionalName"], + ["meta.tag.if.soy",")"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text"," "], + ["meta.tag.punctuation.begin","<"], + ["meta.tag.name","br"], + ["meta.tag.punctuation.end",">"], + ["comment.line.double-slash.soy"," "], + ["punctuation.definition.comment.soy","//"], + ["comment.line.double-slash.soy"," break after every line except the last"] +],[ + "start", + ["text"," "], + ["punctuation.definition.tag.begin.soy","{/"], + ["entity.name.tag.soy","if"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["text","ifempty"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text"," No additional people to greet."] +],[ + "start", + ["text"," "], + ["punctuation.definition.tag.begin.soy","{/"], + ["entity.name.tag.soy","foreach"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{/"], + ["meta.tag.template.soy","template"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["punctuation.definition.tag.begin.soy","{/"], + ["entity.name.tag.soy","foreach"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","if"], + ["meta.tag.if.soy"," "], + ["support.function.soy","length"], + ["meta.tag.if.soy","("], + ["variable.other.soy","$items"], + ["meta.tag.if.soy",") > 5"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","msg"], + ["meta.tag.msg.soy"," "], + ["entity.other.attribute-name.soy","desc"], + ["keyword.operator.soy","="], + ["string.quoted.double","\"Says hello to the user.\""], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","namespace"], + ["text"," "], + ["variable.parameter.soy","ns"], + ["text"," autoescape=\"contextual\""], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start" +],[ + "start", + ["punctuation.definition.comment.begin.soy","/**"], + ["comment.block.documentation.soy"," Example. "], + ["punctuation.definition.comment.end.soy","*/"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","template"], + ["text"," "], + ["entity.name.function.soy",".example"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text"," foo is "], + ["punctuation.definition.tag.begin.soy","{"], + ["variable.other.soy","$ij.foo"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{/"], + ["meta.tag.template.soy","template"], + ["punctuation.definition.tag.end.soy","}"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_space.json b/lib/ace/mode/_test/tokens_space.json new file mode 100644 index 00000000..918b9a67 --- /dev/null +++ b/lib/ace/mode/_test/tokens_space.json @@ -0,0 +1,322 @@ +[[ + "start", + ["variable","query"] +],[ + "start", + ["empty_line"," "], + ["variable","count"], + ["keyword.operator"," "], + ["string","10"] +],[ + "start", + ["empty_line"," "], + ["variable","created"], + ["keyword.operator"," "], + ["string","2011-06-21T08:10:46Z"] +],[ + "start", + ["empty_line"," "], + ["variable","lang"], + ["keyword.operator"," "], + ["string","en-US"] +],[ + "start", + ["empty_line"," "], + ["variable","results"] +],[ + "start", + ["empty_line"," "], + ["variable","photo"] +],[ + "start", + ["empty_line"," "], + ["variable","0"] +],[ + "start", + ["empty_line"," "], + ["variable","farm"], + ["keyword.operator"," "], + ["string","6"] +],[ + "start", + ["empty_line"," "], + ["variable","id"], + ["keyword.operator"," "], + ["string","5855620975"] +],[ + "start", + ["empty_line"," "], + ["variable","isfamily"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","isfriend"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","ispublic"], + ["keyword.operator"," "], + ["string","1"] +],[ + "start", + ["empty_line"," "], + ["variable","owner"], + ["keyword.operator"," "], + ["string","32021554@N04"] +],[ + "start", + ["empty_line"," "], + ["variable","secret"], + ["keyword.operator"," "], + ["string","f1f5e8515d"] +],[ + "start", + ["empty_line"," "], + ["variable","server"], + ["keyword.operator"," "], + ["string","5110"] +],[ + "start", + ["empty_line"," "], + ["variable","title"], + ["keyword.operator"," "], + ["string","7087 bandit cat"] +],[ + "start", + ["empty_line"," "], + ["variable","1"] +],[ + "start", + ["empty_line"," "], + ["variable","farm"], + ["keyword.operator"," "], + ["string","4"] +],[ + "start", + ["empty_line"," "], + ["variable","id"], + ["keyword.operator"," "], + ["string","5856170534"] +],[ + "start", + ["empty_line"," "], + ["variable","isfamily"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","isfriend"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","ispublic"], + ["keyword.operator"," "], + ["string","1"] +],[ + "start", + ["empty_line"," "], + ["variable","owner"], + ["keyword.operator"," "], + ["string","32021554@N04"] +],[ + "start", + ["empty_line"," "], + ["variable","secret"], + ["keyword.operator"," "], + ["string","ff1efb2a6f"] +],[ + "start", + ["empty_line"," "], + ["variable","server"], + ["keyword.operator"," "], + ["string","3217"] +],[ + "start", + ["empty_line"," "], + ["variable","title"], + ["keyword.operator"," "], + ["string","6975 rusty cat"] +],[ + "start", + ["empty_line"," "], + ["variable","2"] +],[ + "start", + ["empty_line"," "], + ["variable","farm"], + ["keyword.operator"," "], + ["string","6"] +],[ + "start", + ["empty_line"," "], + ["variable","id"], + ["keyword.operator"," "], + ["string","5856172972"] +],[ + "start", + ["empty_line"," "], + ["variable","isfamily"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","isfriend"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","ispublic"], + ["keyword.operator"," "], + ["string","1"] +],[ + "start", + ["empty_line"," "], + ["variable","owner"], + ["keyword.operator"," "], + ["string","51249875@N03"] +],[ + "start", + ["empty_line"," "], + ["variable","secret"], + ["keyword.operator"," "], + ["string","6c6887347c"] +],[ + "start", + ["empty_line"," "], + ["variable","server"], + ["keyword.operator"," "], + ["string","5192"] +],[ + "start", + ["empty_line"," "], + ["variable","title"], + ["keyword.operator"," "], + ["string","watermarked-cats"] +],[ + "start", + ["empty_line"," "], + ["variable","3"] +],[ + "start", + ["empty_line"," "], + ["variable","farm"], + ["keyword.operator"," "], + ["string","6"] +],[ + "start", + ["empty_line"," "], + ["variable","id"], + ["keyword.operator"," "], + ["string","5856168328"] +],[ + "start", + ["empty_line"," "], + ["variable","isfamily"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","isfriend"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","ispublic"], + ["keyword.operator"," "], + ["string","1"] +],[ + "start", + ["empty_line"," "], + ["variable","owner"], + ["keyword.operator"," "], + ["string","32021554@N04"] +],[ + "start", + ["empty_line"," "], + ["variable","secret"], + ["keyword.operator"," "], + ["string","0c1cfdf64c"] +],[ + "start", + ["empty_line"," "], + ["variable","server"], + ["keyword.operator"," "], + ["string","5078"] +],[ + "start", + ["empty_line"," "], + ["variable","title"], + ["keyword.operator"," "], + ["string","7020 mandy cat"] +],[ + "start", + ["empty_line"," "], + ["variable","4"] +],[ + "start", + ["empty_line"," "], + ["variable","farm"], + ["keyword.operator"," "], + ["string","3"] +],[ + "start", + ["empty_line"," "], + ["variable","id"], + ["keyword.operator"," "], + ["string","5856171774"] +],[ + "start", + ["empty_line"," "], + ["variable","isfamily"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","isfriend"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","ispublic"], + ["keyword.operator"," "], + ["string","1"] +],[ + "start", + ["empty_line"," "], + ["variable","owner"], + ["keyword.operator"," "], + ["string","32021554@N04"] +],[ + "start", + ["empty_line"," "], + ["variable","secret"], + ["keyword.operator"," "], + ["string","7f5a3180ab"] +],[ + "start", + ["empty_line"," "], + ["variable","server"], + ["keyword.operator"," "], + ["string","2696"] +],[ + "start", + ["empty_line"," "], + ["variable","title"], + ["keyword.operator"," "], + ["string","7448 bobby cat"] +],[ + "key" +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_verilog.json b/lib/ace/mode/_test/tokens_verilog.json new file mode 100644 index 00000000..9680a964 --- /dev/null +++ b/lib/ace/mode/_test/tokens_verilog.json @@ -0,0 +1,113 @@ +[[ + "start", + ["keyword","always"], + ["text"," @"], + ["paren.lparen","("], + ["keyword","negedge"], + ["text"," "], + ["identifier","reset"], + ["text"," "], + ["keyword","or"], + ["text"," "], + ["keyword","posedge"], + ["text"," "], + ["identifier","clk"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","begin"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["paren.lparen","("], + ["identifier","reset"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","begin"] +],[ + "start", + ["text"," "], + ["identifier","d_out"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["constant.numeric","16"], + ["text","'"], + ["identifier","h0000"], + ["text",";"] +],[ + "start", + ["text"," "], + ["identifier","d_out_mem"], + ["text","["], + ["identifier","resetcount"], + ["text","] "], + ["keyword.operator","<="], + ["text"," "], + ["identifier","d_out"], + ["text",";"] +],[ + "start", + ["text"," "], + ["identifier","laststoredvalue"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["identifier","d_out"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword","end"], + ["text"," "], + ["keyword","else"], + ["text"," "], + ["keyword","begin"] +],[ + "start", + ["text"," "], + ["identifier","d_out"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["identifier","d_out"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"], + ["text","'"], + ["identifier","b1"], + ["text","; "] +],[ + "start", + ["text"," "], + ["keyword","end"] +],[ + "start", + ["keyword","end"] +],[ + "start" +],[ + "start", + ["keyword","always"], + ["text"," @"], + ["paren.lparen","("], + ["identifier","bufreadaddr"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","bufreadval"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","d_out_mem"], + ["text","["], + ["identifier","bufreadaddr"], + ["text","];"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_vhdl.json b/lib/ace/mode/_test/tokens_vhdl.json new file mode 100644 index 00000000..88c6e222 --- /dev/null +++ b/lib/ace/mode/_test/tokens_vhdl.json @@ -0,0 +1,271 @@ +[[ + "start", + ["keyword","library"], + ["text"," "], + ["identifier","IEEE"] +],[ + "start", + ["identifier","user"], + ["text"," "], + ["identifier","IEEE"], + ["punctuation.operator","."], + ["identifier","std_logic_1164"], + ["punctuation.operator","."], + ["keyword","all"], + ["punctuation.operator",";"] +],[ + "start", + ["keyword","use"], + ["text"," "], + ["identifier","IEEE"], + ["punctuation.operator","."], + ["identifier","numeric_std"], + ["punctuation.operator","."], + ["keyword","all"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["keyword","entity"], + ["text"," "], + ["identifier","COUNT16"], + ["text"," "], + ["keyword","is"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","port"], + ["text"," "], + ["paren.lparen","("] +],[ + "start", + ["text"," "], + ["identifier","cOut"], + ["text"," "], + ["punctuation.operator",":"], + ["keyword","out"], + ["text"," "], + ["storage.type","std_logic_vector"], + ["paren.lparen","("], + ["constant.numeric","15"], + ["text"," "], + ["keyword","downto"], + ["text"," "], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["punctuation.operator",";"], + ["text"," "], + ["comment","-- counter output"] +],[ + "start", + ["text"," "], + ["identifier","clkEn"], + ["text"," "], + ["punctuation.operator",":"], + ["keyword","in"], + ["text"," "], + ["storage.type","std_logic"], + ["punctuation.operator",";"], + ["text"," "], + ["comment","-- count enable"] +],[ + "start", + ["text"," "], + ["identifier","clk"], + ["text"," "], + ["punctuation.operator",":"], + ["keyword","in"], + ["text"," "], + ["storage.type","std_logic"], + ["punctuation.operator",";"], + ["text"," "], + ["comment","-- clock input"] +],[ + "start", + ["text"," "], + ["identifier","rst"], + ["text"," "], + ["punctuation.operator",":"], + ["keyword","in"], + ["text"," "], + ["storage.type","std_logic"], + ["text"," "], + ["comment","-- reset input"] +],[ + "start", + ["text"," "], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "] +],[ + "start", + ["keyword","end"], + ["text"," "], + ["keyword","entity"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["keyword","architecture"], + ["text"," "], + ["identifier","count_rtl"], + ["text"," "], + ["keyword","of"], + ["text"," "], + ["identifier","COUNT16"], + ["text"," "], + ["keyword","is"] +],[ + "start", + ["text"," "], + ["storage.type","signal"], + ["text"," "], + ["identifier","count"], + ["text"," "], + ["punctuation.operator",":"], + ["storage.type","std_logic_vector"], + ["text"," "], + ["paren.lparen","("], + ["constant.numeric","15"], + ["text"," "], + ["keyword","downto"], + ["text"," "], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "] +],[ + "start", + ["keyword","begin"] +],[ + "start", + ["text"," "], + ["keyword","process"], + ["text"," "], + ["paren.lparen","("], + ["identifier","clk"], + ["punctuation.operator",","], + ["text"," "], + ["identifier","rst"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","begin"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["paren.lparen","("], + ["identifier","rst"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","'1'"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","then"] +],[ + "start", + ["text"," "], + ["identifier","count"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["paren.lparen","("], + ["keyword","others"], + ["keyword.operator","=>"], + ["string","'0'"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword","elsif"], + ["paren.lparen","("], + ["identifier","rising_edge"], + ["paren.lparen","("], + ["identifier","clk"], + ["paren.rparen","))"], + ["text"," "], + ["keyword","then"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["paren.lparen","("], + ["identifier","clkEn"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","'1'"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","then"] +],[ + "start", + ["text"," "], + ["identifier","count"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["identifier","count"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword","end"], + ["text"," "], + ["keyword","if"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword","end"], + ["text"," "], + ["keyword","if"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["keyword","end"], + ["text"," "], + ["keyword","process"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["identifier","cOut"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["identifier","count"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["keyword","end"], + ["text"," "], + ["keyword","architecture"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "] +]] \ No newline at end of file From 45c4bdcb2e16400a6de6ee648fdf12ea2b50daaf Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 14 Dec 2013 19:44:44 +0400 Subject: [PATCH 3/8] disable invalid class on ampersands fixes #1655 --- lib/ace/mode/xml_highlight_rules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/xml_highlight_rules.js b/lib/ace/mode/xml_highlight_rules.js index dd3d2a28..ee6ef8cd 100644 --- a/lib/ace/mode/xml_highlight_rules.js +++ b/lib/ace/mode/xml_highlight_rules.js @@ -130,7 +130,7 @@ var XmlHighlightRules = function(normalize) { token : "constant.language.escape", regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" }, { - token : "invalid.illegal", regex : "&" + token : "text", regex : "&" }], string: [{ From 133db3cfe0b47f1e07643a7a3fc5ed20a963b26f Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 14 Dec 2013 23:52:01 +0400 Subject: [PATCH 4/8] fix #1711 Double click on foldWidgets region can paint whole gutter in red. --- lib/ace/edit_session/folding.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ace/edit_session/folding.js b/lib/ace/edit_session/folding.js index d3fa0ef0..474818b2 100644 --- a/lib/ace/edit_session/folding.js +++ b/lib/ace/edit_session/folding.js @@ -747,8 +747,11 @@ function Folding() { }; var range = this.$toggleFoldWidget(row, options); - if (!range) - (e.target || e.srcElement).className += " ace_invalid"; + if (!range) { + var el = (e.target || e.srcElement) + if (el && /ace_fold-widget/.test(el.className)) + el.className += " ace_invalid"; + } }; this.$toggleFoldWidget = function(row, options) { From b7ee15f5d9c1d2be9c3c72f6e0ec267cc22dd61b Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 15 Dec 2013 02:50:48 +0400 Subject: [PATCH 5/8] fix bug with fixedWidth gutter + firstLineNumber --- lib/ace/layer/gutter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/layer/gutter.js b/lib/ace/layer/gutter.js index cd8622d8..5a535094 100644 --- a/lib/ace/layer/gutter.js +++ b/lib/ace/layer/gutter.js @@ -214,7 +214,7 @@ var Gutter = function(parentEl) { this.element.style.height = config.minHeight + "px"; if (this.$fixedWidth || session.$useWrapMode) - lastLineNumber = session.getLength(); + lastLineNumber = session.getLength() + firstLineNumber; var gutterWidth = gutterRenderer ? gutterRenderer.getWidth(session, lastLineNumber, config) From 6285bf5d5a0c515d40d93ba0b4735194f859ea0e Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 15 Dec 2013 21:18:13 +0400 Subject: [PATCH 6/8] update cssLint and coffee --- demo/kitchen-sink/require.js | 28 +- lib/ace/mode/coffee/helpers.js | 2 +- lib/ace/mode/coffee/lexer.js | 76 +- lib/ace/mode/coffee/nodes.js | 714 ++++++++++--------- lib/ace/mode/coffee/rewriter.js | 69 +- lib/ace/mode/css/csslint.js | 1182 ++++++++++++++++--------------- tool/update_deps.js | 2 +- 7 files changed, 1086 insertions(+), 987 deletions(-) diff --git a/demo/kitchen-sink/require.js b/demo/kitchen-sink/require.js index c0da866b..267b7690 100644 --- a/demo/kitchen-sink/require.js +++ b/demo/kitchen-sink/require.js @@ -1,5 +1,5 @@ /** vim: et:ts=4:sw=4:sts=4 - * @license RequireJS 2.1.8+ Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. + * @license RequireJS 2.1.9+ Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. * Available via the MIT or new BSD license. * see: http://github.com/jrburke/requirejs for details */ @@ -12,7 +12,7 @@ var requirejs, require, define; (function (global) { var req, s, head, baseElement, dataMain, src, interactiveScript, currentlyAddingScript, mainScript, subPath, - version = '2.1.8+', + version = '2.1.9+', commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, jsSuffixRegExp = /\.js$/, @@ -22,7 +22,7 @@ var requirejs, require, define; hasOwn = op.hasOwnProperty, ap = Array.prototype, apsp = ap.splice, - isBrowser = !!(typeof window !== 'undefined' && navigator && window.document), + isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document), isWebWorker = !isBrowser && typeof importScripts !== 'undefined', //PS3 indicates loaded and complete, but need to wait for complete //specifically. Sequence is 'loading', 'loaded', execution, @@ -373,7 +373,6 @@ var requirejs, require, define; function hasPathFallback(id) { var pathConfig = getOwn(config.paths, id); if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) { - removeScript(id); //Pop off the first array value, since it failed, and //retry pathConfig.shift(); @@ -549,7 +548,7 @@ var requirejs, require, define; //local var ref to defQueue, so cannot just reassign the one //on context. apsp.apply(defQueue, - [defQueue.length - 1, 0].concat(globalDefQueue)); + [defQueue.length, 0].concat(globalDefQueue)); globalDefQueue = []; } } @@ -629,7 +628,7 @@ var requirejs, require, define; } function checkLoaded() { - var map, modId, err, usingPathFallback, + var err, usingPathFallback, waitInterval = config.waitSeconds * 1000, //It is possible to disable the wait interval by using waitSeconds of 0. expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(), @@ -647,8 +646,8 @@ var requirejs, require, define; //Figure out the state of all the modules. eachProp(enabledRegistry, function (mod) { - map = mod.map; - modId = map.id; + var map = mod.map, + modId = map.id; //Skip things that are not enabled or in error state. if (!mod.enabled) { @@ -1464,10 +1463,21 @@ var requirejs, require, define; var map = makeModuleMap(id, relMap, true), mod = getOwn(registry, id); + removeScript(id); + delete defined[id]; delete urlFetched[map.url]; delete undefEvents[id]; + //Clean queued defines too. Go backwards + //in array so that the splices do not + //mess up the iteration. + eachReverse(defQueue, function(args, i) { + if(args[0] === id) { + defQueue.splice(i, 1); + } + }); + if (mod) { //Hold on to listeners in case the //module will be attempted to be reloaded @@ -1918,7 +1928,7 @@ var requirejs, require, define; } //Look for a data-main script attribute, which could also adjust the baseUrl. - if (isBrowser) { + if (isBrowser && !cfg.skipDataMain) { //Figure out baseUrl. Get it from the script tag with require.js in it. eachReverse(scripts(), function (script) { //Set the 'head' where we can append children by diff --git a/lib/ace/mode/coffee/helpers.js b/lib/ace/mode/coffee/helpers.js index fe73f2b7..60412fc6 100644 --- a/lib/ace/mode/coffee/helpers.js +++ b/lib/ace/mode/coffee/helpers.js @@ -194,7 +194,7 @@ define(function(require, exports, module) { pathSep = useWinPathSep ? /\\|\// : /\//; parts = file.split(pathSep); file = parts[parts.length - 1]; - if (!stripExt) { + if (!(stripExt && file.indexOf('.') >= 0)) { return file; } parts = file.split('.'); diff --git a/lib/ace/mode/coffee/lexer.js b/lib/ace/mode/coffee/lexer.js index ed02bfe0..05d85236 100644 --- a/lib/ace/mode/coffee/lexer.js +++ b/lib/ace/mode/coffee/lexer.js @@ -193,30 +193,25 @@ define(function(require, exports, module) { }; Lexer.prototype.stringToken = function() { - var match, octalEsc, string; - switch (this.chunk.charAt(0)) { + var octalEsc, quote, string, trimmed; + switch (quote = this.chunk.charAt(0)) { case "'": - if (!(match = SIMPLESTR.exec(this.chunk))) { - return 0; - } - string = match[0]; - this.token('STRING', string.replace(MULTILINER, '\\\n'), 0, string.length); + string = SIMPLESTR.exec(this.chunk)[0]; break; case '"': - if (!(string = this.balancedString(this.chunk, '"'))) { - return 0; - } - if (0 < string.indexOf('#{', 1)) { - this.interpolateString(string.slice(1, -1), { - strOffset: 1, - lexedLength: string.length - }); - } else { - this.token('STRING', this.escapeLines(string, 0, string.length)); - } - break; - default: - return 0; + string = this.balancedString(this.chunk, '"'); + } + if (!string) { + return 0; + } + trimmed = this.removeNewlines(string.slice(1, -1)); + if (quote === '"' && 0 < string.indexOf('#{', 1)) { + this.interpolateString(trimmed, { + strOffset: 1, + lexedLength: string.length + }); + } else { + this.token('STRING', quote + this.escapeLines(trimmed) + quote, 0, string.length); } if (octalEsc = /^(?:\\.|[^\\])*\\(?:0[0-7]|[1-7])/.test(string)) { this.error("octal escape sequences " + string + " are not allowed"); @@ -302,7 +297,7 @@ define(function(require, exports, module) { var body, flags, flagsOffset, heregex, plusToken, prev, re, tag, token, tokens, value, _i, _len, _ref2, _ref3, _ref4; heregex = match[0], body = match[1], flags = match[2]; if (0 > body.indexOf('#{')) { - re = body.replace(HEREGEX_OMIT, '').replace(/\//g, '\\/'); + re = this.escapeLines(body.replace(HEREGEX_OMIT, '$1$2').replace(/\//g, '\\/'), true); if (re.match(/^\*/)) { this.error('regular expressions cannot begin with `*`'); } @@ -321,7 +316,7 @@ define(function(require, exports, module) { if (tag === 'TOKENS') { tokens.push.apply(tokens, value); } else if (tag === 'NEOSTRING') { - if (!(value = value.replace(HEREGEX_OMIT, ''))) { + if (!(value = value.replace(HEREGEX_OMIT, '$1$2'))) { continue; } value = value.replace(/\\/g, '\\\\'); @@ -628,10 +623,6 @@ define(function(require, exports, module) { offsetInChunk = offsetInChunk || 0; strOffset = strOffset || 0; lexedLength = lexedLength || str.length; - if (heredoc && str.length > 0 && str[0] === '\n') { - str = str.slice(1); - strOffset++; - } tokens = []; pi = 0; i = -1; @@ -789,16 +780,31 @@ define(function(require, exports, module) { return LINE_CONTINUER.test(this.chunk) || ((_ref2 = this.tag()) === '\\' || _ref2 === '.' || _ref2 === '?.' || _ref2 === '?::' || _ref2 === 'UNARY' || _ref2 === 'MATH' || _ref2 === '+' || _ref2 === '-' || _ref2 === 'SHIFT' || _ref2 === 'RELATION' || _ref2 === 'COMPARE' || _ref2 === 'LOGIC' || _ref2 === 'THROW' || _ref2 === 'EXTENDS'); }; + Lexer.prototype.removeNewlines = function(str) { + return str.replace(/^\s*\n\s*/, '').replace(/([^\\]|\\\\)\s*\n\s*$/, '$1'); + }; + Lexer.prototype.escapeLines = function(str, heredoc) { - return str.replace(MULTILINER, heredoc ? '\\n' : ''); + str = str.replace(/\\[^\S\n]*(\n|\\)\s*/g, function(escaped, character) { + if (character === '\n') { + return ''; + } else { + return escaped; + } + }); + if (heredoc) { + return str.replace(MULTILINER, '\\n'); + } else { + return str.replace(/\s*\n\s*/g, ' '); + } }; Lexer.prototype.makeString = function(body, quote, heredoc) { if (!body) { return quote + quote; } - body = body.replace(/\\([\s\S])/g, function(match, contents) { - if (contents === '\n' || contents === quote) { + body = body.replace(RegExp("\\\\(" + quote + "|\\\\)", "g"), function(match, contents) { + if (contents === quote) { return contents; } else { return match; @@ -867,27 +873,27 @@ define(function(require, exports, module) { NUMBER = /^0b[01]+|^0o[0-7]+|^0x[\da-f]+|^\d*\.?\d+(?:e[+-]?\d+)?/i; - HEREDOC = /^("""|''')([\s\S]*?)(?:\n[^\n\S]*)?\1/; + HEREDOC = /^("""|''')((?:\\[\s\S]|[^\\])*?)(?:\n[^\n\S]*)?\1/; OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?(\.|::)|\.{2,3})/; WHITESPACE = /^[^\n\S]+/; - COMMENT = /^###([^#][\s\S]*?)(?:###[^\n\S]*|(?:###)$)|^(?:\s*#(?!##[^#]).*)+/; + COMMENT = /^###([^#][\s\S]*?)(?:###[^\n\S]*|###$)|^(?:\s*#(?!##[^#]).*)+/; CODE = /^[-=]>/; MULTI_DENT = /^(?:\n[^\n\S]*)+/; - SIMPLESTR = /^'[^\\']*(?:\\.[^\\']*)*'/; + SIMPLESTR = /^'[^\\']*(?:\\[\s\S][^\\']*)*'/; JSTOKEN = /^`[^\\`]*(?:\\.[^\\`]*)*`/; REGEX = /^(\/(?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/)([imgy]{0,4})(?!\w)/; - HEREGEX = /^\/{3}([\s\S]+?)\/{3}([imgy]{0,4})(?!\w)/; + HEREGEX = /^\/{3}((?:\\?[\s\S])+?)\/{3}([imgy]{0,4})(?!\w)/; - HEREGEX_OMIT = /\s+(?:#.*)?/g; + HEREGEX_OMIT = /((?:\\\\)+)|\\(\s|\/)|\s+(?:#.*)?/g; MULTILINER = /\n/g; diff --git a/lib/ace/mode/coffee/nodes.js b/lib/ace/mode/coffee/nodes.js index b97dd58a..52afdf2c 100644 --- a/lib/ace/mode/coffee/nodes.js +++ b/lib/ace/mode/coffee/nodes.js @@ -27,7 +27,7 @@ define(function(require, exports, module) { // Generated by CoffeeScript 1.6.3 - var Access, Arr, Assign, Base, Block, Call, Class, Closure, Code, CodeFragment, Comment, Existence, Extends, For, IDENTIFIER, IDENTIFIER_STR, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, METHOD_DEF, NEGATE, NO, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, STRICT_PROSCRIBED, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, addLocationDataFn, compact, del, ends, extend, flatten, fragmentsToText, last, locationDataToString, merge, multident, some, starts, throwSyntaxError, unfoldSoak, utility, _ref, _ref1, _ref2, _ref3, + var Access, Arr, Assign, Base, Block, Call, Class, Code, CodeFragment, Comment, Existence, Extends, For, HEXNUM, IDENTIFIER, IDENTIFIER_STR, IS_REGEX, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, METHOD_DEF, NEGATE, NO, NUMBER, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, STRICT_PROSCRIBED, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, addLocationDataFn, compact, del, ends, extend, flatten, fragmentsToText, isLiteralArguments, isLiteralThis, last, locationDataToString, merge, multident, parseNum, some, starts, throwSyntaxError, unfoldSoak, utility, _ref, _ref1, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, @@ -114,12 +114,24 @@ define(function(require, exports, module) { }; Base.prototype.compileClosure = function(o) { - var jumpNode; + var args, argumentsNode, func, jumpNode, meth; if (jumpNode = this.jumps()) { jumpNode.error('cannot use a pure statement in an expression'); } o.sharedScope = true; - return Closure.wrap(this).compileNode(o); + func = new Code([], Block.wrap([this])); + args = []; + if ((argumentsNode = this.contains(isLiteralArguments)) || this.contains(isLiteralThis)) { + args = [new Literal('this')]; + if (argumentsNode) { + meth = 'apply'; + args.push(new Literal('arguments')); + } else { + meth = 'call'; + } + func = new Value(func, [new Access(new Literal(meth))]); + } + return (new Call(func, args)).compileNode(o); }; Base.prototype.cache = function(o, level, reused) { @@ -342,12 +354,12 @@ define(function(require, exports, module) { }; Block.prototype.jumps = function(o) { - var exp, _i, _len, _ref2; + var exp, jumpNode, _i, _len, _ref2; _ref2 = this.expressions; for (_i = 0, _len = _ref2.length; _i < _len; _i++) { exp = _ref2[_i]; - if (exp.jumps(o)) { - return exp; + if (jumpNode = exp.jumps(o)) { + return jumpNode; } } }; @@ -582,8 +594,7 @@ define(function(require, exports, module) { __extends(Undefined, _super); function Undefined() { - _ref2 = Undefined.__super__.constructor.apply(this, arguments); - return _ref2; + return Undefined.__super__.constructor.apply(this, arguments); } Undefined.prototype.isAssignable = NO; @@ -602,8 +613,7 @@ define(function(require, exports, module) { __extends(Null, _super); function Null() { - _ref3 = Null.__super__.constructor.apply(this, arguments); - return _ref3; + return Null.__super__.constructor.apply(this, arguments); } Null.prototype.isAssignable = NO; @@ -655,8 +665,8 @@ define(function(require, exports, module) { Return.prototype.jumps = THIS; Return.prototype.compileToFragments = function(o, level) { - var expr, _ref4; - expr = (_ref4 = this.expression) != null ? _ref4.makeReturn() : void 0; + var expr, _ref2; + expr = (_ref2 = this.expression) != null ? _ref2.makeReturn() : void 0; if (expr && !(expr instanceof Return)) { return expr.compileToFragments(o, level); } else { @@ -705,8 +715,16 @@ define(function(require, exports, module) { return !!this.properties.length; }; + Value.prototype.bareLiteral = function(type) { + return !this.properties.length && this.base instanceof type; + }; + Value.prototype.isArray = function() { - return !this.properties.length && this.base instanceof Arr; + return this.bareLiteral(Arr); + }; + + Value.prototype.isRange = function() { + return this.bareLiteral(Range); }; Value.prototype.isComplex = function() { @@ -718,18 +736,22 @@ define(function(require, exports, module) { }; Value.prototype.isSimpleNumber = function() { - return this.base instanceof Literal && SIMPLENUM.test(this.base.value); + return this.bareLiteral(Literal) && SIMPLENUM.test(this.base.value); }; Value.prototype.isString = function() { - return this.base instanceof Literal && IS_STRING.test(this.base.value); + return this.bareLiteral(Literal) && IS_STRING.test(this.base.value); + }; + + Value.prototype.isRegex = function() { + return this.bareLiteral(Literal) && IS_REGEX.test(this.base.value); }; Value.prototype.isAtomic = function() { - var node, _i, _len, _ref4; - _ref4 = this.properties.concat(this.base); - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - node = _ref4[_i]; + var node, _i, _len, _ref2; + _ref2 = this.properties.concat(this.base); + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + node = _ref2[_i]; if (node.soak || node instanceof Call) { return false; } @@ -737,6 +759,10 @@ define(function(require, exports, module) { return true; }; + Value.prototype.isNotCallable = function() { + return this.isSimpleNumber() || this.isString() || this.isRegex() || this.isArray() || this.isRange() || this.isSplice() || this.isObject(); + }; + Value.prototype.isStatement = function(o) { return !this.properties.length && this.base.isStatement(o); }; @@ -760,6 +786,11 @@ define(function(require, exports, module) { return last(this.properties) instanceof Slice; }; + Value.prototype.looksStatic = function(className) { + var _ref2; + return this.base.value === className && this.properties.length && ((_ref2 = this.properties[0].name) != null ? _ref2.value : void 0) !== 'prototype'; + }; + Value.prototype.unwrap = function() { if (this.properties.length) { return this; @@ -806,33 +837,34 @@ define(function(require, exports, module) { }; Value.prototype.unfoldSoak = function(o) { - var _this = this; - return this.unfoldedSoak != null ? this.unfoldedSoak : this.unfoldedSoak = (function() { - var fst, i, ifn, prop, ref, snd, _i, _len, _ref4, _ref5; - if (ifn = _this.base.unfoldSoak(o)) { - (_ref4 = ifn.body.properties).push.apply(_ref4, _this.properties); - return ifn; - } - _ref5 = _this.properties; - for (i = _i = 0, _len = _ref5.length; _i < _len; i = ++_i) { - prop = _ref5[i]; - if (!prop.soak) { - continue; + return this.unfoldedSoak != null ? this.unfoldedSoak : this.unfoldedSoak = (function(_this) { + return function() { + var fst, i, ifn, prop, ref, snd, _i, _len, _ref2, _ref3; + if (ifn = _this.base.unfoldSoak(o)) { + (_ref2 = ifn.body.properties).push.apply(_ref2, _this.properties); + return ifn; } - prop.soak = false; - fst = new Value(_this.base, _this.properties.slice(0, i)); - snd = new Value(_this.base, _this.properties.slice(i)); - if (fst.isComplex()) { - ref = new Literal(o.scope.freeVariable('ref')); - fst = new Parens(new Assign(ref, fst)); - snd.base = ref; + _ref3 = _this.properties; + for (i = _i = 0, _len = _ref3.length; _i < _len; i = ++_i) { + prop = _ref3[i]; + if (!prop.soak) { + continue; + } + prop.soak = false; + fst = new Value(_this.base, _this.properties.slice(0, i)); + snd = new Value(_this.base, _this.properties.slice(i)); + if (fst.isComplex()) { + ref = new Literal(o.scope.freeVariable('ref')); + fst = new Parens(new Assign(ref, fst)); + snd.base = ref; + } + return new If(new Existence(fst), snd, { + soak: true + }); } - return new If(new Existence(fst), snd, { - soak: true - }); - } - return false; - })(); + return false; + }; + })(this)(); }; return Value; @@ -851,8 +883,9 @@ define(function(require, exports, module) { Comment.prototype.makeReturn = THIS; Comment.prototype.compileNode = function(o, level) { - var code; - code = "/*" + (multident(this.comment, this.tab)) + (__indexOf.call(this.comment, '\n') >= 0 ? "\n" + this.tab : '') + "*/"; + var code, comment; + comment = this.comment.replace(/^(\s*)#/gm, "$1 *"); + code = "/*" + (multident(comment, this.tab)) + (__indexOf.call(comment, '\n') >= 0 ? "\n" + this.tab : '') + " */"; if ((level || o.level) === LEVEL_TOP) { code = o.indent + code; } @@ -872,13 +905,16 @@ define(function(require, exports, module) { this.isNew = false; this.isSuper = variable === 'super'; this.variable = this.isSuper ? null : variable; + if (variable instanceof Value && variable.isNotCallable()) { + variable.error("literal is not a function"); + } } Call.prototype.children = ['variable', 'args']; Call.prototype.newInstance = function() { - var base, _ref4; - base = ((_ref4 = this.variable) != null ? _ref4.base : void 0) || this.variable; + var base, _ref2; + base = ((_ref2 = this.variable) != null ? _ref2.base : void 0) || this.variable; if (base instanceof Call && !base.isNew) { base.newInstance(); } else { @@ -911,13 +947,13 @@ define(function(require, exports, module) { }; Call.prototype.unfoldSoak = function(o) { - var call, ifn, left, list, rite, _i, _len, _ref4, _ref5; + var call, ifn, left, list, rite, _i, _len, _ref2, _ref3; if (this.soak) { if (this.variable) { if (ifn = unfoldSoak(o, this, 'variable')) { return ifn; } - _ref4 = new Value(this.variable).cacheReference(o), left = _ref4[0], rite = _ref4[1]; + _ref2 = new Value(this.variable).cacheReference(o), left = _ref2[0], rite = _ref2[1]; } else { left = new Literal(this.superReference(o)); rite = new Value(left); @@ -945,9 +981,9 @@ define(function(require, exports, module) { break; } } - _ref5 = list.reverse(); - for (_i = 0, _len = _ref5.length; _i < _len; _i++) { - call = _ref5[_i]; + _ref3 = list.reverse(); + for (_i = 0, _len = _ref3.length; _i < _len; _i++) { + call = _ref3[_i]; if (ifn) { if (call.variable instanceof Call) { call.variable = ifn; @@ -961,18 +997,18 @@ define(function(require, exports, module) { }; Call.prototype.compileNode = function(o) { - var arg, argIndex, compiledArgs, compiledArray, fragments, preface, _i, _len, _ref4, _ref5; - if ((_ref4 = this.variable) != null) { - _ref4.front = this.front; + var arg, argIndex, compiledArgs, compiledArray, fragments, preface, _i, _len, _ref2, _ref3; + if ((_ref2 = this.variable) != null) { + _ref2.front = this.front; } compiledArray = Splat.compileSplattedArray(o, this.args, true); if (compiledArray.length) { return this.compileSplat(o, compiledArray); } compiledArgs = []; - _ref5 = this.args; - for (argIndex = _i = 0, _len = _ref5.length; _i < _len; argIndex = ++_i) { - arg = _ref5[argIndex]; + _ref3 = this.args; + for (argIndex = _i = 0, _len = _ref3.length; _i < _len; argIndex = ++_i) { + arg = _ref3[argIndex]; if (argIndex) { compiledArgs.push(this.makeCode(", ")); } @@ -1112,23 +1148,23 @@ define(function(require, exports, module) { } Range.prototype.compileVariables = function(o) { - var step, _ref4, _ref5, _ref6, _ref7; + var step, _ref2, _ref3, _ref4, _ref5; o = merge(o, { top: true }); - _ref4 = this.cacheToCodeFragments(this.from.cache(o, LEVEL_LIST)), this.fromC = _ref4[0], this.fromVar = _ref4[1]; - _ref5 = this.cacheToCodeFragments(this.to.cache(o, LEVEL_LIST)), this.toC = _ref5[0], this.toVar = _ref5[1]; + _ref2 = this.cacheToCodeFragments(this.from.cache(o, LEVEL_LIST)), this.fromC = _ref2[0], this.fromVar = _ref2[1]; + _ref3 = this.cacheToCodeFragments(this.to.cache(o, LEVEL_LIST)), this.toC = _ref3[0], this.toVar = _ref3[1]; if (step = del(o, 'step')) { - _ref6 = this.cacheToCodeFragments(step.cache(o, LEVEL_LIST)), this.step = _ref6[0], this.stepVar = _ref6[1]; + _ref4 = this.cacheToCodeFragments(step.cache(o, LEVEL_LIST)), this.step = _ref4[0], this.stepVar = _ref4[1]; } - _ref7 = [this.fromVar.match(SIMPLENUM), this.toVar.match(SIMPLENUM)], this.fromNum = _ref7[0], this.toNum = _ref7[1]; + _ref5 = [this.fromVar.match(NUMBER), this.toVar.match(NUMBER)], this.fromNum = _ref5[0], this.toNum = _ref5[1]; if (this.stepVar) { - return this.stepNum = this.stepVar.match(SIMPLENUM); + return this.stepNum = this.stepVar.match(NUMBER); } }; Range.prototype.compileNode = function(o) { - var cond, condPart, from, gt, idx, idxName, known, lt, namedIndex, stepPart, to, varPart, _ref4, _ref5; + var cond, condPart, from, gt, idx, idxName, known, lt, namedIndex, stepPart, to, varPart, _ref2, _ref3; if (!this.fromVar) { this.compileVariables(o); } @@ -1146,8 +1182,8 @@ define(function(require, exports, module) { if (this.step !== this.stepVar) { varPart += ", " + this.step; } - _ref4 = ["" + idx + " <" + this.equals, "" + idx + " >" + this.equals], lt = _ref4[0], gt = _ref4[1]; - condPart = this.stepNum ? +this.stepNum > 0 ? "" + lt + " " + this.toVar : "" + gt + " " + this.toVar : known ? ((_ref5 = [+this.fromNum, +this.toNum], from = _ref5[0], to = _ref5[1], _ref5), from <= to ? "" + lt + " " + to : "" + gt + " " + to) : (cond = this.stepVar ? "" + this.stepVar + " > 0" : "" + this.fromVar + " <= " + this.toVar, "" + cond + " ? " + lt + " " + this.toVar + " : " + gt + " " + this.toVar); + _ref2 = ["" + idx + " <" + this.equals, "" + idx + " >" + this.equals], lt = _ref2[0], gt = _ref2[1]; + condPart = this.stepNum ? parseNum(this.stepNum[0]) > 0 ? "" + lt + " " + this.toVar : "" + gt + " " + this.toVar : known ? ((_ref3 = [parseNum(this.fromNum[0]), parseNum(this.toNum[0])], from = _ref3[0], to = _ref3[1], _ref3), from <= to ? "" + lt + " " + to : "" + gt + " " + to) : (cond = this.stepVar ? "" + this.stepVar + " > 0" : "" + this.fromVar + " <= " + this.toVar, "" + cond + " ? " + lt + " " + this.toVar + " : " + gt + " " + this.toVar); stepPart = this.stepVar ? "" + idx + " += " + this.stepVar : known ? namedIndex ? from <= to ? "++" + idx : "--" + idx : from <= to ? "" + idx + "++" : "" + idx + "--" : namedIndex ? "" + cond + " ? ++" + idx + " : --" + idx : "" + cond + " ? " + idx + "++ : " + idx + "--"; if (namedIndex) { varPart = "" + idxName + " = " + varPart; @@ -1159,11 +1195,11 @@ define(function(require, exports, module) { }; Range.prototype.compileArray = function(o) { - var args, body, cond, hasArgs, i, idt, post, pre, range, result, vars, _i, _ref4, _ref5, _results; + var args, body, cond, hasArgs, i, idt, post, pre, range, result, vars, _i, _ref2, _ref3, _results; if (this.fromNum && this.toNum && Math.abs(this.fromNum - this.toNum) <= 20) { range = (function() { _results = []; - for (var _i = _ref4 = +this.fromNum, _ref5 = +this.toNum; _ref4 <= _ref5 ? _i <= _ref5 : _i >= _ref5; _ref4 <= _ref5 ? _i++ : _i--){ _results.push(_i); } + for (var _i = _ref2 = +this.fromNum, _ref3 = +this.toNum; _ref2 <= _ref3 ? _i <= _ref3 : _i >= _ref3; _ref2 <= _ref3 ? _i++ : _i--){ _results.push(_i); } return _results; }).apply(this); if (this.exclusive) { @@ -1185,9 +1221,7 @@ define(function(require, exports, module) { } post = "{ " + result + ".push(" + i + "); }\n" + idt + "return " + result + ";\n" + o.indent; hasArgs = function(node) { - return node != null ? node.contains(function(n) { - return n instanceof Literal && n.value === 'arguments' && !n.asKey; - }) : void 0; + return node != null ? node.contains(isLiteralArguments) : void 0; }; if (hasArgs(this.from) || hasArgs(this.to)) { args = ', arguments'; @@ -1210,8 +1244,8 @@ define(function(require, exports, module) { } Slice.prototype.compileNode = function(o) { - var compiled, compiledText, from, fromCompiled, to, toStr, _ref4; - _ref4 = this.range, to = _ref4.to, from = _ref4.from; + var compiled, compiledText, from, fromCompiled, to, toStr, _ref2; + _ref2 = this.range, to = _ref2.to, from = _ref2.from; fromCompiled = from && from.compileToFragments(o, LEVEL_PAREN) || [this.makeCode('0')]; if (to) { compiled = to.compileToFragments(o, LEVEL_PAREN); @@ -1288,10 +1322,10 @@ define(function(require, exports, module) { }; Obj.prototype.assigns = function(name) { - var prop, _i, _len, _ref4; - _ref4 = this.properties; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - prop = _ref4[_i]; + var prop, _i, _len, _ref2; + _ref2 = this.properties; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + prop = _ref2[_i]; if (prop.assigns(name)) { return true; } @@ -1324,11 +1358,11 @@ define(function(require, exports, module) { } answer = []; compiledObjs = (function() { - var _i, _len, _ref4, _results; - _ref4 = this.objects; + var _i, _len, _ref2, _results; + _ref2 = this.objects; _results = []; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - obj = _ref4[_i]; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + obj = _ref2[_i]; _results.push(obj.compileToFragments(o, LEVEL_LIST)); } return _results; @@ -1351,10 +1385,10 @@ define(function(require, exports, module) { }; Arr.prototype.assigns = function(name) { - var obj, _i, _len, _ref4; - _ref4 = this.objects; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - obj = _ref4[_i]; + var obj, _i, _len, _ref2; + _ref2 = this.objects; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + obj = _ref2[_i]; if (obj.assigns(name)) { return true; } @@ -1408,10 +1442,10 @@ define(function(require, exports, module) { }; Class.prototype.addBoundFunctions = function(o) { - var bvar, lhs, _i, _len, _ref4; - _ref4 = this.boundFuncs; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - bvar = _ref4[_i]; + var bvar, lhs, _i, _len, _ref2; + _ref2 = this.boundFuncs; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + bvar = _ref2[_i]; lhs = (new Value(new Literal("this"), [new Access(bvar)])).compile(o); this.ctor.body.unshift(new Literal("" + lhs + " = " + (utility('bind')) + "(" + lhs + ", this)")); } @@ -1438,15 +1472,12 @@ define(function(require, exports, module) { if (func instanceof Code) { assign = this.ctor = func; } else { - this.externalCtor = o.scope.freeVariable('class'); + this.externalCtor = o.classScope.freeVariable('class'); assign = new Assign(new Literal(this.externalCtor), func); } } else { if (assign.variable["this"]) { func["static"] = true; - if (func.bound) { - func.context = name; - } } else { assign.variable = new Value(new Literal(name), [new Access(new Literal('prototype')), new Access(base)]); if (func instanceof Code && func.bound) { @@ -1464,26 +1495,29 @@ define(function(require, exports, module) { }; Class.prototype.walkBody = function(name, o) { - var _this = this; - return this.traverseChildren(false, function(child) { - var cont, exps, i, node, _i, _len, _ref4; - cont = true; - if (child instanceof Class) { - return false; - } - if (child instanceof Block) { - _ref4 = exps = child.expressions; - for (i = _i = 0, _len = _ref4.length; _i < _len; i = ++_i) { - node = _ref4[i]; - if (node instanceof Value && node.isObject(true)) { - cont = false; - exps[i] = _this.addProperties(node, name, o); - } + return this.traverseChildren(false, (function(_this) { + return function(child) { + var cont, exps, i, node, _i, _len, _ref2; + cont = true; + if (child instanceof Class) { + return false; } - child.expressions = exps = flatten(exps); - } - return cont && !(child instanceof Class); - }); + if (child instanceof Block) { + _ref2 = exps = child.expressions; + for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) { + node = _ref2[i]; + if (node instanceof Assign && node.variable.looksStatic(name)) { + node.value["static"] = true; + } else if (node instanceof Value && node.isObject(true)) { + cont = false; + exps[i] = _this.addProperties(node, name, o); + } + } + child.expressions = exps = flatten(exps); + } + return cont && !(child instanceof Class); + }; + })(this)); }; Class.prototype.hoistDirectivePrologue = function() { @@ -1496,62 +1530,53 @@ define(function(require, exports, module) { return this.directives = expressions.splice(0, index); }; - Class.prototype.ensureConstructor = function(name, o) { - var missing, ref, superCall; - missing = !this.ctor; - this.ctor || (this.ctor = new Code); + Class.prototype.ensureConstructor = function(name) { + if (!this.ctor) { + this.ctor = new Code; + if (this.externalCtor) { + this.ctor.body.push(new Literal("" + this.externalCtor + ".apply(this, arguments)")); + } else if (this.parent) { + this.ctor.body.push(new Literal("" + name + ".__super__.constructor.apply(this, arguments)")); + } + this.ctor.body.makeReturn(); + this.body.expressions.unshift(this.ctor); + } this.ctor.ctor = this.ctor.name = name; this.ctor.klass = null; - this.ctor.noReturn = true; - if (missing) { - if (this.parent) { - superCall = new Literal("" + name + ".__super__.constructor.apply(this, arguments)"); - } - if (this.externalCtor) { - superCall = new Literal("" + this.externalCtor + ".apply(this, arguments)"); - } - if (superCall) { - ref = new Literal(o.scope.freeVariable('ref')); - this.ctor.body.unshift(new Assign(ref, superCall)); - } - this.addBoundFunctions(o); - if (superCall) { - this.ctor.body.push(ref); - this.ctor.body.makeReturn(); - } - return this.body.expressions.unshift(this.ctor); - } else { - return this.addBoundFunctions(o); - } + return this.ctor.noReturn = true; }; Class.prototype.compileNode = function(o) { - var call, decl, klass, lname, name, params, _ref4; - decl = this.determineName(); - name = decl || '_Class'; + var args, argumentsNode, func, jumpNode, klass, lname, name, superClass, _ref2; + if (jumpNode = this.body.jumps()) { + jumpNode.error('Class bodies cannot contain pure statements'); + } + if (argumentsNode = this.body.contains(isLiteralArguments)) { + argumentsNode.error("Class bodies shouldn't reference arguments"); + } + name = this.determineName() || '_Class'; if (name.reserved) { name = "_" + name; } lname = new Literal(name); + func = new Code([], Block.wrap([this.body])); + args = []; + o.classScope = func.makeScope(o.scope); this.hoistDirectivePrologue(); this.setContext(name); this.walkBody(name, o); - this.ensureConstructor(name, o); + this.ensureConstructor(name); + this.addBoundFunctions(o); this.body.spaced = true; - if (!(this.ctor instanceof Code)) { - this.body.expressions.unshift(this.ctor); - } this.body.expressions.push(lname); - (_ref4 = this.body.expressions).unshift.apply(_ref4, this.directives); - call = Closure.wrap(this.body); if (this.parent) { - this.superClass = new Literal(o.scope.freeVariable('super', false)); - this.body.expressions.unshift(new Extends(lname, this.superClass)); - call.args.push(this.parent); - params = call.variable.params || call.variable.base.params; - params.push(new Param(this.superClass)); + superClass = new Literal(o.classScope.freeVariable('super', false)); + this.body.expressions.unshift(new Extends(lname, superClass)); + func.params.push(new Param(superClass)); + args.push(this.parent); } - klass = new Parens(call, true); + (_ref2 = this.body.expressions).unshift.apply(_ref2, this.directives); + klass = new Parens(new Call(func, args)); if (this.variable) { klass = new Assign(this.variable, klass); } @@ -1566,13 +1591,13 @@ define(function(require, exports, module) { __extends(Assign, _super); function Assign(variable, value, context, options) { - var forbidden, name, _ref4; + var forbidden, name, _ref2; this.variable = variable; this.value = value; this.context = context; this.param = options && options.param; this.subpattern = options && options.subpattern; - forbidden = (_ref4 = (name = this.variable.unwrapAll().value), __indexOf.call(STRICT_PROSCRIBED, _ref4) >= 0); + forbidden = (_ref2 = (name = this.variable.unwrapAll().value), __indexOf.call(STRICT_PROSCRIBED, _ref2) >= 0); if (forbidden && this.context !== 'object') { this.variable.error("variable name may not be \"" + name + "\""); } @@ -1593,7 +1618,7 @@ define(function(require, exports, module) { }; Assign.prototype.compileNode = function(o) { - var answer, compiledName, isValue, match, name, val, varBase, _ref4, _ref5, _ref6, _ref7; + var answer, compiledName, isValue, match, name, val, varBase, _ref2, _ref3, _ref4; if (isValue = this.variable instanceof Value) { if (this.variable.isArray() || this.variable.isObject()) { return this.compilePatternMatch(o); @@ -1601,7 +1626,7 @@ define(function(require, exports, module) { if (this.variable.isSplice()) { return this.compileSplice(o); } - if ((_ref4 = this.context) === '||=' || _ref4 === '&&=' || _ref4 === '?=') { + if ((_ref2 = this.context) === '||=' || _ref2 === '&&=' || _ref2 === '?=') { return this.compileConditional(o); } } @@ -1621,10 +1646,10 @@ define(function(require, exports, module) { } } if (this.value instanceof Code && (match = METHOD_DEF.exec(name))) { - if (match[1]) { + if (match[2]) { this.value.klass = match[1]; } - this.value.name = (_ref5 = (_ref6 = (_ref7 = match[2]) != null ? _ref7 : match[3]) != null ? _ref6 : match[4]) != null ? _ref5 : match[5]; + this.value.name = (_ref3 = (_ref4 = match[3]) != null ? _ref4 : match[4]) != null ? _ref3 : match[5]; } val = this.value.compileToFragments(o, LEVEL_LIST); if (this.context === 'object') { @@ -1639,7 +1664,7 @@ define(function(require, exports, module) { }; Assign.prototype.compilePatternMatch = function(o) { - var acc, assigns, code, fragments, i, idx, isObject, ivar, name, obj, objects, olen, ref, rest, splat, top, val, value, vvar, vvarText, _i, _len, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9; + var acc, assigns, code, fragments, i, idx, isObject, ivar, name, obj, objects, olen, ref, rest, splat, top, val, value, vvar, vvarText, _i, _len, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7; top = o.level === LEVEL_TOP; value = this.value; objects = this.variable.base.objects; @@ -1654,14 +1679,14 @@ define(function(require, exports, module) { isObject = this.variable.isObject(); if (top && olen === 1 && !((obj = objects[0]) instanceof Splat)) { if (obj instanceof Assign) { - _ref4 = obj, (_ref5 = _ref4.variable, idx = _ref5.base), obj = _ref4.value; + _ref2 = obj, (_ref3 = _ref2.variable, idx = _ref3.base), obj = _ref2.value; } else { idx = isObject ? obj["this"] ? obj.properties[0].name : obj : new Literal(0); } acc = IDENTIFIER.test(idx.unwrap().value || 0); value = new Value(value); value.properties.push(new (acc ? Access : Index)(idx)); - if (_ref6 = obj.unwrap().value, __indexOf.call(RESERVED, _ref6) >= 0) { + if (_ref4 = obj.unwrap().value, __indexOf.call(RESERVED, _ref4) >= 0) { obj.error("assignment to a reserved word: " + (obj.compile(o))); } return new Assign(obj, value, null, { @@ -1682,10 +1707,10 @@ define(function(require, exports, module) { idx = i; if (isObject) { if (obj instanceof Assign) { - _ref7 = obj, (_ref8 = _ref7.variable, idx = _ref8.base), obj = _ref7.value; + _ref5 = obj, (_ref6 = _ref5.variable, idx = _ref6.base), obj = _ref5.value; } else { if (obj.base instanceof Parens) { - _ref9 = new Value(obj.unwrapAll()).cacheReference(o), obj = _ref9[0], idx = _ref9[1]; + _ref7 = new Value(obj.unwrapAll()).cacheReference(o), obj = _ref7[0], idx = _ref7[1]; } else { idx = obj["this"] ? obj.properties[0].name : obj; } @@ -1736,29 +1761,38 @@ define(function(require, exports, module) { }; Assign.prototype.compileConditional = function(o) { - var left, right, _ref4; - _ref4 = this.variable.cacheReference(o), left = _ref4[0], right = _ref4[1]; + var fragments, left, right, _ref2; + _ref2 = this.variable.cacheReference(o), left = _ref2[0], right = _ref2[1]; if (!left.properties.length && left.base instanceof Literal && left.base.value !== "this" && !o.scope.check(left.base.value)) { this.variable.error("the variable \"" + left.base.value + "\" can't be assigned with " + this.context + " because it has not been declared before"); } if (__indexOf.call(this.context, "?") >= 0) { o.isExistentialEquals = true; + return new If(new Existence(left), right, { + type: 'if' + }).addElse(new Assign(right, this.value, '=')).compileToFragments(o); + } else { + fragments = new Op(this.context.slice(0, -1), left, new Assign(right, this.value, '=')).compileToFragments(o); + if (o.level <= LEVEL_LIST) { + return fragments; + } else { + return this.wrapInBraces(fragments); + } } - return new Op(this.context.slice(0, -1), left, new Assign(right, this.value, '=')).compileToFragments(o); }; Assign.prototype.compileSplice = function(o) { - var answer, exclusive, from, fromDecl, fromRef, name, to, valDef, valRef, _ref4, _ref5, _ref6; - _ref4 = this.variable.properties.pop().range, from = _ref4.from, to = _ref4.to, exclusive = _ref4.exclusive; + var answer, exclusive, from, fromDecl, fromRef, name, to, valDef, valRef, _ref2, _ref3, _ref4; + _ref2 = this.variable.properties.pop().range, from = _ref2.from, to = _ref2.to, exclusive = _ref2.exclusive; name = this.variable.compile(o); if (from) { - _ref5 = this.cacheToCodeFragments(from.cache(o, LEVEL_OP)), fromDecl = _ref5[0], fromRef = _ref5[1]; + _ref3 = this.cacheToCodeFragments(from.cache(o, LEVEL_OP)), fromDecl = _ref3[0], fromRef = _ref3[1]; } else { fromDecl = fromRef = '0'; } if (to) { - if ((from != null ? from.isSimpleNumber() : void 0) && to.isSimpleNumber()) { - to = +to.compile(o) - +fromRef; + if (from instanceof Value && from.isSimpleNumber() && to instanceof Value && to.isSimpleNumber()) { + to = to.compile(o) - fromRef; if (!exclusive) { to += 1; } @@ -1771,7 +1805,7 @@ define(function(require, exports, module) { } else { to = "9e9"; } - _ref6 = this.value.cache(o, LEVEL_LIST), valDef = _ref6[0], valRef = _ref6[1]; + _ref4 = this.value.cache(o, LEVEL_LIST), valDef = _ref4[0], valRef = _ref4[1]; answer = [].concat(this.makeCode("[].splice.apply(" + name + ", [" + fromDecl + ", " + to + "].concat("), valDef, this.makeCode(")), "), valRef); if (o.level > LEVEL_TOP) { return this.wrapInBraces(answer); @@ -1791,9 +1825,6 @@ define(function(require, exports, module) { this.params = params || []; this.body = body || new Block; this.bound = tag === 'boundfunc'; - if (this.bound) { - this.context = '_this'; - } } Code.prototype.children = ['params', 'body']; @@ -1804,29 +1835,43 @@ define(function(require, exports, module) { Code.prototype.jumps = NO; + Code.prototype.makeScope = function(parentScope) { + return new Scope(parentScope, this.body, this); + }; + Code.prototype.compileNode = function(o) { - var answer, code, exprs, i, idt, lit, p, param, params, ref, splats, uniqs, val, wasEmpty, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref4, _ref5, _ref6, _ref7, _ref8; - o.scope = new Scope(o.scope, this.body, this); + var answer, boundfunc, code, exprs, i, lit, p, param, params, ref, splats, uniqs, val, wasEmpty, wrapper, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _len5, _m, _n, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7; + if (this.bound && ((_ref2 = o.scope.method) != null ? _ref2.bound : void 0)) { + this.context = o.scope.method.context; + } + if (this.bound && !this.context) { + this.context = '_this'; + wrapper = new Code([new Param(new Literal(this.context))], new Block([this])); + boundfunc = new Call(wrapper, [new Literal('this')]); + boundfunc.updateLocationDataIfMissing(this.locationData); + return boundfunc.compileNode(o); + } + o.scope = del(o, 'classScope') || this.makeScope(o.scope); o.scope.shared = del(o, 'sharedScope'); o.indent += TAB; delete o.bare; delete o.isExistentialEquals; params = []; exprs = []; - this.eachParamName(function(name) { - if (!o.scope.check(name)) { - return o.scope.parameter(name); - } - }); + _ref3 = this.params; + for (_i = 0, _len = _ref3.length; _i < _len; _i++) { + param = _ref3[_i]; + o.scope.parameter(param.asReference(o)); + } _ref4 = this.params; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - param = _ref4[_i]; + for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) { + param = _ref4[_j]; if (!param.splat) { continue; } _ref5 = this.params; - for (_j = 0, _len1 = _ref5.length; _j < _len1; _j++) { - p = _ref5[_j].name; + for (_k = 0, _len2 = _ref5.length; _k < _len2; _k++) { + p = _ref5[_k].name; if (p["this"]) { p = p.properties[0].name; } @@ -1835,11 +1880,11 @@ define(function(require, exports, module) { } } splats = new Assign(new Value(new Arr((function() { - var _k, _len2, _ref6, _results; + var _l, _len3, _ref6, _results; _ref6 = this.params; _results = []; - for (_k = 0, _len2 = _ref6.length; _k < _len2; _k++) { - p = _ref6[_k]; + for (_l = 0, _len3 = _ref6.length; _l < _len3; _l++) { + p = _ref6[_l]; _results.push(p.asReference(o)); } return _results; @@ -1847,8 +1892,8 @@ define(function(require, exports, module) { break; } _ref6 = this.params; - for (_k = 0, _len2 = _ref6.length; _k < _len2; _k++) { - param = _ref6[_k]; + for (_l = 0, _len3 = _ref6.length; _l < _len3; _l++) { + param = _ref6[_l]; if (param.isComplex()) { val = ref = param.asReference(o); if (param.value) { @@ -1876,7 +1921,7 @@ define(function(require, exports, module) { if (exprs.length) { (_ref7 = this.body.expressions).unshift.apply(_ref7, exprs); } - for (i = _l = 0, _len3 = params.length; _l < _len3; i = ++_l) { + for (i = _m = 0, _len4 = params.length; _m < _len4; i = ++_m) { p = params[i]; params[i] = p.compileToFragments(o); o.scope.parameter(fragmentsToText(params[i])); @@ -1891,21 +1936,13 @@ define(function(require, exports, module) { if (!(wasEmpty || this.noReturn)) { this.body.makeReturn(); } - if (this.bound) { - if ((_ref8 = o.scope.parent.method) != null ? _ref8.bound : void 0) { - this.bound = this.context = o.scope.parent.method.context; - } else if (!this["static"]) { - o.scope.parent.assign('_this', 'this'); - } - } - idt = o.indent; code = 'function'; if (this.ctor) { code += ' ' + this.name; } code += '('; answer = [this.makeCode(code)]; - for (i = _m = 0, _len4 = params.length; _m < _len4; i = ++_m) { + for (i = _n = 0, _len5 = params.length; _n < _len5; i = ++_n) { p = params[i]; if (i) { answer.push(this.makeCode(", ")); @@ -1928,11 +1965,11 @@ define(function(require, exports, module) { }; Code.prototype.eachParamName = function(iterator) { - var param, _i, _len, _ref4, _results; - _ref4 = this.params; + var param, _i, _len, _ref2, _results; + _ref2 = this.params; _results = []; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - param = _ref4[_i]; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + param = _ref2[_i]; _results.push(param.eachName(iterator)); } return _results; @@ -1952,11 +1989,11 @@ define(function(require, exports, module) { __extends(Param, _super); function Param(name, value, splat) { - var _ref4; + var _ref2; this.name = name; this.value = value; this.splat = splat; - if (_ref4 = (name = this.name.unwrapAll().value), __indexOf.call(STRICT_PROSCRIBED, _ref4) >= 0) { + if (_ref2 = (name = this.name.unwrapAll().value), __indexOf.call(STRICT_PROSCRIBED, _ref2) >= 0) { this.name.error("parameter name \"" + name + "\" is not allowed"); } } @@ -1985,6 +2022,7 @@ define(function(require, exports, module) { if (this.splat) { node = new Splat(node); } + node.updateLocationDataIfMissing(this.locationData); return this.reference = node; }; @@ -1993,7 +2031,7 @@ define(function(require, exports, module) { }; Param.prototype.eachName = function(iterator, name) { - var atParam, node, obj, _i, _len, _ref4; + var atParam, node, obj, _i, _len, _ref2; if (name == null) { name = this.name; } @@ -2010,9 +2048,9 @@ define(function(require, exports, module) { if (name instanceof Value) { return atParam(name); } - _ref4 = name.objects; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - obj = _ref4[_i]; + _ref2 = name.objects; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + obj = _ref2[_i]; if (obj instanceof Assign) { this.eachName(iterator, obj.value.unwrap()); } else if (obj instanceof Splat) { @@ -2088,11 +2126,11 @@ define(function(require, exports, module) { return args[0].concat(node.makeCode(".concat("), concatPart, node.makeCode(")")); } base = (function() { - var _j, _len1, _ref4, _results; - _ref4 = list.slice(0, index); + var _j, _len1, _ref2, _results; + _ref2 = list.slice(0, index); _results = []; - for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) { - node = _ref4[_j]; + for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) { + node = _ref2[_j]; _results.push(node.compileToFragments(o, LEVEL_LIST)); } return _results; @@ -2135,17 +2173,17 @@ define(function(require, exports, module) { }; While.prototype.jumps = function() { - var expressions, node, _i, _len; + var expressions, jumpNode, node, _i, _len; expressions = this.body.expressions; if (!expressions.length) { return false; } for (_i = 0, _len = expressions.length; _i < _len; _i++) { node = expressions[_i]; - if (node.jumps({ + if (jumpNode = node.jumps({ loop: true })) { - return node; + return jumpNode; } } return false; @@ -2232,17 +2270,17 @@ define(function(require, exports, module) { }; Op.prototype.isComplex = function() { - var _ref4; - return !(this.isUnary() && ((_ref4 = this.operator) === '+' || _ref4 === '-')) || this.first.isComplex(); + var _ref2; + return !(this.isUnary() && ((_ref2 = this.operator) === '+' || _ref2 === '-')) || this.first.isComplex(); }; Op.prototype.isChainable = function() { - var _ref4; - return (_ref4 = this.operator) === '<' || _ref4 === '>' || _ref4 === '>=' || _ref4 === '<=' || _ref4 === '===' || _ref4 === '!=='; + var _ref2; + return (_ref2 = this.operator) === '<' || _ref2 === '>' || _ref2 === '>=' || _ref2 === '<=' || _ref2 === '===' || _ref2 === '!=='; }; Op.prototype.invert = function() { - var allInvertable, curr, fst, op, _ref4; + var allInvertable, curr, fst, op, _ref2; if (this.isChainable() && this.first.isChainable()) { allInvertable = true; curr = this; @@ -2268,7 +2306,7 @@ define(function(require, exports, module) { return this; } else if (this.second) { return new Parens(this).invert(); - } else if (this.operator === '!' && (fst = this.first.unwrap()) instanceof Op && ((_ref4 = fst.operator) === '!' || _ref4 === 'in' || _ref4 === 'instanceof')) { + } else if (this.operator === '!' && (fst = this.first.unwrap()) instanceof Op && ((_ref2 = fst.operator) === '!' || _ref2 === 'in' || _ref2 === 'instanceof')) { return fst; } else { return new Op('!', this); @@ -2276,17 +2314,17 @@ define(function(require, exports, module) { }; Op.prototype.unfoldSoak = function(o) { - var _ref4; - return ((_ref4 = this.operator) === '++' || _ref4 === '--' || _ref4 === 'delete') && unfoldSoak(o, this, 'first'); + var _ref2; + return ((_ref2 = this.operator) === '++' || _ref2 === '--' || _ref2 === 'delete') && unfoldSoak(o, this, 'first'); }; Op.prototype.generateDo = function(exp) { - var call, func, param, passedParams, ref, _i, _len, _ref4; + var call, func, param, passedParams, ref, _i, _len, _ref2; passedParams = []; func = exp instanceof Assign && (ref = exp.value.unwrap()) instanceof Code ? ref : exp; - _ref4 = func.params || []; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - param = _ref4[_i]; + _ref2 = func.params || []; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + param = _ref2[_i]; if (param.value) { passedParams.push(param.value); delete param.value; @@ -2300,7 +2338,7 @@ define(function(require, exports, module) { }; Op.prototype.compileNode = function(o) { - var answer, isChain, _ref4, _ref5; + var answer, isChain, _ref2, _ref3; isChain = this.isChainable() && this.first.isChainable(); if (!isChain) { this.first.front = this.front; @@ -2308,7 +2346,7 @@ define(function(require, exports, module) { if (this.operator === 'delete' && o.scope.check(this.first.unwrapAll().value)) { this.error('delete operand may not be argument or var'); } - if (((_ref4 = this.operator) === '--' || _ref4 === '++') && (_ref5 = this.first.unwrapAll().value, __indexOf.call(STRICT_PROSCRIBED, _ref5) >= 0)) { + if (((_ref2 = this.operator) === '--' || _ref2 === '++') && (_ref3 = this.first.unwrapAll().value, __indexOf.call(STRICT_PROSCRIBED, _ref3) >= 0)) { this.error("cannot increment/decrement \"" + (this.first.unwrapAll().value) + "\""); } if (this.isUnary()) { @@ -2329,8 +2367,8 @@ define(function(require, exports, module) { }; Op.prototype.compileChain = function(o) { - var fragments, fst, shared, _ref4; - _ref4 = this.first.second.cache(o), this.first.second = _ref4[0], shared = _ref4[1]; + var fragments, fst, shared, _ref2; + _ref2 = this.first.second.cache(o), this.first.second = _ref2[0], shared = _ref2[1]; fst = this.first.compileToFragments(o, LEVEL_OP); fragments = fst.concat(this.makeCode(" " + (this.invert ? '&&' : '||') + " "), shared.compileToFragments(o), this.makeCode(" " + this.operator + " "), this.second.compileToFragments(o, LEVEL_OP)); return this.wrapInBraces(fragments); @@ -2338,7 +2376,7 @@ define(function(require, exports, module) { Op.prototype.compileExistence = function(o) { var fst, ref; - if (!o.isExistentialEquals && this.first.isComplex()) { + if (this.first.isComplex()) { ref = new Literal(o.scope.freeVariable('ref')); fst = new Parens(new Assign(ref, this.first)); } else { @@ -2397,11 +2435,11 @@ define(function(require, exports, module) { In.prototype.invert = NEGATE; In.prototype.compileNode = function(o) { - var hasSplat, obj, _i, _len, _ref4; + var hasSplat, obj, _i, _len, _ref2; if (this.array instanceof Value && this.array.isArray()) { - _ref4 = this.array.base.objects; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - obj = _ref4[_i]; + _ref2 = this.array.base.objects; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + obj = _ref2[_i]; if (!(obj instanceof Splat)) { continue; } @@ -2416,16 +2454,16 @@ define(function(require, exports, module) { }; In.prototype.compileOrTest = function(o) { - var cmp, cnj, i, item, ref, sub, tests, _i, _len, _ref4, _ref5, _ref6; + var cmp, cnj, i, item, ref, sub, tests, _i, _len, _ref2, _ref3, _ref4; if (this.array.base.objects.length === 0) { return [this.makeCode("" + (!!this.negated))]; } - _ref4 = this.object.cache(o, LEVEL_OP), sub = _ref4[0], ref = _ref4[1]; - _ref5 = this.negated ? [' !== ', ' && '] : [' === ', ' || '], cmp = _ref5[0], cnj = _ref5[1]; + _ref2 = this.object.cache(o, LEVEL_OP), sub = _ref2[0], ref = _ref2[1]; + _ref3 = this.negated ? [' !== ', ' && '] : [' === ', ' || '], cmp = _ref3[0], cnj = _ref3[1]; tests = []; - _ref6 = this.array.base.objects; - for (i = _i = 0, _len = _ref6.length; _i < _len; i = ++_i) { - item = _ref6[i]; + _ref4 = this.array.base.objects; + for (i = _i = 0, _len = _ref4.length; _i < _len; i = ++_i) { + item = _ref4[i]; if (i) { tests.push(this.makeCode(cnj)); } @@ -2439,8 +2477,8 @@ define(function(require, exports, module) { }; In.prototype.compileLoopTest = function(o) { - var fragments, ref, sub, _ref4; - _ref4 = this.object.cache(o, LEVEL_LIST), sub = _ref4[0], ref = _ref4[1]; + var fragments, ref, sub, _ref2; + _ref2 = this.object.cache(o, LEVEL_LIST), sub = _ref2[0], ref = _ref2[1]; fragments = [].concat(this.makeCode(utility('indexOf') + ".call("), this.array.compileToFragments(o, LEVEL_LIST), this.makeCode(", "), ref, this.makeCode(") " + (this.negated ? '< 0' : '>= 0'))); if (fragmentsToText(sub) === fragmentsToText(ref)) { return fragments; @@ -2476,8 +2514,8 @@ define(function(require, exports, module) { Try.prototype.isStatement = YES; Try.prototype.jumps = function(o) { - var _ref4; - return this.attempt.jumps(o) || ((_ref4 = this.recovery) != null ? _ref4.jumps(o) : void 0); + var _ref2; + return this.attempt.jumps(o) || ((_ref2 = this.recovery) != null ? _ref2.jumps(o) : void 0); }; Try.prototype.makeReturn = function(res) { @@ -2538,11 +2576,11 @@ define(function(require, exports, module) { Existence.prototype.invert = NEGATE; Existence.prototype.compileNode = function(o) { - var cmp, cnj, code, _ref4; + var cmp, cnj, code, _ref2; this.expression.front = this.front; code = this.expression.compile(o, LEVEL_OP); if (IDENTIFIER.test(code) && !o.scope.check(code)) { - _ref4 = this.negated ? ['===', '||'] : ['!==', '&&'], cmp = _ref4[0], cnj = _ref4[1]; + _ref2 = this.negated ? ['===', '||'] : ['!==', '&&'], cmp = _ref2[0], cnj = _ref2[1]; code = "typeof " + code + " " + cmp + " \"undefined\" " + cnj + " " + code + " " + cmp + " null"; } else { code = "" + code + " " + (this.negated ? '==' : '!=') + " null"; @@ -2595,13 +2633,13 @@ define(function(require, exports, module) { __extends(For, _super); function For(body, source) { - var _ref4; + var _ref2; this.source = source.source, this.guard = source.guard, this.step = source.step, this.name = source.name, this.index = source.index; this.body = Block.wrap([body]); this.own = !!source.own; this.object = !!source.object; if (this.object) { - _ref4 = [this.index, this.name], this.name = _ref4[0], this.index = _ref4[1]; + _ref2 = [this.index, this.name], this.name = _ref2[0], this.index = _ref2[1]; } if (this.index instanceof Value) { this.index.error('index cannot be a pattern matching expression'); @@ -2615,7 +2653,7 @@ define(function(require, exports, module) { this.name.error('cannot pattern match over range loops'); } if (this.own && !this.object) { - this.index.error('cannot use own with for-in'); + this.name.error('cannot use own with for-in'); } this.returns = false; } @@ -2623,9 +2661,9 @@ define(function(require, exports, module) { For.prototype.children = ['body', 'source', 'guard', 'step']; For.prototype.compileNode = function(o) { - var body, bodyFragments, compare, compareDown, declare, declareDown, defPart, defPartFragments, down, forPartFragments, guardPart, idt1, increment, index, ivar, kvar, kvarAssign, lastJumps, lvar, name, namePart, ref, resultPart, returnResult, rvar, scope, source, step, stepNum, stepVar, svar, varPart, _ref4, _ref5; + var body, bodyFragments, compare, compareDown, declare, declareDown, defPart, defPartFragments, down, forPartFragments, guardPart, idt1, increment, index, ivar, kvar, kvarAssign, lastJumps, lvar, name, namePart, ref, resultPart, returnResult, rvar, scope, source, step, stepNum, stepVar, svar, varPart, _ref2, _ref3; body = Block.wrap([this.body]); - lastJumps = (_ref4 = last(body.expressions)) != null ? _ref4.jumps() : void 0; + lastJumps = (_ref2 = last(body.expressions)) != null ? _ref2.jumps() : void 0; if (lastJumps && lastJumps instanceof Return) { this.returns = false; } @@ -2646,8 +2684,8 @@ define(function(require, exports, module) { kvar = (this.range && name) || index || ivar; kvarAssign = kvar !== ivar ? "" + kvar + " = " : ""; if (this.step && !this.range) { - _ref5 = this.cacheToCodeFragments(this.step.cache(o, LEVEL_LIST)), step = _ref5[0], stepVar = _ref5[1]; - stepNum = stepVar.match(SIMPLENUM); + _ref3 = this.cacheToCodeFragments(this.step.cache(o, LEVEL_LIST)), step = _ref3[0], stepVar = _ref3[1]; + stepNum = stepVar.match(NUMBER); } if (this.pattern) { name = ivar; @@ -2675,7 +2713,7 @@ define(function(require, exports, module) { if (step !== stepVar) { defPart += "" + this.tab + step + ";\n"; } - if (!(this.step && stepNum && (down = +stepNum < 0))) { + if (!(this.step && stepNum && (down = parseNum(stepNum[0]) < 0))) { lvar = scope.freeVariable('len'); } declare = "" + kvarAssign + ivar + " = 0, " + lvar + " = " + svar + ".length"; @@ -2736,24 +2774,24 @@ define(function(require, exports, module) { }; For.prototype.pluckDirectCall = function(o, body) { - var base, defs, expr, fn, idx, ref, val, _i, _len, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9; + var base, defs, expr, fn, idx, ref, val, _i, _len, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8; defs = []; - _ref4 = body.expressions; - for (idx = _i = 0, _len = _ref4.length; _i < _len; idx = ++_i) { - expr = _ref4[idx]; + _ref2 = body.expressions; + for (idx = _i = 0, _len = _ref2.length; _i < _len; idx = ++_i) { + expr = _ref2[idx]; expr = expr.unwrapAll(); if (!(expr instanceof Call)) { continue; } - val = expr.variable.unwrapAll(); - if (!((val instanceof Code) || (val instanceof Value && ((_ref5 = val.base) != null ? _ref5.unwrapAll() : void 0) instanceof Code && val.properties.length === 1 && ((_ref6 = (_ref7 = val.properties[0].name) != null ? _ref7.value : void 0) === 'call' || _ref6 === 'apply')))) { + val = (_ref3 = expr.variable) != null ? _ref3.unwrapAll() : void 0; + if (!((val instanceof Code) || (val instanceof Value && ((_ref4 = val.base) != null ? _ref4.unwrapAll() : void 0) instanceof Code && val.properties.length === 1 && ((_ref5 = (_ref6 = val.properties[0].name) != null ? _ref6.value : void 0) === 'call' || _ref5 === 'apply')))) { continue; } - fn = ((_ref8 = val.base) != null ? _ref8.unwrapAll() : void 0) || val; + fn = ((_ref7 = val.base) != null ? _ref7.unwrapAll() : void 0) || val; ref = new Literal(o.scope.freeVariable('fn')); base = new Value(ref); if (val.base) { - _ref9 = [base, val], val.base = _ref9[0], base = _ref9[1]; + _ref8 = [base, val], val.base = _ref8[0], base = _ref8[1]; } body.expressions[idx] = new Call(base, expr.args); defs = defs.concat(this.makeCode(this.tab), new Assign(ref, fn).compileToFragments(o, LEVEL_TOP), this.makeCode(';\n')); @@ -2779,49 +2817,49 @@ define(function(require, exports, module) { Switch.prototype.isStatement = YES; Switch.prototype.jumps = function(o) { - var block, conds, _i, _len, _ref4, _ref5, _ref6; + var block, conds, jumpNode, _i, _len, _ref2, _ref3, _ref4; if (o == null) { o = { block: true }; } - _ref4 = this.cases; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - _ref5 = _ref4[_i], conds = _ref5[0], block = _ref5[1]; - if (block.jumps(o)) { - return block; + _ref2 = this.cases; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + _ref3 = _ref2[_i], conds = _ref3[0], block = _ref3[1]; + if (jumpNode = block.jumps(o)) { + return jumpNode; } } - return (_ref6 = this.otherwise) != null ? _ref6.jumps(o) : void 0; + return (_ref4 = this.otherwise) != null ? _ref4.jumps(o) : void 0; }; Switch.prototype.makeReturn = function(res) { - var pair, _i, _len, _ref4, _ref5; - _ref4 = this.cases; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - pair = _ref4[_i]; + var pair, _i, _len, _ref2, _ref3; + _ref2 = this.cases; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + pair = _ref2[_i]; pair[1].makeReturn(res); } if (res) { this.otherwise || (this.otherwise = new Block([new Literal('void 0')])); } - if ((_ref5 = this.otherwise) != null) { - _ref5.makeReturn(res); + if ((_ref3 = this.otherwise) != null) { + _ref3.makeReturn(res); } return this; }; Switch.prototype.compileNode = function(o) { - var block, body, cond, conditions, expr, fragments, i, idt1, idt2, _i, _j, _len, _len1, _ref4, _ref5, _ref6; + var block, body, cond, conditions, expr, fragments, i, idt1, idt2, _i, _j, _len, _len1, _ref2, _ref3, _ref4; idt1 = o.indent + TAB; idt2 = o.indent = idt1 + TAB; fragments = [].concat(this.makeCode(this.tab + "switch ("), (this.subject ? this.subject.compileToFragments(o, LEVEL_PAREN) : this.makeCode("false")), this.makeCode(") {\n")); - _ref4 = this.cases; - for (i = _i = 0, _len = _ref4.length; _i < _len; i = ++_i) { - _ref5 = _ref4[i], conditions = _ref5[0], block = _ref5[1]; - _ref6 = flatten([conditions]); - for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) { - cond = _ref6[_j]; + _ref2 = this.cases; + for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) { + _ref3 = _ref2[i], conditions = _ref3[0], block = _ref3[1]; + _ref4 = flatten([conditions]); + for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) { + cond = _ref4[_j]; if (!this.subject) { cond = cond.invert(); } @@ -2867,13 +2905,13 @@ define(function(require, exports, module) { If.prototype.children = ['condition', 'body', 'elseBody']; If.prototype.bodyNode = function() { - var _ref4; - return (_ref4 = this.body) != null ? _ref4.unwrap() : void 0; + var _ref2; + return (_ref2 = this.body) != null ? _ref2.unwrap() : void 0; }; If.prototype.elseBodyNode = function() { - var _ref4; - return (_ref4 = this.elseBody) != null ? _ref4.unwrap() : void 0; + var _ref2; + return (_ref2 = this.elseBody) != null ? _ref2.unwrap() : void 0; }; If.prototype.addElse = function(elseBody) { @@ -2888,13 +2926,13 @@ define(function(require, exports, module) { }; If.prototype.isStatement = function(o) { - var _ref4; - return (o != null ? o.level : void 0) === LEVEL_TOP || this.bodyNode().isStatement(o) || ((_ref4 = this.elseBodyNode()) != null ? _ref4.isStatement(o) : void 0); + var _ref2; + return (o != null ? o.level : void 0) === LEVEL_TOP || this.bodyNode().isStatement(o) || ((_ref2 = this.elseBodyNode()) != null ? _ref2.isStatement(o) : void 0); }; If.prototype.jumps = function(o) { - var _ref4; - return this.body.jumps(o) || ((_ref4 = this.elseBody) != null ? _ref4.jumps(o) : void 0); + var _ref2; + return this.body.jumps(o) || ((_ref2 = this.elseBody) != null ? _ref2.jumps(o) : void 0); }; If.prototype.compileNode = function(o) { @@ -2976,52 +3014,6 @@ define(function(require, exports, module) { })(Base); - Closure = { - wrap: function(expressions, statement, noReturn) { - var args, argumentsNode, call, func, meth; - if (expressions.jumps()) { - return expressions; - } - func = new Code([], Block.wrap([expressions])); - args = []; - argumentsNode = expressions.contains(this.isLiteralArguments); - if (argumentsNode && expressions.classBody) { - argumentsNode.error("Class bodies shouldn't reference arguments"); - } - if (argumentsNode || expressions.contains(this.isLiteralThis)) { - meth = new Literal(argumentsNode ? 'apply' : 'call'); - args = [new Literal('this')]; - if (argumentsNode) { - args.push(new Literal('arguments')); - } - func = new Value(func, [new Access(meth)]); - } - func.noReturn = noReturn; - call = new Call(func, args); - if (statement) { - return Block.wrap([call]); - } else { - return call; - } - }, - isLiteralArguments: function(node) { - return node instanceof Literal && node.value === 'arguments' && !node.asKey; - }, - isLiteralThis: function(node) { - return (node instanceof Literal && node.value === 'this' && !node.asKey) || (node instanceof Code && node.bound) || (node instanceof Call && node.isSuper); - } - }; - - unfoldSoak = function(o, parent, name) { - var ifn; - if (!(ifn = parent[name].unfoldSoak(o))) { - return; - } - parent[name] = ifn.body; - ifn.body = new Value(parent); - return ifn; - }; - UTILITIES = { "extends": function() { return "function(child, parent) { for (var key in parent) { if (" + (utility('hasProp')) + ".call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }"; @@ -3060,10 +3052,16 @@ define(function(require, exports, module) { SIMPLENUM = /^[+-]?\d+$/; - METHOD_DEF = RegExp("^(?:(" + IDENTIFIER_STR + ")\\.prototype(?:\\.(" + IDENTIFIER_STR + ")|\\[(\"(?:[^\\\\\"\\r\\n]|\\\\.)*\"|'(?:[^\\\\'\\r\\n]|\\\\.)*')\\]|\\[(0x[\\da-fA-F]+|\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\]))|(" + IDENTIFIER_STR + ")$"); + HEXNUM = /^[+-]?0x[\da-f]+/i; + + NUMBER = /^[+-]?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)$/i; + + METHOD_DEF = RegExp("^(" + IDENTIFIER_STR + ")(\\.prototype)?(?:\\.(" + IDENTIFIER_STR + ")|\\[(\"(?:[^\\\\\"\\r\\n]|\\\\.)*\"|'(?:[^\\\\'\\r\\n]|\\\\.)*')\\]|\\[(0x[\\da-fA-F]+|\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\])$"); IS_STRING = /^['"]/; + IS_REGEX = /^\//; + utility = function(name) { var ref; ref = "__" + name; @@ -3076,5 +3074,33 @@ define(function(require, exports, module) { return code.replace(/\s+$/, ''); }; + parseNum = function(x) { + if (x == null) { + return 0; + } else if (x.match(HEXNUM)) { + return parseInt(x, 16); + } else { + return parseFloat(x); + } + }; + + isLiteralArguments = function(node) { + return node instanceof Literal && node.value === 'arguments' && !node.asKey; + }; + + isLiteralThis = function(node) { + return (node instanceof Literal && node.value === 'this' && !node.asKey) || (node instanceof Code && node.bound) || (node instanceof Call && node.isSuper); + }; + + unfoldSoak = function(o, parent, name) { + var ifn; + if (!(ifn = parent[name].unfoldSoak(o))) { + return; + } + parent[name] = ifn.body; + ifn.body = new Value(parent); + return ifn; + }; + }); \ No newline at end of file diff --git a/lib/ace/mode/coffee/rewriter.js b/lib/ace/mode/coffee/rewriter.js index 009d17d0..acb5c420 100644 --- a/lib/ace/mode/coffee/rewriter.js +++ b/lib/ace/mode/coffee/rewriter.js @@ -27,7 +27,7 @@ define(function(require, exports, module) { // Generated by CoffeeScript 1.6.3 - var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, left, rite, _i, _len, _ref, + var BALANCED_PAIRS, CALL_CLOSERS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, left, rite, _i, _len, _ref, __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, __slice = [].slice; @@ -44,10 +44,9 @@ define(function(require, exports, module) { Rewriter.prototype.rewrite = function(tokens) { this.tokens = tokens; this.removeLeadingNewlines(); - this.removeMidExpressionNewlines(); this.closeOpenCalls(); this.closeOpenIndexes(); - this.addImplicitIndentation(); + this.normalizeLines(); this.tagPostfixConditionals(); this.addImplicitBracesAndParens(); this.addLocationDataToGeneratedTokens(); @@ -99,17 +98,6 @@ define(function(require, exports, module) { } }; - Rewriter.prototype.removeMidExpressionNewlines = function() { - return this.scanTokens(function(token, i, tokens) { - var _ref; - if (!(token[0] === 'TERMINATOR' && (_ref = this.tag(i + 1), __indexOf.call(EXPRESSION_CLOSE, _ref) >= 0))) { - return 1; - } - tokens.splice(i, 1); - return 0; - }); - }; - Rewriter.prototype.closeOpenCalls = function() { var action, condition; condition = function(token, i) { @@ -188,9 +176,9 @@ define(function(require, exports, module) { var stack; stack = []; return this.scanTokens(function(token, i, tokens) { - var endImplicitCall, endImplicitObject, forward, inImplicit, inImplicitCall, inImplicitControl, inImplicitObject, nextTag, offset, prevTag, s, sameLine, stackIdx, stackTag, stackTop, startIdx, startImplicitCall, startImplicitObject, startsLine, tag, _ref, _ref1, _ref2, _ref3, _ref4, _ref5; + var endAllImplicitCalls, endImplicitCall, endImplicitObject, forward, inImplicit, inImplicitCall, inImplicitControl, inImplicitObject, nextTag, offset, prevTag, prevToken, s, sameLine, stackIdx, stackTag, stackTop, startIdx, startImplicitCall, startImplicitObject, startsLine, tag, _ref, _ref1, _ref2, _ref3, _ref4, _ref5; tag = token[0]; - prevTag = (i > 0 ? tokens[i - 1] : [])[0]; + prevTag = (prevToken = i > 0 ? tokens[i - 1] : [])[0]; nextTag = (i < tokens.length - 1 ? tokens[i + 1] : [])[0]; stackTop = function() { return stack[stack.length - 1]; @@ -233,6 +221,11 @@ define(function(require, exports, module) { tokens.splice(i, 0, generate('CALL_END', ')')); return i += 1; }; + endAllImplicitCalls = function() { + while (inImplicitCall()) { + endImplicitCall(); + } + }; startImplicitObject = function(j, startsLine) { var idx; if (startsLine == null) { @@ -324,9 +317,15 @@ define(function(require, exports, module) { startImplicitObject(s, !!startsLine); return forward(2); } - if (prevTag === 'OUTDENT' && inImplicitCall() && (tag === '.' || tag === '?.' || tag === '::' || tag === '?::')) { - endImplicitCall(); - return forward(1); + if (inImplicitCall() && __indexOf.call(CALL_CLOSERS, tag) >= 0) { + if (prevTag === 'OUTDENT') { + endImplicitCall(); + return forward(1); + } + if (prevToken.newLine) { + endAllImplicitCalls(); + return forward(1); + } } if (inImplicitObject() && __indexOf.call(LINEBREAKS, tag) >= 0) { stackTop()[2].sameLine = false; @@ -381,30 +380,32 @@ define(function(require, exports, module) { }); }; - Rewriter.prototype.addImplicitIndentation = function() { + Rewriter.prototype.normalizeLines = function() { var action, condition, indent, outdent, starter; starter = indent = outdent = null; condition = function(token, i) { - var _ref, _ref1; - return token[1] !== ';' && (_ref = token[0], __indexOf.call(SINGLE_CLOSERS, _ref) >= 0) && !(token[0] === 'ELSE' && starter !== 'THEN') && !(((_ref1 = token[0]) === 'CATCH' || _ref1 === 'FINALLY') && (starter === '->' || starter === '=>')); + var _ref, _ref1, _ref2, _ref3; + return token[1] !== ';' && (_ref = token[0], __indexOf.call(SINGLE_CLOSERS, _ref) >= 0) && !(token[0] === 'TERMINATOR' && (_ref1 = this.tag(i + 1), __indexOf.call(EXPRESSION_CLOSE, _ref1) >= 0)) && !(token[0] === 'ELSE' && starter !== 'THEN') && !(((_ref2 = token[0]) === 'CATCH' || _ref2 === 'FINALLY') && (starter === '->' || starter === '=>')) || (_ref3 = token[0], __indexOf.call(CALL_CLOSERS, _ref3) >= 0) && this.tokens[i - 1].newLine; }; action = function(token, i) { return this.tokens.splice((this.tag(i - 1) === ',' ? i - 1 : i), 0, outdent); }; return this.scanTokens(function(token, i, tokens) { - var j, tag, _i, _ref, _ref1; + var j, tag, _i, _ref, _ref1, _ref2; tag = token[0]; - if (tag === 'TERMINATOR' && this.tag(i + 1) === 'THEN') { - tokens.splice(i, 1); - return 0; - } - if (tag === 'ELSE' && this.tag(i - 1) !== 'OUTDENT') { - tokens.splice.apply(tokens, [i, 0].concat(__slice.call(this.indentation()))); - return 2; + if (tag === 'TERMINATOR') { + if (this.tag(i + 1) === 'ELSE' && this.tag(i - 1) !== 'OUTDENT') { + tokens.splice.apply(tokens, [i, 1].concat(__slice.call(this.indentation()))); + return 1; + } + if (_ref = this.tag(i + 1), __indexOf.call(EXPRESSION_CLOSE, _ref) >= 0) { + tokens.splice(i, 1); + return 0; + } } if (tag === 'CATCH') { for (j = _i = 1; _i <= 2; j = ++_i) { - if (!((_ref = this.tag(i + j)) === 'OUTDENT' || _ref === 'TERMINATOR' || _ref === 'FINALLY')) { + if (!((_ref1 = this.tag(i + j)) === 'OUTDENT' || _ref1 === 'TERMINATOR' || _ref1 === 'FINALLY')) { continue; } tokens.splice.apply(tokens, [i + j, 0].concat(__slice.call(this.indentation()))); @@ -413,7 +414,7 @@ define(function(require, exports, module) { } if (__indexOf.call(SINGLE_LINERS, tag) >= 0 && this.tag(i + 1) !== 'INDENT' && !(tag === 'ELSE' && this.tag(i + 1) === 'IF')) { starter = tag; - _ref1 = this.indentation(true), indent = _ref1[0], outdent = _ref1[1]; + _ref2 = this.indentation(true), indent = _ref2[0], outdent = _ref2[1]; if (starter === 'THEN') { indent.fromThen = true; } @@ -493,7 +494,7 @@ define(function(require, exports, module) { EXPRESSION_END.push(INVERSES[left] = rite); } - EXPRESSION_CLOSE = ['CATCH', 'WHEN', 'ELSE', 'FINALLY'].concat(EXPRESSION_END); + EXPRESSION_CLOSE = ['CATCH', 'THEN', 'ELSE', 'FINALLY'].concat(EXPRESSION_END); IMPLICIT_FUNC = ['IDENTIFIER', 'SUPER', ')', 'CALL_END', ']', 'INDEX_END', '@', 'THIS']; @@ -509,5 +510,7 @@ define(function(require, exports, module) { LINEBREAKS = ['TERMINATOR', 'INDENT', 'OUTDENT']; + CALL_CLOSERS = ['.', '?.', '::', '?::']; + }); \ No newline at end of file diff --git a/lib/ace/mode/css/csslint.js b/lib/ace/mode/css/csslint.js index 9f4c3bc8..078c71b1 100644 --- a/lib/ace/mode/css/csslint.js +++ b/lib/ace/mode/css/csslint.js @@ -1,7 +1,7 @@ define(function(require, exports, module) { /*! CSSLint -Copyright (c) 2011 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. +Copyright (c) 2013 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* Build time: 17-January-2013 10:55:01 */ +/* Build: v0.10.0 15-August-2013 01:07:22 */ /*! Parser-Lib Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved. @@ -46,7 +46,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* Version v0.2.2, Build time: 17-January-2013 10:26:34 */ +/* Version v0.2.3, Build time: 19-June-2013 11:16:15 */ var parserlib = {}; (function(){ @@ -956,7 +956,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* Version v0.2.2, Build time: 17-January-2013 10:26:34 */ +/* Version v0.2.3, Build time: 19-June-2013 11:16:15 */ (function(){ var EventTarget = parserlib.util.EventTarget, TokenStreamBase = parserlib.util.TokenStreamBase, @@ -1296,10 +1296,10 @@ Parser.prototype = function(){ var proto = new EventTarget(), //new prototype prop, additions = { - + //restore constructor constructor: Parser, - + //instance constants - yuck DEFAULT_TYPE : 0, COMBINATOR_TYPE : 1, @@ -1310,14 +1310,14 @@ Parser.prototype = function(){ PROPERTY_VALUE_PART_TYPE : 6, SELECTOR_TYPE : 7, SELECTOR_PART_TYPE : 8, - SELECTOR_SUB_PART_TYPE : 9, - + SELECTOR_SUB_PART_TYPE : 9, + //----------------------------------------------------------------- // Grammar //----------------------------------------------------------------- - + _stylesheet: function(){ - + /* * stylesheet * : [ CHARSET_SYM S* STRING S* ';' ]? @@ -1325,19 +1325,19 @@ Parser.prototype = function(){ * [ namespace [S|CDO|CDC]* ]* * [ [ ruleset | media | page | font_face | keyframes ] [S|CDO|CDC]* ]* * ; - */ - + */ + var tokenStream = this._tokenStream, charset = null, count, token, tt; - + this.fire("startstylesheet"); - + //try to read character set this._charset(); - + this._skipCruft(); //try to read imports - may be more than one @@ -1345,42 +1345,46 @@ Parser.prototype = function(){ this._import(); this._skipCruft(); } - + //try to read namespaces - may be more than one while (tokenStream.peek() == Tokens.NAMESPACE_SYM){ this._namespace(); this._skipCruft(); } - + //get the next token tt = tokenStream.peek(); - + //try to read the rest while(tt > Tokens.EOF){ - + try { - + switch(tt){ case Tokens.MEDIA_SYM: this._media(); this._skipCruft(); break; case Tokens.PAGE_SYM: - this._page(); + this._page(); this._skipCruft(); - break; + break; case Tokens.FONT_FACE_SYM: - this._font_face(); + this._font_face(); this._skipCruft(); - break; + break; case Tokens.KEYFRAMES_SYM: - this._keyframes(); + this._keyframes(); this._skipCruft(); - break; + break; + case Tokens.VIEWPORT_SYM: + this._viewport(); + this._skipCruft(); + break; case Tokens.UNKNOWN_SYM: //unknown @ rule tokenStream.get(); if (!this.options.strict){ - + //fire error event this.fire({ type: "error", @@ -1388,30 +1392,30 @@ Parser.prototype = function(){ message: "Unknown @ rule: " + tokenStream.LT(0).value + ".", line: tokenStream.LT(0).startLine, col: tokenStream.LT(0).startCol - }); - + }); + //skip braces count=0; while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) == Tokens.LBRACE){ count++; //keep track of nesting depth } - + while(count){ tokenStream.advance([Tokens.RBRACE]); count--; } - + } else { //not a syntax error, rethrow it throw new SyntaxError("Unknown @ rule.", tokenStream.LT(0).startLine, tokenStream.LT(0).startCol); - } + } break; case Tokens.S: this._readWhitespace(); break; - default: + default: if(!this._ruleset()){ - + //error handling for known issues switch(tt){ case Tokens.CHARSET_SYM: @@ -1430,7 +1434,7 @@ Parser.prototype = function(){ tokenStream.get(); //get the last token this._unexpectedToken(tokenStream.token()); } - + } } } catch(ex) { @@ -1441,84 +1445,84 @@ Parser.prototype = function(){ message: ex.message, line: ex.line, col: ex.col - }); + }); } else { throw ex; } } - + tt = tokenStream.peek(); } - + if (tt != Tokens.EOF){ this._unexpectedToken(tokenStream.token()); } - + this.fire("endstylesheet"); }, - + _charset: function(emit){ var tokenStream = this._tokenStream, charset, token, line, col; - + if (tokenStream.match(Tokens.CHARSET_SYM)){ line = tokenStream.token().startLine; col = tokenStream.token().startCol; - + this._readWhitespace(); tokenStream.mustMatch(Tokens.STRING); - + token = tokenStream.token(); charset = token.value; - + this._readWhitespace(); tokenStream.mustMatch(Tokens.SEMICOLON); - + if (emit !== false){ - this.fire({ + this.fire({ type: "charset", charset:charset, line: line, col: col }); } - } + } }, - + _import: function(emit){ /* * import * : IMPORT_SYM S* * [STRING|URI] S* media_query_list? ';' S* - */ - + */ + var tokenStream = this._tokenStream, tt, uri, importToken, mediaList = []; - + //read import symbol tokenStream.mustMatch(Tokens.IMPORT_SYM); importToken = tokenStream.token(); this._readWhitespace(); - + tokenStream.mustMatch([Tokens.STRING, Tokens.URI]); - + //grab the URI value - uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1"); + uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1"); this._readWhitespace(); - + mediaList = this._media_query_list(); - + //must end with a semicolon tokenStream.mustMatch(Tokens.SEMICOLON); this._readWhitespace(); - + if (emit !== false){ this.fire({ type: "import", @@ -1528,47 +1532,47 @@ Parser.prototype = function(){ col: importToken.startCol }); } - + }, - + _namespace: function(emit){ /* * namespace * : NAMESPACE_SYM S* [namespace_prefix S*]? [STRING|URI] S* ';' S* - */ - + */ + var tokenStream = this._tokenStream, line, col, prefix, uri; - + //read import symbol tokenStream.mustMatch(Tokens.NAMESPACE_SYM); line = tokenStream.token().startLine; col = tokenStream.token().startCol; this._readWhitespace(); - + //it's a namespace prefix - no _namespace_prefix() method because it's just an IDENT if (tokenStream.match(Tokens.IDENT)){ prefix = tokenStream.token().value; this._readWhitespace(); } - + tokenStream.mustMatch([Tokens.STRING, Tokens.URI]); /*if (!tokenStream.match(Tokens.STRING)){ tokenStream.mustMatch(Tokens.URI); }*/ - + //grab the URI value - uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1"); + uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1"); this._readWhitespace(); //must end with a semicolon tokenStream.mustMatch(Tokens.SEMICOLON); this._readWhitespace(); - + if (emit !== false){ this.fire({ type: "namespace", @@ -1578,9 +1582,9 @@ Parser.prototype = function(){ col: col }); } - - }, - + + }, + _media: function(){ /* * media @@ -1591,45 +1595,47 @@ Parser.prototype = function(){ line, col, mediaList;// = []; - + //look for @media tokenStream.mustMatch(Tokens.MEDIA_SYM); line = tokenStream.token().startLine; col = tokenStream.token().startCol; - - this._readWhitespace(); + + this._readWhitespace(); mediaList = this._media_query_list(); tokenStream.mustMatch(Tokens.LBRACE); this._readWhitespace(); - + this.fire({ type: "startmedia", media: mediaList, line: line, col: col }); - + while(true) { if (tokenStream.peek() == Tokens.PAGE_SYM){ this._page(); + } else if (tokenStream.peek() == Tokens.FONT_FACE_SYM){ + this._font_face(); } else if (!this._ruleset()){ break; - } + } } - + tokenStream.mustMatch(Tokens.RBRACE); this._readWhitespace(); - + this.fire({ type: "endmedia", media: mediaList, line: line, col: col }); - }, - + }, + //CSS3 Media Queries _media_query_list: function(){ @@ -1640,26 +1646,26 @@ Parser.prototype = function(){ */ var tokenStream = this._tokenStream, mediaList = []; - - + + this._readWhitespace(); - + if (tokenStream.peek() == Tokens.IDENT || tokenStream.peek() == Tokens.LPAREN){ mediaList.push(this._media_query()); } - + while(tokenStream.match(Tokens.COMMA)){ this._readWhitespace(); mediaList.push(this._media_query()); } - + return mediaList; }, - + /* * Note: "expression" in the grammar maps to the _media_expression * method. - + */ _media_query: function(){ /* @@ -1673,10 +1679,10 @@ Parser.prototype = function(){ ident = null, token = null, expressions = []; - + if (tokenStream.match(Tokens.IDENT)){ ident = tokenStream.token().value.toLowerCase(); - + //since there's no custom tokens for these, need to manually check if (ident != "only" && ident != "not"){ tokenStream.unget(); @@ -1685,9 +1691,9 @@ Parser.prototype = function(){ token = tokenStream.token(); } } - + this._readWhitespace(); - + if (tokenStream.peek() == Tokens.IDENT){ type = this._media_type(); if (token === null){ @@ -1698,17 +1704,17 @@ Parser.prototype = function(){ token = tokenStream.LT(1); } expressions.push(this._media_expression()); - } - + } + if (type === null && expressions.length === 0){ return null; - } else { + } else { this._readWhitespace(); while (tokenStream.match(Tokens.IDENT)){ if (tokenStream.token().value.toLowerCase() != "and"){ this._unexpectedToken(tokenStream.token()); } - + this._readWhitespace(); expressions.push(this._media_expression()); } @@ -1724,7 +1730,7 @@ Parser.prototype = function(){ * : IDENT * ; */ - return this._media_feature(); + return this._media_feature(); }, /** @@ -1745,22 +1751,22 @@ Parser.prototype = function(){ feature = null, token, expression = null; - + tokenStream.mustMatch(Tokens.LPAREN); - + feature = this._media_feature(); this._readWhitespace(); - + if (tokenStream.match(Tokens.COLON)){ this._readWhitespace(); token = tokenStream.LT(1); expression = this._expression(); } - + tokenStream.mustMatch(Tokens.RPAREN); this._readWhitespace(); - return new MediaFeature(feature, (expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null)); + return new MediaFeature(feature, (expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null)); }, //CSS3 Media Queries @@ -1771,33 +1777,33 @@ Parser.prototype = function(){ * ; */ var tokenStream = this._tokenStream; - + tokenStream.mustMatch(Tokens.IDENT); - - return SyntaxUnit.fromToken(tokenStream.token()); + + return SyntaxUnit.fromToken(tokenStream.token()); }, - + //CSS3 Paged Media _page: function(){ /* * page: - * PAGE_SYM S* IDENT? pseudo_page? S* + * PAGE_SYM S* IDENT? pseudo_page? S* * '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S* * ; - */ + */ var tokenStream = this._tokenStream, line, col, identifier = null, pseudoPage = null; - + //look for @page tokenStream.mustMatch(Tokens.PAGE_SYM); line = tokenStream.token().startLine; col = tokenStream.token().startCol; - + this._readWhitespace(); - + if (tokenStream.match(Tokens.IDENT)){ identifier = tokenStream.token().value; @@ -1805,35 +1811,35 @@ Parser.prototype = function(){ if (identifier.toLowerCase() === "auto"){ this._unexpectedToken(tokenStream.token()); } - } - + } + //see if there's a colon upcoming if (tokenStream.peek() == Tokens.COLON){ pseudoPage = this._pseudo_page(); } - + this._readWhitespace(); - + this.fire({ type: "startpage", id: identifier, pseudo: pseudoPage, line: line, col: col - }); + }); + + this._readDeclarations(true, true); - this._readDeclarations(true, true); - this.fire({ type: "endpage", id: identifier, pseudo: pseudoPage, line: line, col: col - }); - + }); + }, - + //CSS3 Paged Media _margin: function(){ /* @@ -1849,14 +1855,14 @@ Parser.prototype = function(){ if (marginSym){ line = tokenStream.token().startLine; col = tokenStream.token().startCol; - + this.fire({ type: "startpagemargin", margin: marginSym, line: line, col: col - }); - + }); + this._readDeclarations(true); this.fire({ @@ -1864,7 +1870,7 @@ Parser.prototype = function(){ margin: marginSym, line: line, col: col - }); + }); return true; } else { return false; @@ -1873,17 +1879,17 @@ Parser.prototype = function(){ //CSS3 Paged Media _margin_sym: function(){ - + /* * margin_sym : - * TOPLEFTCORNER_SYM | - * TOPLEFT_SYM | - * TOPCENTER_SYM | - * TOPRIGHT_SYM | + * TOPLEFTCORNER_SYM | + * TOPLEFT_SYM | + * TOPCENTER_SYM | + * TOPRIGHT_SYM | * TOPRIGHTCORNER_SYM | - * BOTTOMLEFTCORNER_SYM | - * BOTTOMLEFT_SYM | - * BOTTOMCENTER_SYM | + * BOTTOMLEFTCORNER_SYM | + * BOTTOMLEFT_SYM | + * BOTTOMCENTER_SYM | * BOTTOMRIGHT_SYM | * BOTTOMRIGHTCORNER_SYM | * LEFTTOP_SYM | @@ -1891,145 +1897,178 @@ Parser.prototype = function(){ * LEFTBOTTOM_SYM | * RIGHTTOP_SYM | * RIGHTMIDDLE_SYM | - * RIGHTBOTTOM_SYM + * RIGHTBOTTOM_SYM * ; */ - + var tokenStream = this._tokenStream; - + if(tokenStream.match([Tokens.TOPLEFTCORNER_SYM, Tokens.TOPLEFT_SYM, Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM, - Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM, + Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM, Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM, - Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM, + Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM, Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM, Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM])) { - return SyntaxUnit.fromToken(tokenStream.token()); + return SyntaxUnit.fromToken(tokenStream.token()); } else { return null; } - + }, - + _pseudo_page: function(){ /* * pseudo_page * : ':' IDENT - * ; + * ; */ - + var tokenStream = this._tokenStream; - + tokenStream.mustMatch(Tokens.COLON); tokenStream.mustMatch(Tokens.IDENT); - + //TODO: CSS3 Paged Media says only "left", "center", and "right" are allowed - + return tokenStream.token().value; }, - + _font_face: function(){ /* * font_face - * : FONT_FACE_SYM S* + * : FONT_FACE_SYM S* * '{' S* declaration [ ';' S* declaration ]* '}' S* * ; - */ + */ var tokenStream = this._tokenStream, line, col; - + //look for @page tokenStream.mustMatch(Tokens.FONT_FACE_SYM); line = tokenStream.token().startLine; col = tokenStream.token().startCol; - + this._readWhitespace(); this.fire({ type: "startfontface", line: line, col: col - }); - + }); + this._readDeclarations(true); - + this.fire({ type: "endfontface", line: line, col: col - }); + }); + }, + + _viewport: function(){ + /* + * viewport + * : VIEWPORT_SYM S* + * '{' S* declaration? [ ';' S* declaration? ]* '}' S* + * ; + */ + var tokenStream = this._tokenStream, + line, + col; + + tokenStream.mustMatch(Tokens.VIEWPORT_SYM); + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this._readWhitespace(); + + this.fire({ + type: "startviewport", + line: line, + col: col + }); + + this._readDeclarations(true); + + this.fire({ + type: "endviewport", + line: line, + col: col + }); + }, _operator: function(inFunction){ - + /* * operator (outside function) * : '/' S* | ',' S* | /( empty )/ * operator (inside function) * : '/' S* | '+' S* | '*' S* | '-' S* /( empty )/ * ; - */ - + */ + var tokenStream = this._tokenStream, token = null; - + if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) || (inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS]))){ token = tokenStream.token(); this._readWhitespace(); - } + } return token ? PropertyValuePart.fromToken(token) : null; - + }, - + _combinator: function(){ - + /* * combinator * : PLUS S* | GREATER S* | TILDE S* | S+ * ; - */ - + */ + var tokenStream = this._tokenStream, value = null, token; - - if(tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])){ + + if(tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])){ token = tokenStream.token(); value = new Combinator(token.value, token.startLine, token.startCol); this._readWhitespace(); } - + return value; }, - + _unary_operator: function(){ - + /* * unary_operator * : '-' | '+' * ; */ - + var tokenStream = this._tokenStream; - + if (tokenStream.match([Tokens.MINUS, Tokens.PLUS])){ return tokenStream.token().value; } else { return null; - } + } }, - + _property: function(){ - + /* * property * : IDENT S* - * ; + * ; */ - + var tokenStream = this._tokenStream, value = null, hack = null, @@ -2037,7 +2076,7 @@ Parser.prototype = function(){ token, line, col; - + //check for star hack - throws error if not allowed if (tokenStream.peek() == Tokens.STAR && this.options.starHack){ tokenStream.get(); @@ -2046,33 +2085,33 @@ Parser.prototype = function(){ line = token.startLine; col = token.startCol; } - + if(tokenStream.match(Tokens.IDENT)){ token = tokenStream.token(); tokenValue = token.value; - + //check for underscore hack - no error if not allowed because it's valid CSS syntax if (tokenValue.charAt(0) == "_" && this.options.underscoreHack){ hack = "_"; tokenValue = tokenValue.substring(1); } - + value = new PropertyName(tokenValue, hack, (line||token.startLine), (col||token.startCol)); this._readWhitespace(); } - + return value; }, - + //Augmented with CSS3 Selectors _ruleset: function(){ /* * ruleset * : selectors_group * '{' S* declaration? [ ';' S* declaration? ]* '}' S* - * ; - */ - + * ; + */ + var tokenStream = this._tokenStream, tt, selectors; @@ -2086,7 +2125,7 @@ Parser.prototype = function(){ selectors = this._selectors_group(); } catch (ex){ if (ex instanceof SyntaxError && !this.options.strict){ - + //fire error event this.fire({ type: "error", @@ -2094,8 +2133,8 @@ Parser.prototype = function(){ message: ex.message, line: ex.line, col: ex.col - }); - + }); + //skip over everything until closing brace tt = tokenStream.advance([Tokens.RBRACE]); if (tt == Tokens.RBRACE){ @@ -2103,57 +2142,57 @@ Parser.prototype = function(){ } else { //otherwise, rethrow the error because it wasn't handled properly throw ex; - } - + } + } else { //not a syntax error, rethrow it throw ex; - } - + } + //trigger parser to continue return true; } - + //if it got here, all selectors parsed - if (selectors){ - + if (selectors){ + this.fire({ type: "startrule", selectors: selectors, line: selectors[0].line, col: selectors[0].col - }); - - this._readDeclarations(true); - + }); + + this._readDeclarations(true); + this.fire({ type: "endrule", selectors: selectors, line: selectors[0].line, col: selectors[0].col - }); - + }); + } - + return selectors; - + }, //CSS3 Selectors _selectors_group: function(){ - - /* + + /* * selectors_group * : selector [ COMMA S* selector ]* * ; - */ + */ var tokenStream = this._tokenStream, selectors = [], selector; - + selector = this._selector(); if (selector !== null){ - + selectors.push(selector); while(tokenStream.match(Tokens.COMMA)){ this._readWhitespace(); @@ -2168,83 +2207,83 @@ Parser.prototype = function(){ return selectors.length ? selectors : null; }, - + //CSS3 Selectors _selector: function(){ /* * selector * : simple_selector_sequence [ combinator simple_selector_sequence ]* - * ; + * ; */ - + var tokenStream = this._tokenStream, selector = [], nextSelector = null, combinator = null, ws = null; - + //if there's no simple selector, then there's no selector nextSelector = this._simple_selector_sequence(); if (nextSelector === null){ return null; } - + selector.push(nextSelector); - + do { - + //look for a combinator combinator = this._combinator(); - + if (combinator !== null){ selector.push(combinator); nextSelector = this._simple_selector_sequence(); - + //there must be a next selector if (nextSelector === null){ this._unexpectedToken(tokenStream.LT(1)); } else { - + //nextSelector is an instance of SelectorPart selector.push(nextSelector); } } else { - + //if there's not whitespace, we're done - if (this._readWhitespace()){ - + if (this._readWhitespace()){ + //add whitespace separator ws = new Combinator(tokenStream.token().value, tokenStream.token().startLine, tokenStream.token().startCol); - + //combinator is not required combinator = this._combinator(); - + //selector is required if there's a combinator nextSelector = this._simple_selector_sequence(); - if (nextSelector === null){ + if (nextSelector === null){ if (combinator !== null){ this._unexpectedToken(tokenStream.LT(1)); } } else { - + if (combinator !== null){ selector.push(combinator); } else { selector.push(ws); } - + selector.push(nextSelector); - } + } } else { break; - } - + } + } } while(true); - + return new Selector(selector, selector[0].line, selector[0].col); }, - + //CSS3 Selectors _simple_selector_sequence: function(){ /* @@ -2254,13 +2293,13 @@ Parser.prototype = function(){ * | [ HASH | class | attrib | pseudo | negation ]+ * ; */ - + var tokenStream = this._tokenStream, - + //parts of a simple selector elementName = null, modifiers = [], - + //complete selector text selectorText= "", @@ -2283,35 +2322,35 @@ Parser.prototype = function(){ found = false, line, col; - - + + //get starting line and column for the selector line = tokenStream.LT(1).startLine; col = tokenStream.LT(1).startCol; - + elementName = this._type_selector(); if (!elementName){ elementName = this._universal(); } - + if (elementName !== null){ selectorText += elementName; - } - + } + while(true){ //whitespace means we're done if (tokenStream.peek() === Tokens.S){ break; } - + //check for each component while(i < len && component === null){ component = components[i++].call(this); } - + if (component === null){ - + //we don't have a selector if (selectorText === ""){ return null; @@ -2321,17 +2360,17 @@ Parser.prototype = function(){ } else { i = 0; modifiers.push(component); - selectorText += component.toString(); + selectorText += component.toString(); component = null; } } - + return selectorText !== "" ? new SelectorPart(elementName, modifiers, selectorText, line, col) : null; - }, - + }, + //CSS3 Selectors _type_selector: function(){ /* @@ -2339,12 +2378,12 @@ Parser.prototype = function(){ * : [ namespace_prefix ]? element_name * ; */ - + var tokenStream = this._tokenStream, ns = this._namespace_prefix(), elementName = this._element_name(); - - if (!elementName){ + + if (!elementName){ /* * Need to back out the namespace that was read due to both * type_selector and universal reading namespace_prefix @@ -2357,9 +2396,9 @@ Parser.prototype = function(){ tokenStream.unget(); } } - + return null; - } else { + } else { if (ns){ elementName.text = ns + elementName.text; elementName.col -= ns.length; @@ -2367,97 +2406,97 @@ Parser.prototype = function(){ return elementName; } }, - + //CSS3 Selectors _class: function(){ /* * class * : '.' IDENT * ; - */ - + */ + var tokenStream = this._tokenStream, token; - + if (tokenStream.match(Tokens.DOT)){ - tokenStream.mustMatch(Tokens.IDENT); + tokenStream.mustMatch(Tokens.IDENT); token = tokenStream.token(); - return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1); + return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1); } else { return null; } - + }, - + //CSS3 Selectors _element_name: function(){ /* * element_name * : IDENT * ; - */ - + */ + var tokenStream = this._tokenStream, token; - + if (tokenStream.match(Tokens.IDENT)){ token = tokenStream.token(); - return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol); - + return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol); + } else { return null; } }, - + //CSS3 Selectors _namespace_prefix: function(){ - /* + /* * namespace_prefix * : [ IDENT | '*' ]? '|' * ; */ var tokenStream = this._tokenStream, value = ""; - + //verify that this is a namespace prefix if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE){ - + if(tokenStream.match([Tokens.IDENT, Tokens.STAR])){ value += tokenStream.token().value; } - + tokenStream.mustMatch(Tokens.PIPE); value += "|"; - + } - - return value.length ? value : null; + + return value.length ? value : null; }, - + //CSS3 Selectors _universal: function(){ /* * universal * : [ namespace_prefix ]? '*' - * ; + * ; */ var tokenStream = this._tokenStream, value = "", ns; - + ns = this._namespace_prefix(); if(ns){ value += ns; } - + if(tokenStream.match(Tokens.STAR)){ value += "*"; } - + return value.length ? value : null; - + }, - + //CSS3 Selectors _attrib: function(){ /* @@ -2470,69 +2509,69 @@ Parser.prototype = function(){ * INCLUDES | * DASHMATCH ] S* [ IDENT | STRING ] S* * ]? ']' - * ; + * ; */ - + var tokenStream = this._tokenStream, value = null, ns, token; - + if (tokenStream.match(Tokens.LBRACKET)){ token = tokenStream.token(); value = token.value; value += this._readWhitespace(); - + ns = this._namespace_prefix(); - + if (ns){ value += ns; } - + tokenStream.mustMatch(Tokens.IDENT); - value += tokenStream.token().value; + value += tokenStream.token().value; value += this._readWhitespace(); - + if(tokenStream.match([Tokens.PREFIXMATCH, Tokens.SUFFIXMATCH, Tokens.SUBSTRINGMATCH, Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])){ - - value += tokenStream.token().value; + + value += tokenStream.token().value; value += this._readWhitespace(); - + tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]); - value += tokenStream.token().value; + value += tokenStream.token().value; value += this._readWhitespace(); } - + tokenStream.mustMatch(Tokens.RBRACKET); - + return new SelectorSubPart(value + "]", "attribute", token.startLine, token.startCol); } else { return null; } }, - + //CSS3 Selectors _pseudo: function(){ - + /* * pseudo * : ':' ':'? [ IDENT | functional_pseudo ] - * ; - */ - + * ; + */ + var tokenStream = this._tokenStream, pseudo = null, colons = ":", line, col; - + if (tokenStream.match(Tokens.COLON)){ - + if (tokenStream.match(Tokens.COLON)){ colons += ":"; } - + if (tokenStream.match(Tokens.IDENT)){ pseudo = tokenStream.token().value; line = tokenStream.token().startLine; @@ -2542,26 +2581,26 @@ Parser.prototype = function(){ col = tokenStream.LT(1).startCol - colons.length; pseudo = this._functional_pseudo(); } - + if (pseudo){ pseudo = new SelectorSubPart(colons + pseudo, "pseudo", line, col); } } - + return pseudo; }, - + //CSS3 Selectors _functional_pseudo: function(){ /* * functional_pseudo * : FUNCTION S* expression ')' * ; - */ - + */ + var tokenStream = this._tokenStream, value = null; - + if(tokenStream.match(Tokens.FUNCTION)){ value = tokenStream.token().value; value += this._readWhitespace(); @@ -2569,10 +2608,10 @@ Parser.prototype = function(){ tokenStream.mustMatch(Tokens.RPAREN); value += ")"; } - + return value; }, - + //CSS3 Selectors _expression: function(){ /* @@ -2580,26 +2619,26 @@ Parser.prototype = function(){ * : [ [ PLUS | '-' | DIMENSION | NUMBER | STRING | IDENT ] S* ]+ * ; */ - + var tokenStream = this._tokenStream, value = ""; - + while(tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION, Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH, Tokens.FREQ, Tokens.ANGLE, Tokens.TIME, Tokens.RESOLUTION, Tokens.SLASH])){ - + value += tokenStream.token().value; - value += this._readWhitespace(); + value += this._readWhitespace(); } - + return value.length ? value : null; - + }, //CSS3 Selectors _negation: function(){ - /* + /* * negation * : NOT S* negation_arg S* ')' * ; @@ -2611,7 +2650,7 @@ Parser.prototype = function(){ value = "", arg, subpart = null; - + if (tokenStream.match(Tokens.NOT)){ value = tokenStream.token().value; line = tokenStream.token().startLine; @@ -2622,22 +2661,22 @@ Parser.prototype = function(){ value += this._readWhitespace(); tokenStream.match(Tokens.RPAREN); value += tokenStream.token().value; - + subpart = new SelectorSubPart(value, "not", line, col); subpart.args.push(arg); } - + return subpart; }, - + //CSS3 Selectors - _negation_arg: function(){ + _negation_arg: function(){ /* * negation_arg * : type_selector | universal | HASH | class | attrib | pseudo - * ; - */ - + * ; + */ + var tokenStream = this._tokenStream, args = [ this._type_selector, @@ -2645,11 +2684,11 @@ Parser.prototype = function(){ function(){ return tokenStream.match(Tokens.HASH) ? new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) : - null; + null; }, this._class, this._attrib, - this._pseudo + this._pseudo ], arg = null, i = 0, @@ -2658,40 +2697,40 @@ Parser.prototype = function(){ line, col, part; - + line = tokenStream.LT(1).startLine; col = tokenStream.LT(1).startCol; - + while(i < len && arg === null){ - + arg = args[i].call(this); i++; } - + //must be a negation arg if (arg === null){ this._unexpectedToken(tokenStream.LT(1)); } - + //it's an element name if (arg.type == "elementName"){ part = new SelectorPart(arg, [], arg.toString(), line, col); } else { part = new SelectorPart(null, [arg], arg.toString(), line, col); } - - return part; + + return part; }, - + _declaration: function(){ - + /* * declaration * : property ':' S* expr prio? * | /( empty )/ - * ; - */ - + * ; + */ + var tokenStream = this._tokenStream, property = null, expr = null, @@ -2699,22 +2738,22 @@ Parser.prototype = function(){ error = null, invalid = null, propertyName= ""; - + property = this._property(); if (property !== null){ tokenStream.mustMatch(Tokens.COLON); this._readWhitespace(); - + expr = this._expr(); - + //if there's no parts for the value, it's an error if (!expr || expr.length === 0){ this._unexpectedToken(tokenStream.LT(1)); } - + prio = this._prio(); - + /* * If hacks should be allowed, then only check the root * property. If hacks should not be allowed, treat @@ -2723,16 +2762,16 @@ Parser.prototype = function(){ propertyName = property.toString(); if (this.options.starHack && property.hack == "*" || this.options.underscoreHack && property.hack == "_") { - + propertyName = property.text; } - + try { this._validateProperty(propertyName, expr); } catch (ex) { invalid = ex; } - + this.fire({ type: "property", property: property, @@ -2741,46 +2780,46 @@ Parser.prototype = function(){ line: property.line, col: property.col, invalid: invalid - }); - + }); + return true; } else { return false; } }, - + _prio: function(){ /* * prio * : IMPORTANT_SYM S* - * ; + * ; */ - + var tokenStream = this._tokenStream, result = tokenStream.match(Tokens.IMPORTANT_SYM); - + this._readWhitespace(); return result; }, - + _expr: function(inFunction){ /* * expr * : term [ operator term ]* * ; */ - + var tokenStream = this._tokenStream, values = [], //valueParts = [], value = null, operator = null; - + value = this._term(); if (value !== null){ - + values.push(value); - + do { operator = this._operator(inFunction); @@ -2792,9 +2831,9 @@ Parser.prototype = function(){ values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col)); valueParts = []; }*/ - + value = this._term(); - + if (value === null){ break; } else { @@ -2802,17 +2841,17 @@ Parser.prototype = function(){ } } while(true); } - + //cleanup /*if (valueParts.length){ values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col)); }*/ - + return values.length > 0 ? new PropertyValue(values, values[0].line, values[0].col) : null; }, - - _term: function(){ - + + _term: function(){ + /* * term * : unary_operator? @@ -2820,36 +2859,36 @@ Parser.prototype = function(){ * TIME S* | FREQ S* | function | ie_function ] * | STRING S* | IDENT S* | URI S* | UNICODERANGE S* | hexcolor * ; - */ - + */ + var tokenStream = this._tokenStream, unary = null, value = null, token, line, col; - + //returns the operator or null unary = this._unary_operator(); if (unary !== null){ line = tokenStream.token().startLine; col = tokenStream.token().startCol; - } - + } + //exception for IE filters if (tokenStream.peek() == Tokens.IE_FUNCTION && this.options.ieFilters){ - + value = this._ie_function(); if (unary === null){ line = tokenStream.token().startLine; col = tokenStream.token().startCol; } - + //see if there's a simple match } else if (tokenStream.match([Tokens.NUMBER, Tokens.PERCENTAGE, Tokens.LENGTH, Tokens.ANGLE, Tokens.TIME, Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])){ - + value = tokenStream.token().value; if (unary === null){ line = tokenStream.token().startLine; @@ -2857,20 +2896,20 @@ Parser.prototype = function(){ } this._readWhitespace(); } else { - + //see if it's a color token = this._hexcolor(); if (token === null){ - + //if there's no unary, get the start of the next token for line/col info if (unary === null){ line = tokenStream.LT(1).startLine; col = tokenStream.LT(1).startCol; - } - + } + //has to be a function if (value === null){ - + /* * This checks for alpha(opacity=0) style of IE * functions. IE_FUNCTION only presents progid: style. @@ -2886,61 +2925,61 @@ Parser.prototype = function(){ return null; //throw new Error("Expected identifier at line " + tokenStream.token().startLine + ", character " + tokenStream.token().startCol + "."); }*/ - + } else { value = token.value; if (unary === null){ line = token.startLine; col = token.startCol; - } + } } - - } - + + } + return value !== null ? new PropertyValuePart(unary !== null ? unary + value : value, line, col) : null; - + }, - + _function: function(){ - + /* * function * : FUNCTION S* expr ')' S* * ; */ - + var tokenStream = this._tokenStream, functionText = null, expr = null, lt; - + if (tokenStream.match(Tokens.FUNCTION)){ functionText = tokenStream.token().value; this._readWhitespace(); expr = this._expr(true); functionText += expr; - + //START: Horrible hack in case it's an IE filter if (this.options.ieFilters && tokenStream.peek() == Tokens.EQUALS){ do { - + if (this._readWhitespace()){ functionText += tokenStream.token().value; } - + //might be second time in the loop if (tokenStream.LA(0) == Tokens.COMMA){ functionText += tokenStream.token().value; } - + tokenStream.match(Tokens.IDENT); functionText += tokenStream.token().value; - + tokenStream.match(Tokens.EQUALS); functionText += tokenStream.token().value; - + //functionText += this._term(); lt = tokenStream.peek(); while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){ @@ -2952,49 +2991,49 @@ Parser.prototype = function(){ } //END: Horrible Hack - - tokenStream.match(Tokens.RPAREN); + + tokenStream.match(Tokens.RPAREN); functionText += ")"; this._readWhitespace(); - } - + } + return functionText; - }, - + }, + _ie_function: function(){ - + /* (My own extension) * ie_function * : IE_FUNCTION S* IDENT '=' term [S* ','? IDENT '=' term]+ ')' S* * ; */ - + var tokenStream = this._tokenStream, functionText = null, expr = null, lt; - + //IE function can begin like a regular function, too if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])){ functionText = tokenStream.token().value; - + do { - + if (this._readWhitespace()){ functionText += tokenStream.token().value; } - + //might be second time in the loop if (tokenStream.LA(0) == Tokens.COMMA){ functionText += tokenStream.token().value; } - + tokenStream.match(Tokens.IDENT); functionText += tokenStream.token().value; - + tokenStream.match(Tokens.EQUALS); functionText += tokenStream.token().value; - + //functionText += this._term(); lt = tokenStream.peek(); while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){ @@ -3002,16 +3041,16 @@ Parser.prototype = function(){ functionText += tokenStream.token().value; lt = tokenStream.peek(); } - } while(tokenStream.match([Tokens.COMMA, Tokens.S])); - - tokenStream.match(Tokens.RPAREN); + } while(tokenStream.match([Tokens.COMMA, Tokens.S])); + + tokenStream.match(Tokens.RPAREN); functionText += ")"; this._readWhitespace(); - } - + } + return functionText; - }, - + }, + _hexcolor: function(){ /* * There is a constraint on the color that it must @@ -3022,15 +3061,15 @@ Parser.prototype = function(){ * : HASH S* * ; */ - + var tokenStream = this._tokenStream, token = null, color; - + if(tokenStream.match(Tokens.HASH)){ - + //need to do some validation here - + token = tokenStream.token(); color = token.value; if (!/#[a-f0-9]{3,6}/i.test(color)){ @@ -3038,16 +3077,16 @@ Parser.prototype = function(){ } this._readWhitespace(); } - + return token; }, - + //----------------------------------------------------------------- // Animations methods //----------------------------------------------------------------- - + _keyframes: function(){ - + /* * keyframes: * : KEYFRAMES_SYM S* keyframe_name S* '{' S* keyframe_rule* '}' { @@ -3057,53 +3096,53 @@ Parser.prototype = function(){ token, tt, name, - prefix = ""; - + prefix = ""; + tokenStream.mustMatch(Tokens.KEYFRAMES_SYM); token = tokenStream.token(); if (/^@\-([^\-]+)\-/.test(token.value)) { prefix = RegExp.$1; } - + this._readWhitespace(); name = this._keyframe_name(); - + this._readWhitespace(); tokenStream.mustMatch(Tokens.LBRACE); - + this.fire({ type: "startkeyframes", name: name, prefix: prefix, line: token.startLine, col: token.startCol - }); - + }); + this._readWhitespace(); tt = tokenStream.peek(); - + //check for key while(tt == Tokens.IDENT || tt == Tokens.PERCENTAGE) { this._keyframe_rule(); this._readWhitespace(); tt = tokenStream.peek(); - } - + } + this.fire({ type: "endkeyframes", name: name, prefix: prefix, line: token.startLine, col: token.startCol - }); - + }); + this._readWhitespace(); - tokenStream.mustMatch(Tokens.RBRACE); - + tokenStream.mustMatch(Tokens.RBRACE); + }, - + _keyframe_name: function(){ - + /* * keyframe_name: * : IDENT @@ -3114,41 +3153,41 @@ Parser.prototype = function(){ token; tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]); - return SyntaxUnit.fromToken(tokenStream.token()); + return SyntaxUnit.fromToken(tokenStream.token()); }, - + _keyframe_rule: function(){ - + /* * keyframe_rule: - * : key_list S* + * : key_list S* * '{' S* declaration [ ';' S* declaration ]* '}' S* * ; */ var tokenStream = this._tokenStream, token, keyList = this._key_list(); - + this.fire({ type: "startkeyframerule", keys: keyList, line: keyList[0].line, col: keyList[0].col - }); - - this._readDeclarations(true); - + }); + + this._readDeclarations(true); + this.fire({ type: "endkeyframerule", keys: keyList, line: keyList[0].line, col: keyList[0].col - }); - + }); + }, - + _key_list: function(){ - + /* * key_list: * : key [ S* ',' S* key]* @@ -3158,12 +3197,12 @@ Parser.prototype = function(){ token, key, keyList = []; - + //must be least one key keyList.push(this._key()); - + this._readWhitespace(); - + while(tokenStream.match(Tokens.COMMA)){ this._readWhitespace(); keyList.push(this._key()); @@ -3172,7 +3211,7 @@ Parser.prototype = function(){ return keyList; }, - + _key: function(){ /* * There is a restriction that IDENT can be only "from" or "to". @@ -3182,30 +3221,30 @@ Parser.prototype = function(){ * | IDENT * ; */ - + var tokenStream = this._tokenStream, token; - + if (tokenStream.match(Tokens.PERCENTAGE)){ return SyntaxUnit.fromToken(tokenStream.token()); } else if (tokenStream.match(Tokens.IDENT)){ - token = tokenStream.token(); - + token = tokenStream.token(); + if (/from|to/i.test(token.value)){ return SyntaxUnit.fromToken(token); } - + tokenStream.unget(); } - + //if it gets here, there wasn't a valid token, so time to explode this._unexpectedToken(tokenStream.LT(1)); }, - + //----------------------------------------------------------------- // Helper methods //----------------------------------------------------------------- - + /** * Not part of CSS grammar, but useful for skipping over * combination of white space and HTML-style comments. @@ -3238,25 +3277,25 @@ Parser.prototype = function(){ * or * S* '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S* * Note that this is how it is described in CSS3 Paged Media, but is actually incorrect. - * A semicolon is only necessary following a delcaration is there's another declaration - * or margin afterwards. + * A semicolon is only necessary following a declaration is there's another declaration + * or margin afterwards. */ var tokenStream = this._tokenStream, tt; - + this._readWhitespace(); - + if (checkStart){ - tokenStream.mustMatch(Tokens.LBRACE); + tokenStream.mustMatch(Tokens.LBRACE); } - + this._readWhitespace(); try { - + while(true){ - + if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())){ //noop } else if (this._declaration()){ @@ -3266,19 +3305,19 @@ Parser.prototype = function(){ } else { break; } - + //if ((!this._margin() && !this._declaration()) || !tokenStream.match(Tokens.SEMICOLON)){ // break; //} this._readWhitespace(); } - + tokenStream.mustMatch(Tokens.RBRACE); this._readWhitespace(); - + } catch (ex) { if (ex instanceof SyntaxError && !this.options.strict){ - + //fire error event this.fire({ type: "error", @@ -3286,27 +3325,27 @@ Parser.prototype = function(){ message: ex.message, line: ex.line, col: ex.col - }); - + }); + //see if there's another declaration tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]); if (tt == Tokens.SEMICOLON){ //if there's a semicolon, then there might be another declaration - this._readDeclarations(false, readMargins); + this._readDeclarations(false, readMargins); } else if (tt != Tokens.RBRACE){ //if there's a right brace, the rule is finished so don't do anything //otherwise, rethrow the error because it wasn't handled properly throw ex; - } - + } + } else { //not a syntax error, rethrow it throw ex; } - } - - }, - + } + + }, + /** * In some cases, you can end up with two white space tokens in a * row. Instead of making a change in every function that looks for @@ -3317,17 +3356,17 @@ Parser.prototype = function(){ * @private */ _readWhitespace: function(){ - + var tokenStream = this._tokenStream, ws = ""; - + while(tokenStream.match(Tokens.S)){ ws += tokenStream.token().value; } - + return ws; }, - + /** * Throws an error when an unexpected token is found. @@ -3339,7 +3378,7 @@ Parser.prototype = function(){ _unexpectedToken: function(token){ throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol); }, - + /** * Helper method used for parsing subparts of a style sheet. * @return {void} @@ -3349,64 +3388,64 @@ Parser.prototype = function(){ _verifyEnd: function(){ if (this._tokenStream.LA(1) != Tokens.EOF){ this._unexpectedToken(this._tokenStream.LT(1)); - } + } }, - + //----------------------------------------------------------------- // Validation methods //----------------------------------------------------------------- _validateProperty: function(property, value){ Validation.validate(property, value); }, - + //----------------------------------------------------------------- // Parsing methods //----------------------------------------------------------------- - - parse: function(input){ + + parse: function(input){ this._tokenStream = new TokenStream(input, Tokens); this._stylesheet(); }, - + parseStyleSheet: function(input){ //just passthrough return this.parse(input); }, - + parseMediaQuery: function(input){ this._tokenStream = new TokenStream(input, Tokens); var result = this._media_query(); - + //if there's anything more, then it's an invalid selector this._verifyEnd(); - + //otherwise return result - return result; + return result; }, - + /** * Parses a property value (everything after the semicolon). * @return {parserlib.css.PropertyValue} The property value. * @throws parserlib.util.SyntaxError If an unexpected token is found. * @method parserPropertyValue - */ + */ parsePropertyValue: function(input){ - + this._tokenStream = new TokenStream(input, Tokens); this._readWhitespace(); - + var result = this._expr(); - + //okay to have a trailing white space this._readWhitespace(); - + //if there's anything more, then it's an invalid selector this._verifyEnd(); - + //otherwise return result return result; }, - + /** * Parses a complete CSS rule, including selectors and * properties. @@ -3416,22 +3455,22 @@ Parser.prototype = function(){ */ parseRule: function(input){ this._tokenStream = new TokenStream(input, Tokens); - + //skip any leading white space this._readWhitespace(); - + var result = this._ruleset(); - + //skip any trailing white space this._readWhitespace(); //if there's anything more, then it's an invalid selector this._verifyEnd(); - + //otherwise return result - return result; + return result; }, - + /** * Parses a single CSS selector (no comma) * @param {String} input The text to parse as a CSS selector. @@ -3440,29 +3479,29 @@ Parser.prototype = function(){ * @method parseSelector */ parseSelector: function(input){ - + this._tokenStream = new TokenStream(input, Tokens); - + //skip any leading white space this._readWhitespace(); - + var result = this._selector(); - + //skip any trailing white space this._readWhitespace(); //if there's anything more, then it's an invalid selector this._verifyEnd(); - + //otherwise return result return result; }, /** - * Parses an HTML style attribute: a set of CSS declarations + * Parses an HTML style attribute: a set of CSS declarations * separated by semicolons. * @param {String} input The text to parse as a style attribute - * @return {void} + * @return {void} * @method parseStyleAttribute */ parseStyleAttribute: function(input){ @@ -3471,14 +3510,14 @@ Parser.prototype = function(){ this._readDeclarations(); } }; - + //copy over onto prototype for (prop in additions){ if (additions.hasOwnProperty(prop)){ proto[prop] = additions[prop]; } - } - + } + return proto; }(); @@ -3489,6 +3528,7 @@ nth ['-'|'+']? INTEGER | {O}{D}{D} | {E}{V}{E}{N} ] S* ; */ + /*global Validation, ValidationTypes, ValidationError*/ var Properties = { @@ -3586,7 +3626,7 @@ var Properties = { "bookmark-target" : "none | | ", "border" : " || || ", "border-bottom" : " || || ", - "border-bottom-color" : "", + "border-bottom-color" : " | inherit", "border-bottom-left-radius" : "", "border-bottom-right-radius" : "", "border-bottom-style" : "", @@ -3643,7 +3683,7 @@ var Properties = { "border-radius" : function(expression) { var valid = false, - numeric = " | ", + simple = " | | inherit", slash = false, fill = false, count = 0, @@ -3651,7 +3691,7 @@ var Properties = { part; while (expression.hasNext() && count < max) { - valid = ValidationTypes.isAny(expression, numeric); + valid = ValidationTypes.isAny(expression, simple); if (!valid) { if (expression.peek() == "/" && count > 0 && !slash) { @@ -3742,7 +3782,7 @@ var Properties = { //D "direction" : "ltr | rtl | inherit", - "display" : "inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | box | inline-box | grid | inline-grid | none | inherit | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker", + "display" : "inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | box | inline-box | grid | inline-grid | none | inherit | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box", "dominant-baseline" : 1, "drop-initial-after-adjust" : "central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | | ", "drop-initial-after-align" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical", @@ -3970,6 +4010,7 @@ var Properties = { "z-index" : " | auto | inherit", "zoom" : " | | normal" }; + /*global SyntaxUnit, Parser*/ /** * Represents a selector combinator (whitespace, +, >). @@ -4203,6 +4244,9 @@ function PropertyValuePart(text, line, col){ case "pt": case "pc": case "ch": + case "vh": + case "vw": + case "vm": this.type = "length"; break; @@ -5589,7 +5633,7 @@ var Tokens = [ /* * The following token names are defined in CSS3 Grammar: http://www.w3.org/TR/css3-syntax/#lexical */ - + //HTML-style comments { name: "CDO"}, { name: "CDC"}, @@ -5597,16 +5641,16 @@ var Tokens = [ //ignorables { name: "S", whitespace: true/*, channel: "ws"*/}, { name: "COMMENT", comment: true, hide: true, channel: "comment" }, - + //attribute equality { name: "INCLUDES", text: "~="}, { name: "DASHMATCH", text: "|="}, { name: "PREFIXMATCH", text: "^="}, { name: "SUFFIXMATCH", text: "$="}, { name: "SUBSTRINGMATCH", text: "*="}, - + //identifier types - { name: "STRING"}, + { name: "STRING"}, { name: "IDENT"}, { name: "HASH"}, @@ -5617,9 +5661,10 @@ var Tokens = [ { name: "FONT_FACE_SYM", text: "@font-face"}, { name: "CHARSET_SYM", text: "@charset"}, { name: "NAMESPACE_SYM", text: "@namespace"}, + { name: "VIEWPORT_SYM", text: "@viewport"}, { name: "UNKNOWN_SYM" }, //{ name: "ATKEYWORD"}, - + //CSS3 animations { name: "KEYFRAMES_SYM", text: [ "@keyframes", "@-webkit-keyframes", "@-moz-keyframes", "@-o-keyframes" ] }, @@ -5634,30 +5679,30 @@ var Tokens = [ { name: "DIMENSION"}, { name: "PERCENTAGE"}, { name: "NUMBER"}, - + //functions { name: "URI"}, { name: "FUNCTION"}, - + //Unicode ranges { name: "UNICODE_RANGE"}, - + /* * The following token names are defined in CSS3 Selectors: http://www.w3.org/TR/css3-selectors/#selector-syntax - */ - + */ + //invalid string { name: "INVALID"}, - + //combinators { name: "PLUS", text: "+" }, { name: "GREATER", text: ">"}, { name: "COMMA", text: ","}, { name: "TILDE", text: "~"}, - + //modifier - { name: "NOT"}, - + { name: "NOT"}, + /* * Defined in CSS3 Paged Media */ @@ -5689,13 +5734,13 @@ var Tokens = [ /* * The following token names are not defined in any CSS specification but are used by the lexer. */ - + //not a real token, but useful for stupid IE filters { name: "IE_FUNCTION" }, //part of CSS3 grammar but not the Flex code { name: "CHAR" }, - + //TODO: Needed? //Not defined as tokens, but might as well be { @@ -5718,19 +5763,19 @@ var Tokens = [ { name: "LBRACE", text: "{" - }, + }, { name: "RBRACE", text: "}" - }, + }, { name: "LBRACKET", text: "[" - }, + }, { name: "RBRACKET", text: "]" - }, + }, { name: "EQUALS", text: "=" @@ -5738,20 +5783,20 @@ var Tokens = [ { name: "COLON", text: ":" - }, + }, { name: "SEMICOLON", text: ";" - }, - + }, + { name: "LPAREN", text: "(" - }, + }, { name: "RPAREN", text: ")" - }, + }, { name: "DOT", text: "." @@ -5762,7 +5807,7 @@ var Tokens = [ var nameMap = [], typeMap = {}; - + Tokens.UNKNOWN = -1; Tokens.unshift({name:"EOF"}); for (var i=0, len = Tokens.length; i < len; i++){ @@ -5778,11 +5823,11 @@ var Tokens = [ } } } - + Tokens.name = function(tt){ return nameMap[tt]; }; - + Tokens.type = function(c){ return typeMap[c] || -1; }; @@ -6341,14 +6386,11 @@ var ValidationTypes = { "": function(expression) { //[ | ] [ | ]? var result = false, - count = 0, - numeric = " | ", - part; + simple = " | | inherit"; - if (ValidationTypes.isAny(expression, numeric)){ + if (ValidationTypes.isAny(expression, simple)){ result = true; - - ValidationTypes.isAny(expression, numeric); + ValidationTypes.isAny(expression, simple); } return result; @@ -6378,6 +6420,15 @@ ValidationError :ValidationError })(); + + +(function(){ +for(var prop in parserlib){ +exports[prop] = parserlib[prop]; +} +})(); + + /** * Main CSSLint object. * @class CSSLint @@ -6392,7 +6443,7 @@ var CSSLint = (function(){ embeddedRuleset = /\/\*csslint([^\*]*)\*\//, api = new parserlib.util.EventTarget(); - api.version = "0.9.10"; + api.version = "0.10.0"; //------------------------------------------------------------------------- // Rule Management @@ -6615,6 +6666,7 @@ var CSSLint = (function(){ return api; })(); + /*global CSSLint*/ /** * An instance of Report is used to report results of the @@ -7763,6 +7815,7 @@ CSSLint.addRule({ } }); + /* * Rule: Don't use IDs for selectors. */ @@ -8176,6 +8229,7 @@ CSSLint.addRule({ } }); + /* * Rule: Warn people past the IE 4095 limit */ diff --git a/tool/update_deps.js b/tool/update_deps.js index adab36bd..a5adebb3 100644 --- a/tool/update_deps.js +++ b/tool/update_deps.js @@ -11,7 +11,7 @@ var rootDir = __dirname + "/../lib/ace/"; var deps = { csslint: { path: "mode/css/csslint.js", - url: "https://raw.github.com/stubbornella/csslint/master/release/csslint-node.js", + url: "https://raw.github.com/stubbornella/csslint/master/release/csslint.js", needsFixup: true }, requirejs: { From 10e2c3049cf2fd41a369336c4d03342127a618e2 Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 4 Dec 2013 01:48:18 +0400 Subject: [PATCH 7/8] add options for theme and mode --- lib/ace/edit_session.js | 4 ++++ lib/ace/editor.js | 6 ++++-- lib/ace/virtual_renderer.js | 17 ++++++++++++----- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index eab30e92..a63ceeef 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -2534,6 +2534,10 @@ config.defineOptions(EditSession.prototype, "session", { set: function(val) {this.doc.setNewLineMode(val)}, get: function() {return this.doc.getNewLineMode()}, handlesSet: true + }, + mode: { + set: function(val) { this.setMode(val) }, + get: function() { return this.$modeId } } }); diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 9c4e5ef3..6486a881 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -248,7 +248,7 @@ var Editor = function(renderer, session) { this.setKeyboardHandler = function(keyboardHandler) { if (!keyboardHandler) { this.keyBinding.setKeyboardHandler(null); - } else if (typeof keyboardHandler == "string") { + } else if (typeof keyboardHandler === "string") { this.$keybindingId = keyboardHandler; var _self = this; config.loadModule(["keybinding", keyboardHandler], function(module) { @@ -2424,6 +2424,7 @@ config.defineOptions(Editor.prototype, "editor", { minLines: "renderer", scrollPastEnd: "renderer", fixedWidthGutter: "renderer", + theme: "renderer", scrollSpeed: "$mouseHandler", dragDelay: "$mouseHandler", @@ -2437,7 +2438,8 @@ config.defineOptions(Editor.prototype, "editor", { useSoftTabs: "session", tabSize: "session", wrap: "session", - foldStyle: "session" + foldStyle: "session", + mode: "session" }); exports.Editor = Editor; diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 943aebaf..dbf02aee 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -49,6 +49,7 @@ dom.importCssString(editorCss, "ace_editor"); /** * The class that is responsible for drawing everything you see on the screen! + * @related editor.renderer * @class VirtualRenderer **/ @@ -1469,18 +1470,18 @@ var VirtualRenderer = function(container, theme) { **/ this.setTheme = function(theme, cb) { var _self = this; - this.$themeValue = theme; + this.$themeId = theme; _self._dispatchEvent('themeChange',{theme:theme}); if (!theme || typeof theme == "string") { - var moduleName = theme || "ace/theme/textmate"; + var moduleName = theme || this.$options.theme.initialValue; config.loadModule(["theme", moduleName], afterLoad); } else { afterLoad(theme); } function afterLoad(module) { - if (_self.$themeValue != theme) + if (_self.$themeId != theme) return cb && cb(); if (!module.cssClass) return; @@ -1507,7 +1508,7 @@ var VirtualRenderer = function(container, theme) { // force re-measure of the gutter width if (_self.$size) { _self.$size.width = 0; - _self.onResize(); + _self.$updateSizeAsync(); } _self._dispatchEvent('themeLoaded', {theme:module}); @@ -1520,7 +1521,7 @@ var VirtualRenderer = function(container, theme) { * @returns {String} **/ this.getTheme = function() { - return this.$themeValue; + return this.$themeId; }; // Methods allows to add / remove CSS classnames to the editor element. @@ -1688,6 +1689,12 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", { this.$gutterLayer.$fixedWidth = !!val; this.$loop.schedule(this.CHANGE_GUTTER); } + }, + theme: { + set: function(val) { this.setTheme(val) }, + get: function() { return this.$themeId || this.theme; }, + initialValue: "./theme/textmate", + handlesSet: true } }); From 3a864c6056509ceeba2d290407dc91566c223d8e Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 17 Dec 2013 00:04:21 +0400 Subject: [PATCH 8/8] add support for inline mode in php worker --- lib/ace/mode/php.js | 7 +++++-- lib/ace/mode/php_worker.js | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/ace/mode/php.js b/lib/ace/mode/php.js index 18aecb66..e7f2317b 100644 --- a/lib/ace/mode/php.js +++ b/lib/ace/mode/php.js @@ -44,8 +44,8 @@ var CStyleFoldMode = require("./folding/cstyle").FoldMode; var unicode = require("../unicode"); var Mode = function(opts) { - var inline = opts && opts.inline; - var HighlightRules = inline ? PhpLangHighlightRules : PhpHighlightRules; + this.inlinePhp = opts && opts.inline; + var HighlightRules = this.inlinePhp ? PhpLangHighlightRules : PhpHighlightRules; this.HighlightRules = HighlightRules; this.$outdent = new MatchingBraceOutdent(); this.$behaviour = new CstyleBehaviour(); @@ -117,6 +117,9 @@ oop.inherits(Mode, TextMode); this.createWorker = function(session) { var worker = new WorkerClient(["ace"], "ace/mode/php_worker", "PhpWorker"); worker.attachToDocument(session.getDocument()); + + if (this.inlinePhp) + worker.call("setOptions", [{inline: true}]); worker.on("error", function(e) { session.setAnnotations(e.data); diff --git a/lib/ace/mode/php_worker.js b/lib/ace/mode/php_worker.js index 59ebcf48..878d88d6 100644 --- a/lib/ace/mode/php_worker.js +++ b/lib/ace/mode/php_worker.js @@ -43,12 +43,17 @@ var PhpWorker = exports.PhpWorker = function(sender) { oop.inherits(PhpWorker, Mirror); (function() { - + this.setOptions = function(opts) { + this.inlinePhp = opts && opts.inline; + }; + this.onUpdate = function() { var value = this.doc.getValue(); var errors = []; // var start = new Date(); + if (this.inlinePhp) + value = ""; var tokens = PHP.Lexer(value, {short_open_tag: 1}); try {