Paste: control structure syntax for clay

Author: pruned
Mode: text
Date: Fri, 13 May 2011 21:05:26
Plain Text |
RULES:

  - brackets optional around root calls of statements
  - semicolon optional at the end too
  - newline before `foo: bar' is implicit comma
  - idented block after -> is a lambda value
  - after `foo:', -> is optional

CODE:

if bool
then:
    foo()
else:
    if foobar
    then:
        bar()
    else:
        baz()

switch n
case: 1 do:
    foo()
case: 2 do:
    bar()
defaultDo:
    baz()

var a = 0
while [a<10] do:
    a += 1
    doStuff(a)

forEach v do: x ->
    print(x)

FLAT EQUIVALENT:
 
if(bool, (#then:,[foo();]), (#else:, [if(foobar, (#then, [bar();]), (#else,[baz();]))]));

switch(n, (#case:, 1), (#do: [foo();]), (#case:, 2), (#do: [bar();]), (#defaultDo: [baz();]));

var a = 0; while([a<10], (#do:, [a+=1; doStuff(a);]));

forEach(v, (#do, [x -> print(x);]));

Annotation: with true keyword syntax

Author: pruned
Mode: text
Date: Tue, 7 Jun 2011 18:43:14
Plain Text |
RULES:
  - true keywords
  - semicolon optional at the end of statements
  - idented block after -> is a lambda value
  - after `foo:', -> is optional

CODE:

bool
then:
    foo()
else:
    foobar
    then:
        bar()
    else:
        baz()

n
case: 1 do:
    foo()
case: 2 do:
    bar()
default:
    baz()

var a = 0
[a<10] while:
    a += 1
    doStuff(a)

v each: x ->
    print(x)

FLAT EQUIVALENT:
 
#"then:else:"(bool, [foo();], [#"then:else:"(foobar, [bar();], [baz();])]);

#"case:do:case:do:default:"(n, 1, [foo();], 2, [bar();], [baz();]);

var a = 0; #"while:"([a<10], [a+=1; doStuff(a);]);

#"each:"(v, [x -> print(x);]);

New Annotation

Summary:
Author:
Mode:
Body: