###############################################
# FILE: funcs
# SUBJ: comment
# AUTH: Kruthika
# CREATED: 2023-10-28 16:42:10
# MODIFIED:
###############################################

@DECL

CheckMore(L("var")) {
L("bar")=1;
    L("val")=pnnext(L("var"));
    L("val1")=pnnext(L("val"));
while(L("bar"))
{
    if(strequal(pnvar(L("val"),"$text"),".")&&strisalpha((pnvar(L("val1"),"$text"))))
    {
        L("bar")=1;
        pnmakevar(L("val"),"ispart",1);
        pnmakevar(L("val1"),"ispart",1);
        L("val")=pnnext(L("val1"));
    L("val1")=pnnext(L("val"));

    }
    else
    L("bar")=0;
    }

}
AddAttrs(L("node"))
{
    L("concept")=pnvar(L("node"),"con");
    addstrval(L("concept"),"local",pnvar(L("node"),"local"));
    if(pnvar(L("node"),"domainname"))
    addstrval(L("concept"),"domainname",pnvar(L("node"),"domainname"));
    if(pnvar(L("node"),"dn"))
    addstrval(L("concept"),"domainname",pnvar(L("node"),"dn"));
    if(pnvar(L("node"),"tld"))
    addstrval(L("concept"),"tld",pnvar(L("node"),"tld"));
    if(pnvar(L("node"),"cd"))
    addstrval(L("concept"),"cd",pnvar(L("node"),"cd"));
    if(pnvar(L("node"),"country"))
    addstrval(L("concept"),"country",pnvar(L("node"),"country"));
    
}
CheckPrev(L("node"))
{
    L("node")=pnprev(L("node"));
    while(L("node")&&(strequal(pnvar(L("node"),"$text"),"dot")||strequal(pnvar(L("node"),"$text"),"dot")||strisalpha((pnvar(L("node"),"$text")))||strisdigit((pnvar(L("node"),"$text")))))
    {
        "output.txt" << pnvar(L("node"),"$text") << "\n";
        pnmakevar(L("node"),"isprev",1);
        L("node")=pnprev(L("node"));
    }
}
CheckName(L("con"),L("out"))
{
    G("attrList") = findattrs(L("con"));

    while(nextattr(G("attrList")))
    {
        G("attrName") = attrname(G("attrList"));
         L("out") <<"\t\t\""<<G("attrName")<<"\":";
         G("valList") = attrvals(G("attrList"));
         G("valName") = getstrval(G("valList"));
                if(getstrval(G("valList"))){
                L("out") <<"\""<<getstrval(G("valList"))<<"\",\n";
                }
            G("attrList") = nextattr(G("attrList"));
            L("count")++;
    }
    G("attrName") = attrname(G("attrList"));
         L("out") <<"\t\t\""<<G("attrName")<<"\":";
         G("valList") = attrvals(G("attrList"));
         G("valName") = getstrval(G("valList"));
                if(getstrval(G("valList"))){
                L("out") <<"\""<<getstrval(G("valList"))<<"\"\n";
}
}
XMLOut(L("out")){
        L("out")<<"{\n\t\"email_address\""<<":   [\n";
     L("con") = down(G("email"));
         L("count")=0;
     while(next(L("con")))
     {  
         L("out")<<"\t\t{"<<"\n";
         L("out") <<"\t\t\""<<"emailadd-id"<<"\":"<<"\""+str(L("count"))+"\""+",\n";
CheckName(L("con"),L("out"));
 L("out")<<"\t},"<<"\n";
        L("con") = next(L("con"));
         L("count")++;
     }
     L("out")<<"\t\t{"<<"\n";
         L("out") <<"\t\t\""<<"emailadd-id"<<"\":"<<"\""+str(L("count"))+"\""+",\n";
CheckName(L("con"),L("out"));
 L("out")<<"\t}"<<"\n";
        L("con") = next(L("con"));
        L("out")<<"\t]\n}";

}
@@DECL