473,405 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

YACC

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 '07 #1
2 1899
You want news:comp.compilers

Mar 6 '07 #2
da************@gmail.com 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.
Mar 7 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Profetas | last post by:
Hi. I was wondering how can I access the yacc functions? because when use a normal yacc function such as qstring { yylval.string = strdup(yytext+1); if(yylval.string !='"')...
4
by: Rodrick Brown | last post by:
This might be off topic but can someone give me a quick run down on why tools like lexx/yacc/bison are usefull ? I know what there used for but not sure when they should be used and where ? ...
6
by: Volker Hetzer | last post by:
Hi! We are finding ourselves in a situation where we have to parse several more or less free format text files. In the past, on linux, we had flex and bison for generating very fast parsers for...
1
by: deepusrp | last post by:
Helo everyone, i am doing a project on some graphic tool using qt as the front end. i am using lex and yacc as parser. now i am facing a problem since yacc generates only c code as i want to...
13
by: Berk Birand | last post by:
Hi, I am working on a school project where we use lex/yacc to write a compiler for a fictional (Java-like) language. I have handled all the details about the yacc and lex files, but I still have...
2
by: max.giacometti | last post by:
Hi everybody! I am using lex and yacc to write a vhdl to systemc converter. Lex simply reads the input file and yacc implements grammar and translation. I'd like to be able to make yacc...
2
by: Mohitz | last post by:
Hi Guys, I am facing a peculiar problem with my yacc script. Following is the snippet of the yacc script that i am using. I am using lex as the lexical analyzer. Sample Input :
1
by: neena.usenet | last post by:
I have a gui that reads in a file using C++/yacc. If the file has a parsing error, yacc throws the error to my program and I report it. The problem is at that point, I would like to try to open...
5
by: thomas | last post by:
hello I m writing a simple parser using bison. I just used someone's else c++ grammar, to produce a code beutifier. The thing is , most of the actions for productions would have form {$$ = $1 + $2...
1
by: Robert | last post by:
If the goal is to take a 1-dimensional package of text and produce a tree data structure that is easy to understand and manipulate, and then write C/C++ code that works with that tree - does...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.