private SourceStruct m_lastStruct = null; // used to remember last structure created for use in linking more public SourceFile(FileRef filepath, Type type) : base(filepath.Filename, TokenRef.Type.Non) { Debug.Assert(type != Type.Null, "Cannot be of Type.Null"); Filepath = filepath; OfType = type; SourceStruct = null; }
public void LinkNext(SourceStruct srcStruct) { if (Next == null) { Next = srcStruct; } else { Next.LinkNext(srcStruct); // find the current end of the list } }
public static SourceStruct Build(SourceFile srcFile) { SourceObject start = srcFile.Sequence; // the start object in a sequence of Struct objects to process SourceObject next = start; // the next object to process SourceStruct first = null; // the 1st struct built upon this call SourceStruct previous, build = null; ParseResponse response = NextStateFunc.GoToNextState(next); do { } while (response != ParseResponse.Null); return(first); }
/// <summary>Build the SourceStruct using the SoucreObject sequence from a SourceFile</summary> /// <param name="lastSrcStruct">Ref: loaded with the last SourceStruct created previously or null if none. Gets set to the last created this call</param> /// <param name="srcFile">The SourceFile to use for building the SourceStruct from</param> /// <returns>The 1st SourceStruct created by this call ...</returns> internal SourceStruct Build(ref SourceStruct lastSrcStruct, SourceFile srcFile) { BuildInstr instr = BuildInstr.Continue; // continue until a struct is identified SourceObject start = srcFile.Sequence; // the start object in a sequence of Struct objects to process SourceObject next = start; // the next object to process SourceStruct first = null; // the 1st struct built upon this call SourceStruct previous, build = null; NextStateFunc.BeginParse(); while (next != null) { ParseResponse response = NextStateFunc.GoToNextState(next); switch (response) { case ParseResponse.Accept: if (first == null) { first = build; } break; case ParseResponse.Resume: break; case ParseResponse.Next: case ParseResponse.Call: next = next.Sequence; break; default: throw new InvalidEnumValueException(typeof(ParseResponse), response); } } // TODO: add check for source file completion, i.e. nothing left on the stack return(first); }
public virtual void SetChild(SourceStruct srcStruct) { throw new InvalidOperationException($"Can't set child for a 'SourceStruct Object -must be a SourceContainer!\nThis object: {this}, of type: {OfType.ToString()}"); }
public void AddStruct(SourceStruct sourceStruct) { m_lastStruct.LinkNext(sourceStruct); m_lastStruct = sourceStruct; }