LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-04-2014, 05:17 AM   #1
ANUUUU
LQ Newbie
 
Registered: Feb 2014
Posts: 5

Rep: Reputation: Disabled
Nest parsing of two files in fedora core..


I am trying to develop a compiler for a specific language. After generating the parser using bison i tried it with a program(.adb file),say A.adb.Within the compilation of A.adb,I called for compilation of B.ads(using system(./semantizer -dt <B.ads)).It worked.But the problem is: all variables used in B is added to symbol table during its compilation and was erased when it returned to A. I actually wanted all those symbols used in A and B after the compilation of A..What change shall I make to have thi..THANKS IN ADVANCE..

Last edited by ANUUUU; 02-04-2014 at 11:53 AM.
 
Old 02-04-2014, 08:18 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,986

Rep: Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447
if you are using "fedora core"
the VERY LAST ONE was "fedora core 6 "
and fedora 6 is 14 versions and 7 YEARS OUT OF DATE


so before you do anything
install fedora 20
 
Old 02-05-2014, 12:15 AM   #3
ANUUUU
LQ Newbie
 
Registered: Feb 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
how to execute only the grammar rule section of bison file during nested parsing in FC4

Quote:
Originally Posted by John VV View Post
if you are using "fedora core"
the VERY LAST ONE was "fedora core 6 "
and fedora 6 is 14 versions and 7 YEARS OUT OF DATE


so before you do anything
install fedora 20
I am trying to do for 32 bit compiler and my mam has asked me to do in FC4..I have tried in FC19 too .But it returns me error while trying to execute..Actually what i would like to know is is there any way to skip the prologue and bison declarations and execute only the grammar rules while i'm parsing a file from within the parsing of another..
 
Old 02-05-2014, 09:01 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
You can't use the system library function to do that. It doesn't share memory with the parent process as the system library function does:

1. forks a new process
2. execs a new executable (usually bash)
3. bash parses the parameter you gave to the system function
4. bash forks a new process...
5. the new bash execs the program identified in the parameter and passes any arguments

There is NO WAY that #5 entry can be part of the parent process and no way for it to add symbols to an internal data structure.

Now, if you are trying to create an "include file" handling, you must do that within the context of the first bison parser... and do the proper file handling/scanning switching for both scanner AND parser. Since it is now only one process, the symbol tables from the first scanner/parser can be shared with the second scanner/parser.

If you are attempting a "two level grammar" that is a different topic... but it is possible to do within a single grammar, though you will need a current Bison parser generator.

reference (this points to a lot of information):

http://www.gnu.org/software/bison/
 
1 members found this post helpful.
Old 02-05-2014, 11:50 AM   #5
ANUUUU
LQ Newbie
 
Registered: Feb 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jpollard View Post
You can't use the system library function to do that. It doesn't share memory with the parent process as the system library function does:

1. forks a new process
2. execs a new executable (usually bash)
3. bash parses the parameter you gave to the system function
4. bash forks a new process...
5. the new bash execs the program identified in the parameter and passes any arguments

There is NO WAY that #5 entry can be part of the parent process and no way for it to add symbols to an internal data structure.

Now, if you are trying to create an "include file" handling, you must do that within the context of the first bison parser... and do the proper file handling/scanning switching for both scanner AND parser. Since it is now only one process, the symbol tables from the first scanner/parser can be shared with the second scanner/parser.

If you are attempting a "two level grammar" that is a different topic... but it is possible to do within a single grammar, though you will need a current Bison parser generator.

reference (this points to a lot of information):

http://www.gnu.org/software/bison/





I'm doing a project to develop a compiler in fedoracore4.Bison is used to generate the parser.Language I'm concentrating is more or less similar to ada. The thing is that when another program is refernced from current program,i tried to compile the former from within the compilation of the former using system(command).It worked.But when the control returns, the symbol table entries corresponding to the already compiled program gets cleared.. Is there any way to keep the symbols as such until the whole compilation is completed?

the code is:

IDENTIFIER_TOK
{
if(trace)printf("COMPOUND NAME!!\n\n");
if (getcwd(path,sizeof(path))!=NULL)
strcat(path,"/");
strcat(path,$1.name);
strcat(path,".ads");
fp3=fopen(path,"r+");
if(!fp3)
{
ReportError(yyline,yycolumn);
printf("-------------------------NO SUCH FILE EXIST--%s.ads\n",$1.name);
}
sprintf(buf,"./semantizer -da <%s.ads",$1.name);
system(buf);
printf("-----------------CALL RETURNED________________\n\n");
display();

}
 
Old 02-05-2014, 12:59 PM   #6
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,986

Rep: Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447
there is no fedoracode4.bison

there is the antique version
"bison-2.0-6.i386.rpm " that was in the 8+ year out of date fedora4
( last updated on 20-May-2005 )

"bison-2.7-3.fc20.i686.rpm" That is in the current version

Code:
su -
rpm -qa | grep bison
will inform you as to what version was installed 9 years ago
 
1 members found this post helpful.
Old 02-05-2014, 01:57 PM   #7
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
Quote:
Originally Posted by ANUUUU View Post
I'm doing a project to develop a compiler in fedoracore4.Bison is used to generate the parser.Language I'm concentrating is more or less similar to ada. The thing is that when another program is refernced from current program,i tried to compile the former from within the compilation of the former using system(command).It worked.But when the control returns, the symbol table entries corresponding to the already compiled program gets cleared.. Is there any way to keep the symbols as such until the whole compilation is completed?

the code is:

IDENTIFIER_TOK
{
if(trace)printf("COMPOUND NAME!!\n\n");
if (getcwd(path,sizeof(path))!=NULL)
strcat(path,"/");
strcat(path,$1.name);
strcat(path,".ads");
fp3=fopen(path,"r+");
if(!fp3)
{
ReportError(yyline,yycolumn);
printf("-------------------------NO SUCH FILE EXIST--%s.ads\n",$1.name);
}
sprintf(buf,"./semantizer -da <%s.ads",$1.name);
system(buf);
printf("-----------------CALL RETURNED________________\n\n");
display();

}
No.
You need to learn how UNIX/Linux works.

http://www.tldp.org/LDP/tlk/tlk-toc.html

You also need to learn how to use Bison. Ada is a two level grammar, and Bison can handle it. It isn't simple (two level grammars are never simple), but it is possible.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] parsing with gnu-flex and bison fails for space and brace RudraB Programming 9 05-25-2013 06:41 PM
Yacc(Bison) Parameter Parsing -- Modifying a Scientific Programming Language! IncendiaryProgrammer Programming 3 06-23-2006 05:29 PM
perl files download instead of parsed on apache2 mod-perl2 not parsing perl files zeigerpuppy Debian 1 02-16-2006 06:31 AM
Conflict resolution when parsing with bison csikel Solaris / OpenSolaris 1 05-10-2005 10:45 AM
enumerate object symbols in symbol table jim mcnamara Linux - General 1 05-13-2002 09:10 PM


All times are GMT -5. The time now is 08:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration