c316790569 2010-11-21 kinaba: /** c316790569 2010-11-21 kinaba: * Authors: k.inaba c316790569 2010-11-21 kinaba: * License: NYSL 0.9982 http://www.kmonos.net/nysl/ c316790569 2010-11-21 kinaba: * c316790569 2010-11-21 kinaba: * Definition of constants related to the layers. c316790569 2010-11-21 kinaba: */ c316790569 2010-11-21 kinaba: module polemy.layer; c316790569 2010-11-21 kinaba: import polemy._common; c316790569 2010-11-21 kinaba: c316790569 2010-11-21 kinaba: /// Type for the layer ID c316790569 2010-11-21 kinaba: c316790569 2010-11-21 kinaba: alias string Layer; c316790569 2010-11-21 kinaba: c316790569 2010-11-21 kinaba: enum : Layer c316790569 2010-11-21 kinaba: { 6ac127ddd0 2010-11-23 kinaba: SystemLayer = "(system)", /// Predefined layer for internal data 6ac127ddd0 2010-11-23 kinaba: ValueLayer = "@value", /// Predefined layer for normal run b97bd4f713 2010-11-23 kinaba: MacroLayer = "@macro", /// Predefined layer for macro run (@lay() changes layer) b97bd4f713 2010-11-23 kinaba: RawMacroLayer = "(rawmacro)", /// Predefined layer for macro run (@lay() becomes AST) b97bd4f713 2010-11-23 kinaba: } b97bd4f713 2010-11-23 kinaba: 36c517dfc4 2010-11-23 kinaba: /// True if it is macro-like layer that basically generates syntax tree 36c517dfc4 2010-11-23 kinaba: b97bd4f713 2010-11-23 kinaba: bool isMacroishLayer( Layer lay ) b97bd4f713 2010-11-23 kinaba: { b97bd4f713 2010-11-23 kinaba: return lay==MacroLayer || lay==RawMacroLayer; b97bd4f713 2010-11-23 kinaba: } b97bd4f713 2010-11-23 kinaba: 5e924caac9 2010-11-23 kinaba: unittest 5e924caac9 2010-11-23 kinaba: { 5e924caac9 2010-11-23 kinaba: assert( !isMacroishLayer(SystemLayer) ); 5e924caac9 2010-11-23 kinaba: assert( !isMacroishLayer(ValueLayer) ); 5e924caac9 2010-11-23 kinaba: assert( isMacroishLayer(MacroLayer) ); 5e924caac9 2010-11-23 kinaba: assert( isMacroishLayer(RawMacroLayer) ); 5e924caac9 2010-11-23 kinaba: } 5e924caac9 2010-11-23 kinaba: 36c517dfc4 2010-11-23 kinaba: /// True if in the specified layer @lay(...) has no effect and merely produces a syntax tree 36c517dfc4 2010-11-23 kinaba: b97bd4f713 2010-11-23 kinaba: bool isNoLayerChangeLayer( Layer lay ) b97bd4f713 2010-11-23 kinaba: { b97bd4f713 2010-11-23 kinaba: return lay==RawMacroLayer; 5e924caac9 2010-11-23 kinaba: } 5e924caac9 2010-11-23 kinaba: 5e924caac9 2010-11-23 kinaba: unittest 5e924caac9 2010-11-23 kinaba: { 5e924caac9 2010-11-23 kinaba: assert( !isNoLayerChangeLayer(SystemLayer) ); 5e924caac9 2010-11-23 kinaba: assert( !isNoLayerChangeLayer(ValueLayer) ); 5e924caac9 2010-11-23 kinaba: assert( !isNoLayerChangeLayer(MacroLayer) ); 5e924caac9 2010-11-23 kinaba: assert( isNoLayerChangeLayer(RawMacroLayer) ); c316790569 2010-11-21 kinaba: }