Ejemplo n.º 1
0
 private void _Pointer(AmyDeclarator declarator)
 {
     CType qualifier = 0;
       bool ok = false;
       while (!ok) {
     Token token = input.ReadToken();
     switch ((TokenType)token.Type) {
       case TokenType.KeywordConst:
     qualifier |= CType.Const;
     break;
       case TokenType.KeywordRestrict:
     qualifier |= CType.Restrict;
     break;
       case TokenType.KeywordVolatile:
     qualifier |= CType.Volatile;
     break;
       //case TokenType.KeywordAtomic:
       //  qualifier |= CType.Atomic;
       //break;
       default:
     input.UnToken(token);
     ok = true;
     break;
     }
       }
       declarator.PushPointer(qualifier);
 }
Ejemplo n.º 2
0
        private void _DeclaratorDeco(AmyDeclarator declarator)
        {
            for (; ; ) {
            Token token = input.ReadToken();
            if (token.Type == (int)TokenType.OpenParenthesis) {
              for (; ; ) {
            // FIXME no storage
            AmyType type = _TypeDeclaration();
            if (type == null) {
              token = input.ReadToken();
              if (token.Type == (int)TokenType.Operator3Dot) {
                Console.WriteLine("Add unbounded param to " + declarator);
                token = input.ReadToken();
                if (token.Type != (int)TokenType.CloseParenthesis)
                  ErrorReport.Error("Unexpected");
                return;
              } else if (token.Type == (int)TokenType.CloseParenthesis)
                return;
              else {
                ErrorReport.Error("Unexpected");
              }
            }
            AmyDeclarator param = _Declarator(type);
            // param.Alias = token.Litteral;
            Console.WriteLine("Add param " + param + " to " + declarator);

            token = input.ReadToken();
            if (token.Type == (int)TokenType.CloseParenthesis)
              return;
            if (token.Type != (int)TokenType.Comma) {
              ErrorReport.Error("Unexpected");
              return;
            }
              }
            } else if (token.Type == (int)TokenType.OpenBraclet) {
              token = input.ReadToken();
              if (token.Type == (int)TokenType.CloseBraclet) {
            declarator.PushPointer(CType.Array);
              } else {
            while (token.Type != (int)TokenType.CloseBraclet)
              token = input.ReadToken();
            declarator.PushPointer(CType.Array);
            // FIXME read Array expression
              }
            } else {
              input.UnToken(token);
              return;
            }
              }
        }