Are you blogging on PH? Get your free blog.
*/
*/

View ezasm\proc_parse.cpp

Ezasm for linux 1.0

Submitted By: acvivek
Rating: Not rated (Rate It)


#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "s.h"
extern symtab sy;
extern void parse(char *);
extern int loc_ctr;
extern int err_count;
extern int line_count;
int  splits(char a[])
{
        int i=0,l,j=0,z=0;
        char t[20];
        char c[10][10];
        l=strlen(a);
        while(i<l)
        {
                if(isalpha(a[i]) || isdigit(a[i]))
                {
                        t[j++]=a[i++];
                }
                else if(a[i]==' ')
                {
                        t[j]='\0';
                        j=0;
                        while(a[i]==' ') i++;
                        strcpy(c[z++],t);
                }
                else i++;
        }
        t[j]='\0';
        strcpy(c[z++],t);
        if(z==2 && strcmp(c[1],"proc")==0) return 1;
        return 0;
}
void proc_parse(char l[])
{
        static int p_flag=0;
        static int p_c=0;
        int i,z=0,j=0;
        int error=0;
        char tmp[30];
        char p[10][20];
        if(p_flag==0)
        {              
                        for(i=0;i<strlen(l);i++)
                        {
                                if(l[i]==' ')
                                {                            
                                        tmp[j]='\0';
                                        strcpy(p[z++],tmp);
                                        j=0;
                                }
                                else if(isalpha(l[i])) tmp[j++]=l[i];   
                                else error=1;
                        }
                        tmp[j]='\0';   
                        strcpy(p[z++],tmp);
                        p_flag=1;
                        if(p_c!=0) {printf("\nOpen Procedure (%d)",line_count);err_count++;}
                        p_c++;
                        if(error==1) {printf("\nSyntax error");return;}
                        if(z==2)
                        {
                                if(strcmp(p[1],"proc")==0)
                                {
                                        sy.insert(p[0],"0");
                                        loc_ctr++;                             
                                }
                        }
               
        }
        else
        {
                if(strcmp(l,"endp")==0) {p_flag=0;p_c--;if(p_c!=0) printf("\nOpen Procedure (%d) ",line_count);}
                else parse(l);
        }
}

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.
Resource Listings