simulation of a processor
hi friends i faced a problem that is in the simulation of a processor my task is to print the purpose of each and every word and characters i mean
in that i want to explain as
but i am facing the problem at tokenizing the sentence in the line there is no delimiter between 'printf' and '('(opening brace) then how could i do that
thanks in advance waiting for ur replies
printf("hi is nani");in the above code it is a line of c program which is the input file to my program
in that i want to explain as
printf - it is used to print the statement between the quotationslike that my output would be.
( - opening brace
" - quotation mark
) - closing brace
but i am facing the problem at tokenizing the sentence in the line there is no delimiter between 'printf' and '('(opening brace) then how could i do that
thanks in advance waiting for ur replies
Replies
-
shalini_goel14
Sorry Raviteja, but i could not get you that why you need a delimiter to tokenize only printf and (. Is there any boundations that you have to do so only? Will your input file always consist of printf type statements followed by ( ?Raviteja.ghi friends i faced a problem that is in the simulation of a processor my task is to print the purpose of each and every word and characters i mean
printf("hi is nani");
in the above code it is a line of c program which is the input file to my program
in that i want to explain as
like that my output would be.
but i am facing the problem at tokenizing the sentence in the line there is no delimiter between 'printf' and '('(opening brace) then how could i do that
thanks in advance waiting for ur replies
If you can be more generic to your requirement, may be we can be of some help to you. 😀 -
Raviteja.gthe input file to mu program is a [dot]c file.
so it would definitely contain printf statements followed by ( .
and my program is to design a program which gives the output explaining each and every word with special characters included.
my program will be as follows:
import java.io.*;
import java.util.*;
import java.lang.*;
class cp
{
static StringTokenizer st;
public static void main(String args[])throws IOException
{
File f1=new File("input.dat");
FileReader fr=new FileReader(f1);
BufferedReader br=new BufferedReader(fr);
File f2=new File("con.txt");
FileReader fr1=new FileReader(f2);
BufferedReader br1=new BufferedReader(fr1);
String s[]={"#include","main","{","int",";","}"};
int i=0,j,p=0;
String a[ ]=new String [100];
String b[ ]=new String [100];
String c[ ]=new String [100];
do
{
a=br.readLine();
i++;
}while(a[i-1]!=null);
for(j=0;j<(i-1);j++)
{
st =new StringTokenizer(a[j]);
while(st.hasMoreTokens())
{
b[p]=st.nextToken( );
p++;
}
}
i=0;
do
{
c=br1.readLine();
i++;
}while(c[i-1]!=null);
for(i=0;i {
for(j=0;j<6;j++)
{
if(b.equals(s[j]))
{
System.out.println(c[j]);
if(j==3)
System.out.println(b[i+1]+" is a integer variable");
}
}
}
}
}
and the input file is
#include
the above wouldn't work with files more than three lines u can understand that and my problem is tokenizing the instruction line to strings for which delimiters are required
main {
int a ;
printf("hi is nani");
}
i think u can understand now
You are reading an archived discussion.
Related Posts
Hello guys, I have a problem with my quicktime and i am unable to export my files to the matlab format.( 8-bit (indexed or grayscale),16-bit grayscale or 24-bit (TrueColor) )....
CEans,
This is how a 'Crazy' Engineer folds a t-shirt. Awesome Video -
[youtube]fZKKrUXjzDY[/youtube]
What do you say? Do you have better ideas?
😁 This is Adam Smith. I am a Computer Engineering Graduate from America.
Hi,
I am making a robotics project. I am using shape memory alloy wires in place of motors. I need help with the electronics part as I have no idea...
CEans,
CE has associated with VNIT's Aarohi - Central India's Biggest Youth Cultural Event. 😀
Head over to Aarohi's official website: AAROHI 09 - Home
More to follow soon!