private static CTFAssignmentExpression Parse(CTFScope scope, TokParser tp)
        {
            CTFUnaryExpression cue = CTFUnaryExpression.Parse(tp);

            if (cue != null)
            {
                if (tp.Match(Token.EnumId.ASSIGNMENT))
                {
                    CTFUnaryExpression cue2 = CTFUnaryExpression.Parse(tp);
                    if (cue2 == null)
                    {
                        throw new CTFException();
                    }

                    return(new CTFAssignmentExpression(cue, cue2));
                }

                if (tp.Match(Token.EnumId.TYPE_ASSIGNMENT))
                {
                    CTFTypeSpecifier cs = CTFITypeSpecifier.ParseTypeSpecifier(scope, tp);
                    if (cs == null)
                    {
                        throw new CTFException();
                    }

                    return(new CTFAssignmentExpression(cue, cs));
                }
            }

            return(null);
        }
Пример #2
0
        internal static CTFITypeSpecifier Parse(CTFScope scope, TokParser tp)
        {
            if (!tp.Match(Token.EnumId.ENUM))
            {
                return(null);
            }

            tp.MustBe(Token.EnumId.COLON);

            List <CTFTypeSpecifier> cds = ParseList(scope, tp);

            tp.MustBe(Token.EnumId.LCURL);

            List <CTFEnumElem> list = new List <CTFEnumElem>();

            do
            {
                CTFEnumElem ce = CTFEnumElem.Parse(tp);
                list.Add(ce);
            }while (tp.Match(Token.EnumId.SEPARATOR));

            tp.MustBe(Token.EnumId.RCURL);

            return(new CTFEnumSpecifier(Token.EnumId.ENUM, cds, list));
        }
Пример #3
0
        internal static CTFEnumElem Parse(TokParser tp)
        {
            string name = tp.GetIden();

            tp.MustBe(Token.EnumId.ASSIGNMENT);
            CTFUnaryExpression first = CTFUnaryExpression.Parse(tp);
            CTFEnumElem        ce    = new CTFEnumElem(name, first.Calculate());

            if (tp.Match(Token.EnumId.ELIPSES))
            {
                ce.Second = CTFUnaryExpression.Parse(tp).Calculate();
            }

            return(ce);
        }
Пример #4
0
        internal static CTFTypeSpecifier Parse(CTFScope scope, TokParser tp)
        {
            string name = null;
            List <CTFStructOrVariantDeclaration> list = null;

            if (!tp.Match(Token.EnumId.STRUCT))
            {
                return(null);
            }

            if (tp.Token.Id == Token.EnumId.IDEN)
            {
                name = tp.Token.Buffer;
                tp.Next();
            }

            if (tp.Match(Token.EnumId.LCURL))
            {
                list = CTFStructOrVariantDeclaration.ParseList(scope, tp);
                tp.MustBe(Token.EnumId.RCURL);
            }

            int align = 0;

            if (tp.Match(Token.EnumId.ALIGN))
            {
                tp.MustBe(Token.EnumId.LPAREN);
                CTFUnaryExpression cue = CTFUnaryExpression.Parse(tp);
                tp.MustBe(Token.EnumId.RPAREN);
                align = cue.Calculate();
            }

            CTFType ct = CTFType.GetStructType(scope, name, list, align);

            return(new CTFStructSpecifier(ct));
        }