Example #1
0
 public AmyDeclarator(AmyType type)
 {
     Type = type;
       Alias = string.Empty;
 }
Example #2
0
        private AmyType _Struct(CType storage)
        {
            string name = null;
              Token token = input.ReadToken();
              if (token.Type == (int)TokenType.Identifier) {
            name = "struct " + token.Litteral;
            token = input.ReadToken();
              }

              if (name == null)
            name = Anonyme();
              AmyType structure = new AmyType(storage, name);
              if (token.Type != (int)TokenType.OpenBraclet) {
            input.UnToken(token);
            return structure;
              }

              // Push structure scope
              //Console.WriteLine("_ PUSH Struct scope" + structure);
              for (; ; ) {
            token = input.ReadToken();
            input.UnToken(token);
            AmyType f = _TypeDeclaration(); // No storage/function spec allowed, STATIC_ASSERT is allowed^^
            if (f == null) {
              token = input.ReadToken();
              if (token.Type != (int)TokenType.CloseBraclet) {
            ErrorReport.Error("Unexepcted token");
              }

              break;
            }
            AmyDeclarator field = _Declarator(f);
            token = input.ReadToken();
            //if (token.Type == (int)TokenType.DoubleColon)
            // : <cst> (,)

            Console.WriteLine("Add param " + field + " to " + structure);

            if (token.Type == (int)TokenType.SemiColon)
              continue;

            ErrorReport.Error("Unexpected token");
            return structure;
              }
              //Console.WriteLine("_ POP Struct scope" + structure);
              // Pop structure scopde

              return structure;
        }
Example #3
0
        private AmyDeclarator _Declarator(AmyType type)
        {
            AmyDeclarator declarator = new AmyDeclarator(type);
              for (; ; ) {
            Token token = input.ReadToken();
            switch ((TokenType)token.Type) {
              case TokenType.Star:
            _Pointer(declarator);
            break;

              case TokenType.Identifier:
            declarator.Alias = token.Litteral;
            // Console.WriteLine("Declare " + declarator);
            _DeclaratorDeco(declarator);
            return declarator;

              case TokenType.OpenParenthesis:
            // FIXME What if there is no IDENTIFIER !?
            // FIXME avoid recursivity
            AmyDeclarator refer = _Declarator(type);
            token = input.ReadToken();
            if (token.Type != (int)TokenType.CloseParenthesis)
              ErrorReport.Error("Unexpected token");

            _DeclaratorDeco(refer);

            if (false) {
              // If type is unchanged
              // refer.PointerCount == 0 && refer,Paramters == 0
              return refer;
            } else {
              declarator.Alias = refer.Alias;
              refer.Alias = Anonyme();
              // CreateTypeWith refer (FunctionPointer!!)
              declarator.Type = declarator.Type.Refered(refer);
              return declarator;
            }

              case TokenType.OpenBraclet:
            input.UnToken(token);
            _DeclaratorDeco(declarator);
            return declarator;

              default:
            input.UnToken(token);
            return declarator;
            }
              }
        }
Example #4
0
        private AmyType _Enum(CType storage)
        {
            string name = null;
              Token token = input.ReadToken();
              if (token.Type == (int)TokenType.Identifier) {
            name = "enum " + token.Litteral;
            token = input.ReadToken();
              }

              if (name == null)
            name = Anonyme();
              AmyType enumeration = new AmyType(storage, name);
              if (token.Type != (int)TokenType.OpenBraclet) {
            input.UnToken(token);
            return enumeration;
              }

              for (; ; ) {
            token = input.ReadToken();
            if (token.Type == (int)TokenType.Comma)
              continue;

            if (token.Type == (int)TokenType.Identifier) {
              token = input.ReadToken();
              if (token.Type == (int)TokenType.OperatorAssign) {
              }
              // New Value
            }

            if (token.Type == (int)TokenType.CloseBraclet)
              break;
              }
              return enumeration;
        }
Example #5
0
 public AmyType Refered(AmyDeclarator decl)
 {
     AmyType at = new AmyType(this.Storage, decl.Alias);
       // FIXME
       return at;
 }