473,388 Members | 1,326 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,388 software developers and data experts.

yacc

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[yyleng-2] !='"')
warning("Undeterminated Character strig",(char
*)0);
else
yylval.string[yyleng-2]='\0';
return qstring;}

I won't be able to compile it gives me
example.l: In function `yylex':
example.l:14: `yylval' undeclared (first use in this function)
example.l:14: (Each undeclared identifier is reported only once
example.l:14: for each function it appears in.)

as if the yacc library weren't been used.

How do I include then?

Thanks Profetas

Nov 14 '05 #1
4 6316

"Profetas" <xu*****@yahoo.com> wrote in message

I was wondering how can I access the yacc functions?
because when use a normal yacc function such as

example.l: In function `yylex':
example.l:14: `yylval' undeclared (first use in this function)

Yacc takes a parser specification and spits out compileable C source. yylval
is if I remember rightly a global variable inserted into the source, whilst
yylex() is the name of the function it generates for the lexical analyser.

You can add fragments of C to the yacc file and they will be incorporated
into the output. Somehow you must have got yacc into a state where yylval
isn't visble to yylex(). Remember to the C compiler this is just source.

How you've done this I couldn't say. You don't want to edit the yacc C
output. You need to look at your specification file to see what has gone
wrong, maybe making a toy parser that accesses in yylval in yylex() to see
if the same problem crops up.
Nov 14 '05 #2
>How you've done this I couldn't say. You don't want to edit the yacc C
output. You need to look at your specification file to see what has gone
wrong, maybe making a toy parser that accesses in yylval in yylex() to seeif the same problem crops up.


I am using a example given in a book, I think the problem is when I
compile the flexer using flex or lex it won't find its own library in the
book example they don't use any pre-process or something like that.
I guessed that the flex/lex would automatically identify its own library
but it may be my system that has wrong path thing like that.

Nov 14 '05 #3
Profetas wrote:

I guessed that the flex/lex would automatically identify its own library
but it may be my system that has wrong path thing like that.


IIRC, you need to link with the correct lib, libl for lex, and libfl for
flex:

cc file.c -o output -lfl

A good RTFM (man flex) helps.

[]s
--
..O. Cesar A. K. Grossmann ICQ UIN: 35659423
...O http://www.LinuxByGrossmann.cjb.net/
OOO Quidquid Latine dictum sit, altum viditur
Nov 14 '05 #4
>IIRC, you need to link with the correct lib, libl for lex, and libfl for
flex:
cc file.c -o output -lfl
A good RTFM (man flex) helps.


NO I found the problem, you probably don't know lex well
as yylval is a local union which I hadn't deffined.
Nov 14 '05 #5

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

Similar topics

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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.