using System.Collections.Generic; namespace NTERA.EmuEra.Game.EraEmu.Sub { /// /// 字句解析結果の保存場所。Listとその現在位置を結びつけるためのもの。 /// 基本的に全てpublicで /// internal sealed class WordCollection { public List Collection = new List(); public int Pointer; private static Word nullToken = new NullWord(); public void Add(Word token) { Collection.Add(token); } public void Add(WordCollection wc) { Collection.AddRange(wc.Collection); } public void Clear() { Collection.Clear(); } public void ShiftNext() { Pointer++; } public Word Current { get { if (Pointer >= Collection.Count) return nullToken; return Collection[Pointer]; } } public bool EOL => Pointer >= Collection.Count; public void Insert(Word w) { Collection.Insert(Pointer, w); } public void InsertRange(WordCollection wc) { Collection.InsertRange(Pointer, wc.Collection); } public void Remove() { Collection.RemoveAt(Pointer); } public void SetIsMacro() { foreach(Word word in Collection) { word.SetIsMacro(); } } public WordCollection Clone() { WordCollection ret = new WordCollection(); for(int i = 0;i < Collection.Count;i++) { ret.Collection.Add(Collection[i]); } return ret; } public WordCollection Clone(int start, int count) { WordCollection ret = new WordCollection(); if (start > Collection.Count) return ret; int end = start + count; if (end > Collection.Count) end = Collection.Count; for(int i = start;i < end;i++) { ret.Collection.Add(Collection[i]); } return ret; } } }