Exemplo n.º 1
0
        public static FunnyType ReadType(this TokFlow flow)
        {
            var cur      = flow.Current;
            var readType = ToFunnyType(cur);

            flow.MoveNext();
            var lastPosition = cur.Finish;

            while (flow.IsCurrent(TokType.ArrOBr))
            {
                if (flow.Current.Start != lastPosition)
                {
                    throw FunParseException.ErrorStubToDo("unexpected space before []");
                }

                flow.MoveNext();
                lastPosition = flow.Current.Finish;
                if (!flow.MoveIf(TokType.ArrCBr))
                {
                    throw ErrorFactory.ArrTypeCbrMissed(new Interval(cur.Start, flow.Current.Start));
                }
                readType = FunnyType.ArrayOf(readType);
            }

            return(readType);
        }
Exemplo n.º 2
0
 public static bool MoveIf(this TokFlow flow, TokType tokType)
 {
     if (flow.IsCurrent(tokType))
     {
         flow.MoveNext();
         return(true);
     }
     return(false);
 }
Exemplo n.º 3
0
        public static bool MoveIf(this TokFlow flow, TokType tokType, out Tok tok)
        {
            if (flow.IsCurrent(tokType))
            {
                tok = flow.Current;
                flow.MoveNext();
                return(true);
            }

            tok = null;
            return(false);
        }
Exemplo n.º 4
0
        public static VarAttribute[] ReadAttributes(this TokFlow flow)
        {
            var attributes = new VarAttribute[0];

            if (!flow.IsCurrent(TokType.MetaInfo))
            {
                return(attributes);
            }

            bool newLine = flow.IsStart || flow.Previous.Is(TokType.NewLine);
            var  ans     = new List <VarAttribute>();

            while (flow.IsCurrent(TokType.MetaInfo))
            {
                if (!newLine)
                {
                    throw ErrorFactory.NowNewLineBeforeAttribute(flow);
                }

                ans.Add(ReadAttributeOrThrow(flow));
                flow.SkipNewLines();
            }
            return(ans.ToArray());
        }
Exemplo n.º 5
0
 public static bool IsDoneOrEof(this TokFlow flow)
 => flow.IsDone || flow.IsCurrent(TokType.Eof);