473,225 Members | 1,621 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,225 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 6299

"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: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.