Beispiel #1
0
        /// <summary>
        /// Parse the name of a declaration (but not the assignment expression)
        /// </summary>
        public SyntaxDecl ParseBoxDeclarationName(string [] rejects)
        {
            // Accept "box", "in", "out", "bus", "bit", "int", etc.
            SyntaxDecl decl = new SyntaxDecl();

            decl.TypeName = mToken;
            Accept();

            if (mToken.Type != eTokenType.Identifier)
            {
                Reject("Expecting an identifier (the name of a box, parameter, or variable)", rejects);
                return(decl);
            }

            // Accept the identifier
            decl.VariableName = mToken;
            Accept();

            if (mTokenName == "[")
            {
                decl.ArraySizeExpr = ParseParen();
            }

            return(decl);
        }
Beispiel #2
0
        /// <summary>
        /// Parse a box declaration parameter
        /// </summary>
        public SyntaxDecl ParseBoxDeclarationParameter()
        {
            if (mTokenName != "in" && mTokenName != "out" && mTokenName != "bus")
            {
                Reject("Expecting in, out, or bus keyword", REJECT_PARAMETER);
                SyntaxDecl decl2 = new SyntaxDecl();
                return(decl2);
            }
            // Parse the declaration
            SyntaxDecl decl = ParseBoxDeclarationName(REJECT_PARAMETER);

            // Additional info for error
            if (mTokenName == "=")
            {
                Reject("Declaration parameters can not be assigned", REJECT_PARAMETER);
            }
            return(decl);
        }