function_t.c

 /********** Standard Predefined Macros **********/
class Func
{
    string function_name;
    int line_numb;
};

bool function_parse(string line_str,int line)
{
        bool flag = false;
        int i=0;
        string return_type,funct_name;
        while(i< line_str.length() && (line_str.at(i) != ' ' || line_str.at(i) != '\t' || line_str.at(i) != '\0'))
        {
            return_type += line_str.at(i);
            i++;
        }
        if(line_str.at(i) == '\0')
            return false;
        if(return_type == "int" || return_type == "void" || return_type == "float" || return_type == "unsigned" || return_type == "double" || return_type == "long")
            flag = true;

        if(flag == true)
        {

            while(i< line_str.length() && (line_str.at(i) != '('))
            {    
                funct_name += line_str.at(i);
                i++;
            }   
            if(line_str.at(i) = '\0')
                flag = false;

            if(line_str.at(i) = '(')
            { 
                function_name = funct_name;
                line_numb = line;
                flag = true;

            }

        }

}
/************** Parser *****************/

string_t* Parse_Argument(string_t line,string def_macro,int line_no,Bool noArgs)
{
    string_t tok_str;
    string_t st[50];
int i=0;
int last=0;
tok_str=tokenize(line, ',');
noArgs = FALSE;
if(tok_str == NULL)
{
noArgs = TRUE;
tok_str=tokenize(line, ')');
}
    while(tok_str != NULL)
    {
        //   if(is_id(tok_str," ",0))
        //   {
        if(last=locate(tok_str, ')' ) == -1)
        {  
        tok_str=tokenize(tok_str, ')');
        copy(st[i],tok_str);
            break;
        }
else
{
#ifdef DEBUG 
            printf("%s", tok_str->str);
#endif
            copy(st[i],tok_str);
}
       tok_str=tokenize(line+i, ',');
       i++;  
    }
#ifdef DEBUG    
    printf("Parse Argument Token: %s %d", c_string(tok_str), tok_str->len);
#endif 
    return st;   
}
string_t Parse_Macro_Body(string multiline, int line_no,int count_lines) // Parse body for macros
{
    string_t rep = string(" ");
string_t s;
    Bool flag = FALSE;
    // Multi-line macro function

    string_t orig_str = tokenize(multiline,"\n");
    if(is_at_end(orig_str,"\\") == FALSE)
        return "\0";
if(orig_str == NULL)
return "\0";
orig_str[orig_str->len- 1] = '\0';
prev_orig_str = copy(orig_str);
    while(is_at_end(orig_str,"\\") == TRUE)
    {
string_t orig_str = tokenize(multiline,"\n");
    if(orig_str == NULL)
  return prev_orig_str;
    orig_str[orig_str->len- 1] = '\0';
if(is_at_end(orig_str,"\\") == TRUE)
prev_orig_str = append(prev_orig_str,orig_str);
    }
    // inp[line_no].line_str = orig_str.c_str();
#if DEBUG
    printf("Entire string is :%s\n", prev_orig_str);
#endif 
   return Parse_Macro_Body  
}
Bool is_at_end(string_t str,string_t end)
{
    Bool flag= FALSE;
    for(int k= str->len - 1; k >= 0; k--)
    {
        if(at(str,k) == ' ')
        {

        } 
        else if(at(str,k) == end)
        {  
                flag = TRUE; 
                //str.replace(k-1,2,"");               // Hack for replacing '\' with "" str 
manipulate_n(str,"",k-1,2);  // Hack for replacing '\' with "" str 
                return flag;

        }
        else 
        {
            flag = FALSE;
            return flag;

        }

    }
    return flag;
}

Comments

Popular posts from this blog

VECPP.c

VECPP Windows.c

tuple_t Windows.h