示例#1
0
文件: Reader.cs 项目: jmclain/Nmp
		///////////////////////////////////////////////////////////////////////////

		//public Reader()
		//{
		//}


		///////////////////////////////////////////////////////////////////////////

		public Reader( GrandCentral gc, IBaseReader reader )
		{
			this.gc = gc;
			this.reader = reader;
		}
		///////////////////////////////////////////////////////////////////////////
		
		public MasterParseReader GetMasterParseReader( IBaseReader reader )
		{
			return new MasterParseReader( this, GetDirectoryStack(), reader );
		}
		///////////////////////////////////////////////////////////////////////////
		
		public ParseReader GetParseReader( IBaseReader reader, string context )
		{
			return new ParseReader( this, GetDirectoryStack(), reader, context );
		}
示例#4
0
		///////////////////////////////////////////////////////////////////////////
		
		//public void	SetSearchPath( string path )
		//{
		//	// ******
		//	//
		//	// clear current path set, split path at ';' and put
		//	// the non emtpy results into SearchPath
		//	//
		//	NmpStringList searchPaths = ThreadContext.SearchPaths;
		//	searchPaths.Clear();

		//	string [] a = path.Split( new char[] {';'} );
		//	
		//	foreach( string s in a ) {
		//		if( s.Length > 0 ) {
		//			searchPaths.Add( s );
		//		}
		//	}
		//}
		
		
		///////////////////////////////////////////////////////////////////////////
		
		public MasterParseReader( GrandCentral gc, NmpStack<string> dirStack, IBaseReader reader )
			:	base( gc, dirStack, reader, "Root source" )
		{
			this.BaseFileName = current.SourceName;
		}
示例#5
0
		public ParseReader( GrandCentral gc, NmpStack<string> dirStack, IBaseReader reader, string context )
		{
			this.gc = gc;
			this.dirStack = dirStack;
			Initialize( reader, string.IsNullOrEmpty(context) ? "no context" : context );
		}
示例#6
0
		///////////////////////////////////////////////////////////////////////////

		//public void IncludeFile( string fileNameIn )
		//{
		//	// ******
		//	string	text = null;
		//	string fileName = string.Empty;

		//	// ******
		//	if( null == (text = FileReader.ReadFile( fileNameIn, out fileName, null )) ) {
		//		ThreadContext.MacroError( "file not found \"{0}\"", fileNameIn );
		//		return;
		//	}

		//	// ******
		//	if( string.IsNullOrEmpty( text ) ) {
		//		//
		//		// empty file
		//		//
		//		return;
		//	}

		//	// ******
		//	int nInstances = includeFiles.Count( item => fileName == item.SourceName );
		//	if( nInstances >= 20 ) {
		//		ThreadContext.MacroError( "the file \"{0}\" is activly included {1} times, this exceeds the allowed limit, Nmp will terminate", fileName, nInstances );
		//	}

		//	// ******
		//	NewState( new Reader(new ParseStringReader( text, fileName)) );
		//}
		
		
		///////////////////////////////////////////////////////////////////////////
		
		//[DebuggerStepThrough]
		public void Initialize( IBaseReader reader, string context )
		{
			//
			// this is ugly
			//
			if( ! string.IsNullOrEmpty(reader.DefaultPath) ) {
				dirStack.Push( reader.DefaultPath );
				initializePushedDirectory = true;
			}

			// ******
			Context = context;
			PushbackCalled = false;

			// ******
			current = new Reader( gc, reader );
		}