assembly parser

I have to write a program that accepts a single argument, which is the name of a file. The file should contain a series of assembly-language instructions that form a short assembly-language computer program. My program should open and read this file, one line at a time. It must parse the data in the program and cout possible errors on the assembly code.(EX. Error on line 1: Missing third ",". Error on line 2: Extra data after instruction. Error on line 3: Expected Register for third OPERAND; saw “PC”.) How can i read the program line by line and parse it into my c++ program?
(We are not allowed to use string library.)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  int main(int argc, char** argv){
    int commaNum;
    ifstream open_file("FILENAME");
    int line;
    while(open_file.getline(line, 101)){
        istringstream sentence(line);
        char* words[4];
        for(int i = 0; i<4; i++){
            words[i] = new char[101];
        }
        
        for(int i = 0; i<4; i++){
            char* input_word = new char[101];
            sentence >> input_word;
            if(!str_cmp(input_word, ",")) {
                words[i] = input_word;
                --i;
     
                a++;
                continue;
                
            }
            if(!str_cmp(input_word, "#")) {
                words[i] = input_word;
                --i;
                commaNum++;
                break;
                
            }
}
Topic archived. No new replies allowed.