YACC

Discussion in 'C Programming' started by daniele.zurico@gmail.com, Mar 6, 2007.

  1. Guest

    Hello I've a big problem i search to parse an header file(C). I not
    know how to solve the problem in the line 3 for the $4.
    Someone can help me?

    /* STRUCT & UNION */
    struct_or_union_specifier
    : struct_or_union IDENTIFIER '{' struct_declaration_list '}'
    { printf("%d,%s,%s",$1->type,$2->word_name,$4???????????) }
    | struct_or_union '{' struct_declaration_list '}'
    | struct_or_union IDENTIFIER
    ;

    struct_or_union
    : STRUCT { $$=mktype(TSTRUCT); }
    | UNION { $$=mktype(TUNION); }
    ;

    struct_declaration_list
    : struct_declaration
    | struct_declaration_list struct_declaration
    ;

    struct_declaration
    : specifier_qualifier_list struct_declarator_list ';'
    ;

    specifier_qualifier_list
    : type_specifier specifier_qualifier_list
    | type_specifier
    ;

    struct_declarator_list
    : struct_declarator
    | struct_declarator_list ',' struct_declarator
    ;

    struct_declarator
    : declarator
    | ':' LNG
    | declarator ':' LNG
    ;

    declarator
    : pointer direct_declarator
    | direct_declarator
    ;

    pointer
    : '*'
    | '*' pointer
    ;

    direct_declarator
    : IDENTIFIER
    | '(' declarator ')'
    | direct_declarator '[' LNG ']'
    | direct_declarator '[' ']'
    | direct_declarator '(' parameter_list ')'
    | direct_declarator '(' identifier_list ')'
    | direct_declarator '(' ')'
    ;

    parameter_list
    : parameter_declaration
    | parameter_list ',' parameter_declaration
    ;

    identifier_list
    : IDENTIFIER
    | identifier_list ',' IDENTIFIER
    ;

    parameter_declaration
    : declaration_specifiers declarator
    | declaration_specifiers abstract_declarator
    | declaration_specifiers
    ;

    direct_abstract_declarator
    : '(' abstract_declarator ')'
    | '[' ']'
    | '[' LNG ']'
    | direct_abstract_declarator '[' ']'
    | direct_abstract_declarator '[' LNG ']'
    | '(' ')'
    | '(' parameter_list ')'
    | direct_abstract_declarator '(' ')'
    | direct_abstract_declarator '(' parameter_list ')'
    ;

    abstract_declarator
    : pointer
    | direct_abstract_declarator
    | pointer direct_abstract_declarator
    ;
     
    , Mar 6, 2007
    #1
    1. Advertising

  2. user923005 Guest

    You want news:comp.compilers
     
    user923005, Mar 6, 2007
    #2
    1. Advertising

  3. SM Ryan Guest

    wrote:
    # Hello I've a big problem i search to parse an header file(C). I not
    # know how to solve the problem in the line 3 for the $4.
    # Someone can help me?
    #
    # /* STRUCT & UNION */
    # struct_or_union_specifier
    # : struct_or_union IDENTIFIER '{' struct_declaration_list '}'
    # { printf("%d,%s,%s",$1->type,$2->word_name,$4???????????) }

    $4 is the value of struct_declaration_list, but

    # struct_declaration_list
    # : struct_declaration
    # | struct_declaration_list struct_declaration
    # ;

    you're not assigning $$ in struct_declaration_list.

    --
    SM Ryan http://www.rawbw.com/~wyrmwif/
    I have no respect for people with no shopping agenda.
     
    SM Ryan, Mar 7, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. exits funnel

    Parsing - YACC to java

    exits funnel, Jul 31, 2003, in forum: Java
    Replies:
    3
    Views:
    5,689
    exits funnel
    Jul 31, 2003
  2. Mike Wahler
    Replies:
    2
    Views:
    552
    John Harrison
    Jul 8, 2003
  3. John Harrison

    [OT] Re: problem : yacc v.s c++

    John Harrison, Aug 28, 2003, in forum: C++
    Replies:
    0
    Views:
    484
    John Harrison
    Aug 28, 2003
  4. Moonlit

    Best lex/yacc for C++?

    Moonlit, Oct 8, 2003, in forum: C++
    Replies:
    18
    Views:
    1,567
    Moonlit
    Oct 14, 2003
  5. Arthur T. Murray

    Re: Parsing English with lex and yacc

    Arthur T. Murray, Jan 23, 2004, in forum: C++
    Replies:
    5
    Views:
    1,397
    Amnon Meyers
    Jan 26, 2004
Loading...

Share This Page