LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Nest parsing of two files in fedora core.. (https://www.linuxquestions.org/questions/linux-newbie-8/nest-parsing-of-two-files-in-fedora-core-4175493658/)

ANUUUU 02-04-2014 04:17 AM

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..

John VV 02-04-2014 07:18 PM

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

ANUUUU 02-04-2014 11:15 PM

how to execute only the grammar rule section of bison file during nested parsing in FC4
 
Quote:

Originally Posted by John VV (Post 5111650)
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..

jpollard 02-05-2014 08:01 AM

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/

ANUUUU 02-05-2014 10:50 AM

Quote:

Originally Posted by jpollard (Post 5111994)
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();

}

John VV 02-05-2014 11:59 AM

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

jpollard 02-05-2014 12:57 PM

Quote:

Originally Posted by ANUUUU (Post 5112120)
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.


All times are GMT -5. The time now is 04:12 AM.