Complicated Declarations: dcl vs direct-dcl

This is a discussion on Complicated Declarations: dcl vs direct-dcl within the C Programming forums, part of the General Programming Boards category; Hello all: Im trying to understand a program that parses declarations and outputs english-word descriptions. It would take a declarations ...

  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
    32,854
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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
    32,854
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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-14-2011, 12:23 AM
  2. Probably way too complicated for me.
    By Necrofear in forum Windows Programming
    Replies: 3
    Last Post: 05-21-2006, 06:41 AM
  3. complicated
    By ZakkWylde969 in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 07-12-2003, 10:15 AM
  4. Nothing complicated, just...
    By SMurf in forum Windows Programming
    Replies: 1
    Last Post: 09-01-2002, 06:59 PM
  5. pretty complicated
    By soaponarope in forum C++ Programming
    Replies: 5
    Last Post: 08-31-2002, 04:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21