Differences From Artifact [59dc790b72d21ee0]:
- File
polemy/layer.d
- 2010-11-23 10:37:54 - part of checkin [5e924caac9] on branch trunk - added AST-rewriting macro sample. (user: kinaba) [annotate]
To Artifact [bd983db748e0ad6a]:
- File
polemy/layer.d
- 2010-11-23 18:28:47 - part of checkin [ba11f1d551] on branch trunk - fixed the macro scoping rules concerning non-macro let (user: kinaba) [annotate]
13 13
14 enum : Layer 14 enum : Layer
15 { 15 {
16 SystemLayer = "(system)", /// Predefined layer for internal data 16 SystemLayer = "(system)", /// Predefined layer for internal data
17 ValueLayer = "@value", /// Predefined layer for normal run 17 ValueLayer = "@value", /// Predefined layer for normal run
18 MacroLayer = "@macro", /// Predefined layer for macro run (@lay() 18 MacroLayer = "@macro", /// Predefined layer for macro run (@lay()
19 RawMacroLayer = "(rawmacro)", /// Predefined layer for macro run (@lay() 19 RawMacroLayer = "(rawmacro)", /// Predefined layer for macro run (@lay()
> 20 AstLayer = "(ast)", /// Predefined layer for macro run (never
20 } 21 }
21 22
22 /// True if it is macro-like layer that basically generates syntax tree 23 /// True if it is macro-like layer that basically generates syntax tree
23 24
24 bool isMacroishLayer( Layer lay ) | 25 bool isASTLayer( Layer lay )
25 { 26 {
26 return lay==MacroLayer || lay==RawMacroLayer; | 27 return lay==MacroLayer || lay==RawMacroLayer || lay==AstLayer;
27 } 28 }
28 29
29 unittest 30 unittest
30 { 31 {
31 assert( !isMacroishLayer(SystemLayer) ); | 32 assert( !isASTLayer(SystemLayer) );
32 assert( !isMacroishLayer(ValueLayer) ); | 33 assert( !isASTLayer(ValueLayer) );
33 assert( isMacroishLayer(MacroLayer) ); | 34 assert( isASTLayer(MacroLayer) );
34 assert( isMacroishLayer(RawMacroLayer) ); | 35 assert( isASTLayer(RawMacroLayer) );
> 36 assert( isASTLayer(AstLayer) );
35 } 37 }
36 38
37 /// True if in the specified layer @lay(...) has no effect and merely produces a 39 /// True if in the specified layer @lay(...) has no effect and merely produces a
38 40
39 bool isNoLayerChangeLayer( Layer lay ) 41 bool isNoLayerChangeLayer( Layer lay )
40 { 42 {
41 return lay==RawMacroLayer; | 43 return lay==RawMacroLayer || lay==AstLayer;
42 } 44 }
43 45
44 unittest 46 unittest
45 { 47 {
46 assert( !isNoLayerChangeLayer(SystemLayer) ); 48 assert( !isNoLayerChangeLayer(SystemLayer) );
47 assert( !isNoLayerChangeLayer(ValueLayer) ); 49 assert( !isNoLayerChangeLayer(ValueLayer) );
48 assert( !isNoLayerChangeLayer(MacroLayer) ); 50 assert( !isNoLayerChangeLayer(MacroLayer) );
49 assert( isNoLayerChangeLayer(RawMacroLayer) ); 51 assert( isNoLayerChangeLayer(RawMacroLayer) );
> 52 assert( isNoLayerChangeLayer(AstLayer) );
> 53 }
> 54
> 55 /// True if do macro expanstion
> 56
> 57 bool isMacroLayer( Layer lay )
> 58 {
> 59 return lay==MacroLayer || lay==RawMacroLayer;
> 60 }
> 61
> 62 unittest
> 63 {
> 64 assert( !isMacroLayer(SystemLayer) );
> 65 assert( !isMacroLayer(ValueLayer) );
> 66 assert( isMacroLayer(MacroLayer) );
> 67 assert( isMacroLayer(RawMacroLayer) );
> 68 assert( !isMacroLayer(AstLayer) );
50 } 69 }