Esempio n. 1
0
        private LuaContainerType Pop()
        {
            var context = currentContext;

            currentContext = contextStack[contextStack.Count - 1];
            contextStack.RemoveAt(contextStack.Count - 1);
            // Determine outer container type
            switch (currentContext.ContainerType)
            {
            case LuaContainerType.None:
                Debug.Assert(contextStack.Count == 0);
                currentState = State.Start;
                break;

            case LuaContainerType.Table:
                currentState = context.ContainerType == LuaContainerType.Key
                        ? State.KeyEnd
                        : State.FieldStart;
                break;

            case LuaContainerType.Key:
                currentState = State.Key;
                break;

            default:
#if NETSTANDARD2_0
                Debug.Fail("Invalid ContainerType.");
#else
                Debug.Assert(false);
#endif
                break;
            }
            // Return the poped container type
            return(context.ContainerType);
        }
Esempio n. 2
0
        private LuaContainerType Pop()
        {
            var context = currentContext;

            currentContext = contextStack[contextStack.Count - 1];
            contextStack.RemoveAt(contextStack.Count - 1);
            // Determine outer container type
            switch (currentContext.ContainerType)
            {
            case LuaContainerType.None:
                Debug.Assert(contextStack.Count == 0);
                currentState = State.End;
                break;

            case LuaContainerType.Table:
                currentState = context.ContainerType == LuaContainerType.Key
                        ? State.KeyEnd
                        : State.FieldEnd;
                break;

            case LuaContainerType.Key:
                currentState = State.Key;
                break;

            default:
                Debug.Assert(false, "Invalid ContainerType.");
                break;
            }
            // Return the popped container type
            return(context.ContainerType);
        }
Esempio n. 3
0
 public LuaTableTextWriter(TextWriter writer)
 {
     Writer         = writer ?? throw new ArgumentNullException(nameof(writer));
     currentContext = new LuaContainerContext(LuaContainerType.None);
     contextStack   = new List <LuaContainerContext>();
     CloseWriter    = true;
     Indentation    = 2;
     IndentChar     = ' ';
 }
Esempio n. 4
0
 public LuaTableTextReader(TextReader reader)
 {
     Reader         = reader ?? throw new ArgumentNullException(nameof(reader));
     currentContext = new LuaContainerContext(LuaContainerType.None);
     contextStack   = new List <LuaContainerContext>();
     CloseReader    = true;
     buffer         = new char[1024];
     bufferPos      = 0;
     readerEof      = false;
 }
Esempio n. 5
0
        public static string ToString(IEnumerable <LuaContainerContext> stack, LuaContainerContext current)
        {
            var sb = new StringBuilder();

            foreach (var c in stack)
            {
                c.ToString(sb);
            }
            current.ToString(sb);
            return(sb.ToString());
        }
Esempio n. 6
0
 private void Push(LuaContainerType type)
 {
     contextStack.Add(currentContext);
     currentContext = new LuaContainerContext(type);
 }