Thread: Complicated Declarations: dcl vs direct-dcl

  1. #1
    young grasshopper jwroblewski44's Avatar
    Join Date
    May 2012
    Location
    Where the sidewalk ends
    Posts
    294

    Complicated Declarations: dcl vs direct-dcl

    Hello all:
    Im trying to understand a program that parses declarations and outputs english-word descriptions. It would take a declarations such as:

    Code:
    int ( * fp )( );
    and this would have an output of: fp: pointer to function returning int.


    The book says that the program is "based on the grammar that specifies a declarator... In words, a dcl is a direct-dcl, perhaps preceded by *'s. A direct-dcl is a name, or a parenthesized dcl, or a direct-dcl followed by parentheses, or a direct-dcl followed by brackets with an optional size.
    This grammar can be used to parse declarations"

    When I read a declaration, I can understand what I'm seeing. But when I start reading about dcl's and direct-dcl's, I don't understand what they are talking about. Can someone please help clear up these terms for me?

    Also if you are aware of the dcl program I'm referring to, a walkthrough of the program logic would be nice.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form
    https://en.wikipedia.org/wiki/Syntax_diagram
    > But when I start reading about dcl's and direct-dcl's, I don't understand what they are talking about.
    They're just names attached to syntactic elements.

    It's like saying
    A string is a nul character or any other character followed by a string.
    <string> ::= '\0' | <non-null-char> <string>
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    young grasshopper jwroblewski44's Avatar
    Join Date
    May 2012
    Location
    Where the sidewalk ends
    Posts
    294
    Thanks for the fast response. Am I correct in saying that dcl means "declarator" and direct-dcl means "direct-declarator"?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > Am I correct in saying that dcl means "declarator" and direct-dcl means "direct-declarator"?
    Yes.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A bit more complicated problem
    By uural4792 in forum C Programming
    Replies: 4
    Last Post: 10-13-2011, 11:23 PM
  2. Probably way too complicated for me.
    By Necrofear in forum Windows Programming
    Replies: 3
    Last Post: 05-21-2006, 05:41 AM
  3. complicated
    By ZakkWylde969 in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 07-12-2003, 09:15 AM
  4. Nothing complicated, just...
    By SMurf in forum Windows Programming
    Replies: 1
    Last Post: 09-01-2002, 05:59 PM
  5. pretty complicated
    By soaponarope in forum C++ Programming
    Replies: 5
    Last Post: 08-31-2002, 03:21 PM