File Annotation
Not logged in
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)
ba11f1d551 2010-11-23        kinaba: 	AstLayer      = "(ast)",      /// Predefined layer for macro run (never invoke macro)
36c517dfc4 2010-11-23        kinaba: }
36c517dfc4 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: 
ba11f1d551 2010-11-23        kinaba: bool isASTLayer( Layer lay )
5e924caac9 2010-11-23        kinaba: {
ba11f1d551 2010-11-23        kinaba: 	return lay==MacroLayer || lay==RawMacroLayer || lay==AstLayer;
5e924caac9 2010-11-23        kinaba: }
5e924caac9 2010-11-23        kinaba: 
5e924caac9 2010-11-23        kinaba: unittest
36c517dfc4 2010-11-23        kinaba: {
ba11f1d551 2010-11-23        kinaba: 	assert( !isASTLayer(SystemLayer) );
ba11f1d551 2010-11-23        kinaba: 	assert( !isASTLayer(ValueLayer) );
ba11f1d551 2010-11-23        kinaba: 	assert( isASTLayer(MacroLayer) );
ba11f1d551 2010-11-23        kinaba: 	assert( isASTLayer(RawMacroLayer) );
ba11f1d551 2010-11-23        kinaba: 	assert( isASTLayer(AstLayer) );
36c517dfc4 2010-11-23        kinaba: }
36c517dfc4 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: 
36c517dfc4 2010-11-23        kinaba: bool isNoLayerChangeLayer( Layer lay )
36c517dfc4 2010-11-23        kinaba: {
ba11f1d551 2010-11-23        kinaba: 	return lay==RawMacroLayer || lay==AstLayer;
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) );
ba11f1d551 2010-11-23        kinaba: 	assert( isNoLayerChangeLayer(AstLayer) );
ba11f1d551 2010-11-23        kinaba: }
ba11f1d551 2010-11-23        kinaba: 
ba11f1d551 2010-11-23        kinaba: /// True if do macro expanstion
ba11f1d551 2010-11-23        kinaba: 
ba11f1d551 2010-11-23        kinaba: bool isMacroLayer( Layer lay )
ba11f1d551 2010-11-23        kinaba: {
ba11f1d551 2010-11-23        kinaba: 	return lay==MacroLayer || lay==RawMacroLayer;
ba11f1d551 2010-11-23        kinaba: }
ba11f1d551 2010-11-23        kinaba: 
ba11f1d551 2010-11-23        kinaba: unittest
ba11f1d551 2010-11-23        kinaba: {
ba11f1d551 2010-11-23        kinaba: 	assert( !isMacroLayer(SystemLayer) );
ba11f1d551 2010-11-23        kinaba: 	assert( !isMacroLayer(ValueLayer) );
ba11f1d551 2010-11-23        kinaba: 	assert( isMacroLayer(MacroLayer) );
ba11f1d551 2010-11-23        kinaba: 	assert( isMacroLayer(RawMacroLayer) );
ba11f1d551 2010-11-23        kinaba: 	assert( !isMacroLayer(AstLayer) );
c316790569 2010-11-21        kinaba: }