Ejemplo n.º 1
0
        public Extern Parse(TokenStream stream)
        {
            // Consume extern keyword.
            stream.Skip(TokenType.KeywordExternal);

            // Invoke the prototype parser.
            Prototype prototype = new PrototypeParser().Parse(stream);

            // Create the external definition entity using the parsed prototype.
            Extern external = new Extern(prototype);

            // Return the external definition entity.
            return(external);
        }
Ejemplo n.º 2
0
        public Function Parse(TokenStream stream)
        {
            // Parse the prototype from the stream, this captures the name, arguments and return type.
            Prototype prototype = new PrototypeParser().Parse(stream);

            // Create the function.
            var function = new Function();

            // Assign the function prototype to the parsed prototype.
            function.Prototype = prototype;

            // Parse the body.
            Block body = new BlockParser().Parse(stream);

            // Set the name of the body block.
            body.SetNameEntry();

            // Assign the body.
            function.Body = body;

            return(function);
        }
Ejemplo n.º 3
0
        public Function Parse(ParserContext context)
        {
            // Create the attribute buffer list.
            List <Attribute> attributes = new List <Attribute>();

            // Parse attribute if applicable.
            while (context.Stream.Current.Type == TokenType.SymbolBracketL)
            {
                // Invoke attribute parser.
                Attribute attribute = new AttributeParser().Parse(context);

                // Append the resulting attribute onto the buffer list.
                attributes.Add(attribute);
            }

            // Parse the prototype from the stream, this captures the name, arguments and return type.
            Prototype prototype = new PrototypeParser().Parse(context);

            // Create the function.
            Function function = new Function();

            // Assign the function attributes.
            function.Attributes = attributes.ToArray();

            // Assign the function prototype to the parsed prototype.
            function.Prototype = prototype;

            // Parse the body.
            Block body = new BlockParser().Parse(context);

            // Set the name of the body block.
            body.SetNameEntry();

            // Assign the body.
            function.Body = body;

            // Return the function.
            return(function);
        }
Ejemplo n.º 4
0
        public Extern Parse(ParserContext context)
        {
            // Ensure current token is extern keyword.
            context.Stream.EnsureCurrent(TokenType.KeywordExternal);

            // Skip extern keyword.
            context.Stream.Skip();

            // Invoke the prototype parser.
            Prototype prototype = new PrototypeParser().Parse(context);

            // Ensure current token is a semi-colon.
            context.Stream.EnsureCurrent(TokenType.SymbolSemiColon);

            // Skip semi-colon.
            context.Stream.Skip();

            // Create the external definition entity using the parsed prototype.
            Extern external = new Extern(prototype);

            // Return the external definition entity.
            return(external);
        }