My favorites
▼
|
Sign in
dao-language
Dao Language for Scripting and Computing
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
demo
/
macro
/
scoping_by_indentation.dao
r63
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#{
Indentation mark:
@x: where x=1,2,...,9,
tokens followed with the same indentation mark
must be aligned with the same indentation;
Indented code block:
$IBL prefixed variable matches a block of indented codes;
String literal from tokens:
Tokens expanded for patterns between a pair of \" or \',
are concatenated into a string literal enclosed in the
corresponding quotation mark. A space is inserted between
to consecutive identifer tokens.
#}
syntax{ # if : elif : else :
if @1 $EXP_1 : \[ $IBL_1 \]
\{ elif @1 $EXP_2 : \[ $IBL_2 \] \}
\[ else @1 : \[ $IBL_3 \] \]
}as{ # if(){}elif(){}else{}
if( 1 ){ # extra nesting to avoid the inside messing up with the outside
if( $EXP_1 ){ \[ $IBL_1 \] }
\{ elif( $EXP_2 ){ \[ $IBL_2 \] } \}
\[ else{ \[ $IBL_3 \] } \]
}
}
syntax{ # for in :
for $ID_1 in $EXP_1 \{ , $ID_2 in $EXP_2 \} : \[ $IBL_1 \]
}as{ # for( in ){}
for( $ID_1 in $EXP_1 \{ ; $ID_2 in $EXP_2 \} ){ \[ $IBL_1 \] }
io.writeln( \" \[ $IBL_1 \] \" )
}
a = 1
b = 0
if a == 0 :
io.writeln( 'python "if" works!' )
if b == 1 :
io.writeln( 'b =', b )
elif a == 1 :
io.writeln( 'python "if-elif" works!' )
if b == 0 :
io.writeln( 'b =', b )
list1 = { 1, 2, 3 }
list2 = { 'a', 'b', 'c' }
for x in list1:
io.writeln( x )
for y in list2:
io.writeln( y )
if y == 'b':
io.writeln( y )
for x in list1 , y in list2 :
io.writeln( x, y )
Show details
Hide details
Change log
r44
by phoolimin on Apr 24, 2010
Diff
Add: macro example for scoping by indentation;
Go to:
/trunk/demo/macro
...macro/scoping_by_indentation.dao
Project members,
sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 1427 bytes, 61 lines
View raw file
Powered by
Google Project Hosting