Artifact ec0e00bb40d202e71ed3410bfb05b669aa83fb26
/**
* Authors: k.inaba
* License: NYSL 0.9982 http://www.kmonos.net/nysl/
*
* Definition of constants related to the layers.
*/
module polemy.layer;
import polemy._common;
/// Type for the layer ID
alias string Layer;
enum : Layer
{
SystemLayer = "(system)", /// Predefined layer for internal data
ValueLayer = "@value", /// Predefined layer for normal run
MacroLayer = "@macro", /// Predefined layer for macro run (@lay() changes layer)
RawMacroLayer = "(rawmacro)", /// Predefined layer for macro run (@lay() becomes AST)
AstLayer = "(ast)", /// Predefined layer for macro run (never invoke macro)
}
/// True if it is macro-like layer that basically generates syntax tree
bool isASTLayer( Layer lay )
{
return lay==MacroLayer || lay==RawMacroLayer || lay==AstLayer;
}
unittest
{
assert( !isASTLayer(SystemLayer) );
assert( !isASTLayer(ValueLayer) );
assert( isASTLayer(MacroLayer) );
assert( isASTLayer(RawMacroLayer) );
assert( isASTLayer(AstLayer) );
}
/// True if in the specified layer @lay(...) has no effect and merely produces a syntax tree
bool isNoLayerChangeLayer( Layer lay )
{
return lay==RawMacroLayer || lay==AstLayer;
}
unittest
{
assert( !isNoLayerChangeLayer(SystemLayer) );
assert( !isNoLayerChangeLayer(ValueLayer) );
assert( !isNoLayerChangeLayer(MacroLayer) );
assert( isNoLayerChangeLayer(RawMacroLayer) );
assert( isNoLayerChangeLayer(AstLayer) );
}
/// True if do macro expanstion
bool isMacroLayer( Layer lay )
{
return lay==MacroLayer || lay==RawMacroLayer;
}
unittest
{
assert( !isMacroLayer(SystemLayer) );
assert( !isMacroLayer(ValueLayer) );
assert( isMacroLayer(MacroLayer) );
assert( isMacroLayer(RawMacroLayer) );
assert( !isMacroLayer(AstLayer) );
}