public override void ExitTypeSpecifier(CParser.TypeSpecifierContext context)
        {
            //atomicTypeSpecifier
            if (context.atomicTypeSpecifier() != null)
            {
                SematicError(context, "atomic types not supported");
            }
            //structOrUnionSpecifier
            else if (context.structOrUnionSpecifier() != null)
            {
                if (context.structOrUnionSpecifier().structOrUnion().GetText() == "union")
                {
                    SematicError(context, "unions not supported");
                }
                else if (context.structOrUnionSpecifier().structDeclarationList() != null)
                {
                    string idstring = context.structOrUnionSpecifier().Identifier() != null?context.structOrUnionSpecifier().Identifier().GetText() : null;

                    CDeclaration.EndStructDefinition(idstring);
                }
                else
                {
                    CDeclaration.PushStructDeclaration(context.structOrUnionSpecifier().Identifier().GetText());
                }
            }
            //enumSpecifier
            else if (context.enumSpecifier() != null)
            {
                if (context.enumSpecifier().enumeratorList() != null)
                {
                    string idString = context.enumSpecifier().Identifier() != null?context.enumSpecifier().Identifier().GetText() : null;

                    CDeclaration.EnumDefinition(idString, GetEnumeratorListCount(context.enumSpecifier().enumeratorList()));
                }
                else
                {
                    CDeclaration.PushEnumDeclaration(context.enumSpecifier().Identifier().GetText());
                }
            }
            //'__typeof__' '(' constantExpression ')' --- GCC extension not supported
            else if (context.constantExpression() != null)
            {
                SematicError(context, "gcc typeof not supported");
            }
            //else, a fundamental type
            else if (context.typedefName() != null)
            {
                CDeclaration.PushTypeDefName(context.GetText());
            }
            else
            {
                CDeclaration.PushTypeSpecifier(context.GetText());
            }
        }
Example #2
0
 public override void EnterTypeSpecifier([NotNull] CParser.TypeSpecifierContext context)
 {
     base.EnterTypeSpecifier(context);
     typeList.Add(context.GetText());
 }