Artifact Content
Not logged in

Artifact 59dc790b72d21ee032d1d114b1aeed5a8975ff46


/**
 * 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)
}

/// True if it is macro-like layer that basically generates syntax tree

bool isMacroishLayer( Layer lay )
{
	return lay==MacroLayer || lay==RawMacroLayer;
}

unittest
{
	assert( !isMacroishLayer(SystemLayer) );
	assert( !isMacroishLayer(ValueLayer) );
	assert( isMacroishLayer(MacroLayer) );
	assert( isMacroishLayer(RawMacroLayer) );
}

/// True if in the specified layer @lay(...) has no effect and merely produces a syntax tree

bool isNoLayerChangeLayer( Layer lay )
{
	return lay==RawMacroLayer;
}

unittest
{
	assert( !isNoLayerChangeLayer(SystemLayer) );
	assert( !isNoLayerChangeLayer(ValueLayer) );
	assert( !isNoLayerChangeLayer(MacroLayer) );
	assert( isNoLayerChangeLayer(RawMacroLayer) );
}