Diff
Not logged in

Differences From Artifact [ec0e00bb40d202e7]:

To Artifact [70a85e9a66eddacd]:


13 13 14 14 enum : Layer 15 15 { 16 16 SystemLayer = "(system)", /// Predefined layer for internal data 17 17 ValueLayer = "@value", /// Predefined layer for normal run 18 18 MacroLayer = "@macro", /// Predefined layer for macro run (@lay() changes layer) 19 19 RawMacroLayer = "(rawmacro)", /// Predefined layer for macro run (@lay() becomes AST) 20 - AstLayer = "(ast)", /// Predefined layer for macro run (never invoke macro) 20 +} 21 + 22 +/// True if it is a user-defined layer 23 + 24 +bool isUserDefinedLayer( Layer lay ) 25 +{ 26 + return lay!=SystemLayer && lay!=ValueLayer && lay!=MacroLayer && lay!=RawMacroLayer; 27 +} 28 + 29 +unittest 30 +{ 31 + assert( !isUserDefinedLayer(SystemLayer) ); 32 + assert( !isUserDefinedLayer(ValueLayer) ); 33 + assert( !isUserDefinedLayer(MacroLayer) ); 34 + assert( !isUserDefinedLayer(RawMacroLayer) ); 35 + assert( isUserDefinedLayer("@foo") ); 21 36 } 22 37 23 38 /// True if it is macro-like layer that basically generates syntax tree 24 39 25 40 bool isASTLayer( Layer lay ) 26 41 { 27 - return lay==MacroLayer || lay==RawMacroLayer || lay==AstLayer; 42 + return lay==MacroLayer || lay==RawMacroLayer; 28 43 } 29 44 30 45 unittest 31 46 { 32 47 assert( !isASTLayer(SystemLayer) ); 33 48 assert( !isASTLayer(ValueLayer) ); 34 49 assert( isASTLayer(MacroLayer) ); 35 50 assert( isASTLayer(RawMacroLayer) ); 36 - assert( isASTLayer(AstLayer) ); 37 51 } 38 52 39 53 /// True if in the specified layer @lay(...) has no effect and merely produces a syntax tree 40 54 41 55 bool isNoLayerChangeLayer( Layer lay ) 42 56 { 43 - return lay==RawMacroLayer || lay==AstLayer; 57 + return lay==RawMacroLayer; 44 58 } 45 59 46 60 unittest 47 61 { 48 62 assert( !isNoLayerChangeLayer(SystemLayer) ); 49 63 assert( !isNoLayerChangeLayer(ValueLayer) ); 50 64 assert( !isNoLayerChangeLayer(MacroLayer) ); 51 65 assert( isNoLayerChangeLayer(RawMacroLayer) ); 52 - assert( isNoLayerChangeLayer(AstLayer) ); 53 66 } 54 67 55 68 /// True if do macro expanstion 56 69 57 70 bool isMacroLayer( Layer lay ) 58 71 { 59 72 return lay==MacroLayer || lay==RawMacroLayer; ................................................................................ 61 74 62 75 unittest 63 76 { 64 77 assert( !isMacroLayer(SystemLayer) ); 65 78 assert( !isMacroLayer(ValueLayer) ); 66 79 assert( isMacroLayer(MacroLayer) ); 67 80 assert( isMacroLayer(RawMacroLayer) ); 68 - assert( !isMacroLayer(AstLayer) ); 69 81 }