Permalink
Browse files

Major Documentation and Syntax Updates

  • Loading branch information...
1 parent 7d10919 commit c2716faffaad9780bbcf93d7568b38f12be6aeb7 @Inspiravetion committed Mar 6, 2014
View
BIN .DS_Store
Binary file not shown.
@@ -61,7 +61,7 @@
},
{
"comment": "keywords like 'from' 0 'to' 10 'do'...",
- "match": "\\b(spawn|if|else|then|for|in|while|do|not|and|or|from|to|by|function|end|module|class|import|export|super|this|return|operator|extends|private|either|wait_for|break|given|is|except)\\b",
+ "match": "\\b(spawn|if|else|then|for|var|in|while|do|not|and|or|from|to|by|function|end|module|class|import|export|super|this|return|operator|extends|private|either|wait_for|break|given|is|except)\\b",
"name": "keyword.control.source.hydra"
},
{
View
Binary file not shown.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -967,7 +967,7 @@
keywords: {
keyword: 'for if from to else then while var in class private public gen function extends do end',
literal: 'false true null',
- 'built-in': 'super throw new yield import export return spawn as <- -> + = - * /'
+ 'built-in': 'super supers throw new yield import export return spawn as <- -> + = - * /'
},
contains: [
{
@@ -1403,9 +1403,9 @@ <h2 id="classes">Classes</h2>
foo.pub_class_val //25
</code></pre>
-<h3 id="extends">extends</h3>
-<p>Classes can extend multiple classes. The order in which they extend those classes is important. When a subclass tries to call a superclass's property, Hydra checks the first Class after the <code>extends</code> keyword and then the second and then the third until it either finds the correct property or throws an error.</p>
-<h3 id="supers">super(s)</h3>
+<h3 id="extends">extends:</h3>
+<p>Classes can extend multiple classes. The order in which they extend those classes is important. When a subclass tries to access a superclass's property via <code>this.&lt;property&gt;</code>, Hydra checks the first Class after the <code>extends</code> keyword and then the second and then the third until it either finds the correct property or throws an error.</p>
+<h3 id="supers">super(s):</h3>
<p>The <code>super</code> keyword can be used to access the methods and variables of a class's superclasses. A superclasses constructor can be called one of three ways. The first is to use <code>super</code> similar to a namespace ie. <code>super.&lt;name of class&gt;(/* params... */)</code>. The second is to use the <code>supers()</code> function. This is for when a class inherits from more than one superclass. It takes a variable number of arrays, each containing the parameters to pass to its respective superclass constructor. Note that when using this method order matters. The last way is a simplified syntax for when you either only extend one superclass or you only want to call the constructor of the first superclass after the <code>extends</code> keyword. In this case the parameters are passed to <code>super</code> as a function call. If a superclass's constructor is not called, all of the variables that the constructor would have initialized are set to <code>null</code>.</p>
<pre><code class="hydra">
class A
@@ -1457,7 +1457,19 @@ <h3 id="supers">super(s)</h3>
class F extends A, B
F(){
- super(25)
+ //Wrong order
+ supers(
+ ['From F'],
+ [25]
+ )
+ }
+
+end
+
+class G extends A, B
+
+ G(){
+ super(30)
}
end
@@ -1474,8 +1486,12 @@ <h3 id="supers">super(s)</h3>
e.string //'In B From E'
var f = new F()
-f.num //25
-f.string //null
+f.num //'From F'
+f.string //'In B 25'
+
+var g = new G()
+g.num //30
+g.string //null
</code></pre>
<p>The <code>super</code> keyword can also be used to call a superclass's method directly. Again, <code>super</code> may be used similar to a namespace.</p>
@@ -1499,13 +1515,13 @@ <h3 id="supers">super(s)</h3>
Foo(){}
function bar(zero){
- if zero &lt; 0 {
+ if zero &lt; 0 then do
super.Base.error(&quot;wompppp...too small&quot;)
- } else if zero == 0 {
+ else if zero == 0 then do
print('shwweeeeet')
- } else {
+ else do
this.error('wompppp...too big')
- }
+ end
}
end
View
@@ -6,7 +6,7 @@ class Control
* 'do' always ends with 'end'
* 'run' always ends with '(p1, p2, p3){ //some func };'
*/
-
+
function new(){
this.num = 0;
this.map = {};
@@ -17,7 +17,7 @@ class Control
this.str2 = "str2";
this.regx = /\w*/;
this.file = open('myFile.txt');
- this.func = (param){
+ this.func = (param){
return param < 1;
};
}
@@ -51,20 +51,20 @@ class Control
var total_words_in_file = 0;
//default for in for files splits them as lines
- for line_num, line in this.file do
+ for line_num, line in this.file do
print('line: ' + line_num);
for word_num, word in line.split(/\s/) do //create an array of strings then loop through it
print('word: ' + word_num + ' of line ' + line_num + ' => ' + word);
total_words_in_file++;
end
end
-
+
print('total word count: ' + total_words_in_file);
}
generator function for_in(){ //for array
for i = 0; i < this.arr.length; i++ do
- yield i , this.arr[i];
+ yield i , this.arr[i];
end
// if you use a for in loop on this class it will act like its local arr
@@ -84,14 +84,14 @@ class Control
//i is i local to for loop
for var i = 0; i < this.arr.length; i++ do
- print('i: ' + i); //0
+ print('i: ' + i); //0
end
print(i); //'10'
//i is global i
for i = 0; i < this.arr.length; i++ do
- print('i: ' + i); //0
+ print('i: ' + i); //0
end
print(i); //1
@@ -117,7 +117,7 @@ class Control
//go from 0 to 14 by steps of 5
//*** can't violate bounds so 14 isn't given ***
from 0 to 14 by 5 run (i){
- print('i: ' + i); //0 5 10
+ print('i: ' + i); //0 5 10
}
//dynamic step value
@@ -141,7 +141,7 @@ class Control
//go from 0 to 14 by steps of 5
//*** can't violate bounds so 14 isn't given ***
0..14 by 5 run (i){
- print('i: ' + i); //0 5 10
+ print('i: ' + i); //0 5 10
}
//dynamic step value
@@ -152,6 +152,8 @@ class Control
}
function range_as_value(){
+ //make this a list comprehension
+ //ie [0..9]
var range;
range = from 0 to 10;
@@ -211,12 +213,15 @@ class Control
function given_is(){
given obj
- is String do
+ is String do
string_stuff(obj);
+ break;
is Array do
array_stuff(obj);
+ break;
is 0 or 2 do //allow to check for multiple cases
number_stuff(obj);
+ break;
else do
default();
end
@@ -227,21 +232,21 @@ class Control
while true do
wait_for
- either recvd, clsd << in_chan1 then do
- if clsd then
+ either recvd, clsd << in_chan1 then do
+ if clsd then
do_something();
- else
- out_chan << do_something(recvd);
+ else
+ out_chan << do_something(recvd);
end
- or recvd, clsd << in_chan2 then do
- if clsd then
+ or recvd, clsd << in_chan2 then do
+ if clsd then
break;
- else
- out_chan << do_something2(recvd);
+ else
+ out_chan << do_something2(recvd);
end
- or do
+ or do
default();
- break; //break is for while true
+ break; //break is for while true
end
end
end
@@ -255,11 +260,11 @@ class Control
a , closed << in_chan; //can check for closed
- if !closed do
+ if !closed do
print('channel not closed....gave me: ' + a);
else do
print('channel closed :(...cant use value');
- end
+ end
}
function closure_semantics(){
@@ -294,15 +299,15 @@ class Control
unquote_blk(specs)
end
end
-
+
macro it(name, spec) do
quote do
def unquote(binary_to_atom("#{name} spec"))() do // Note: this is generating a function on the module
unquote_blk(spec)
end
end
end
-
+
macro should_eq(value1, value2) do
quote do
if unquote(value1) != unquote(value2) then raise "some hell" end
@@ -311,11 +316,11 @@ class Control
//lets you right
describe "some test" do
- it 'compares two ints' do
+ it 'compares two ints' do
should_eq 30, 30
end
end
-
+
//with closures--------------------
//from to run
@@ -336,7 +341,7 @@ class Control
}
macro for(item) in(container, blk) do
- while unquote(item), done = unquote(container).for_in(); !done do
+ while unquote(item), done = unquote(container).for_in(); !done do
unquote_blk(blk)();
do
end
@@ -351,4 +356,4 @@ class Control
}
-end
+end
View
@@ -0,0 +1,81 @@
+import std.Emitter
+import ./gui_base.hy as Base
+
+export class Test extends Base, Emitter
+
+ Test(m){
+ supers()
+
+ @node_chan = <-5->
+ @mode = m
+ @_running = false
+
+ @on('window:ready', (){
+ @renderGUI()
+ })
+
+ }
+
+ function content(){
+ @div(null,'.someclass', '#someid', (c){
+ @div(c '.someclass2', '#someid2', (c){
+ @span(c '.text-highlight', 'categoryHeader')
+ @span(c '.text-info', 'categorySummary')
+ })
+ })
+ }
+
+ function afterAttatch(onDom){
+ if onDom then
+ @addTreeMap()
+ end
+ }
+
+ function renderGUI(){
+ spawn @createNodes()
+ @renderNodes()
+
+ @emit('gui:rendered')
+ }
+
+ function createNodes(){
+ var categories, category_start, category_name, category;
+
+ categories = {};
+
+ for event_name, details in @eventLog do
+ if @ignoredEvents.contains(event_name) then continue
+
+ category_start = event_name.indexOf(':');
+
+ if category_start is -1 then
+ category_name = 'uncategorized'
+ else
+ category_name = @humanizeEventName(event_name[0:category_start])
+ category = categories[category_name]
+ end
+
+ if !category == then
+ category = {
+ name: @humanizeEventName(category_name),
+ children: []
+ }
+
+ categories[category_name] = category;
+ end
+
+ category.children.push(@content)
+ category -> @node_chan
+ end
+
+ close(@node_chan)
+ }
+
+ function renderNodes(){
+ for node in @node_chan do
+ @render(node)
+ end
+ open(@node_chan)
+ }
+
+end
View
Binary file not shown.
View
@@ -0,0 +1,2 @@
+#set $GOPATH to the root of the directory
+export GOPATH=$PWD
View
Binary file not shown.
Binary file not shown.

0 comments on commit c2716fa

Please sign in to comment.