Annotation of researchv10no/cmd/style/end.l, revision 1.1

1.1     ! root        1: %{
        !             2: #include <stdio.h>
        !             3: #include <ctype.h>
        !             4: #include "names.h"
        !             5: #include "ehash.c"
        !             6: #include "edict.c"
        !             7: #define OUT1(c) putchar(c); putchar(':'); for(i=yyleng-1;i>=0;)putchar(yytext[i--])
        !             8: #define POUT1(c) putchar(c); putchar(':'); for(i=yyleng-1;i>0;)putchar(yytext[i--])
        !             9: int i;
        !            10: int nomin = 0;
        !            11: int NOCAPS = 0;                /*if set, all caps mapped to lower, plurals stripped*/
        !            12: %}
        !            13: 
        !            14: C      [A-Z0-9a-z",;]
        !            15: L      [a-zA-Z-]
        !            16: 
        !            17: %%
        !            18: ^{C}:.+        {
        !            19:        ECHO;
        !            20:        }
        !            21: ^ci.+  {
        !            22:        look(ic,2,ADJ);
        !            23:        }
        !            24: ^de.+  {
        !            25:        look(ed,2,ED);
        !            26:        }
        !            27: ^draw.+        {
        !            28:        if(yytext[5] == 'E'){
        !            29:                OUT1(NOUN_ADJ);
        !            30:        }
        !            31:        OUT1(ADJ_ADV);
        !            32:        }
        !            33: ^eca.+ {
        !            34:        look(ace,3,NOUN_VERB);
        !            35:        }
        !            36: ^eci.+ {
        !            37:        look(ice,3,NOUN_VERB);
        !            38:        }
        !            39: ^ecne.+        {
        !            40:        if(look(ence,4,NOM))nomin++;
        !            41:        }
        !            42: ^ecna.+        {
        !            43:        if(look(ance,4,NOM))nomin++;
        !            44:        }
        !            45: ^ee.+  {
        !            46:        look(ee,2,NOUN);
        !            47:        }
        !            48: ^ega.+ {
        !            49:        look(age,3,NOUN);
        !            50:        }
        !            51: ^elba.+        {
        !            52:        look(able,4,ADJ);
        !            53:        }
        !            54: ^elbi.+        {
        !            55:        look(ible,4,ADJ);
        !            56:        }
        !            57: ^elc.+ {
        !            58:        look(cle,3,NOUN);
        !            59:        }
        !            60: ^eru.+ {
        !            61:        look(ure,3,NOUN);
        !            62:        }
        !            63: ^eti.+ {
        !            64:        look(ite,3,NOUN);
        !            65:        }
        !            66: ^evi.+ {
        !            67:        look(ive,3,ADJ);
        !            68:        }
        !            69: ^ezi.+ {
        !            70:        look(ize,3,VERB);
        !            71:        }
        !            72: ^gni.+ {
        !            73:        look(ing,3,ING);
        !            74:        }
        !            75: ^hsi.+ {
        !            76:        look(ish,3,ADJ);
        !            77:        }
        !            78: ^lac.+ {
        !            79:        look(cal,3,ADJ);
        !            80:        }
        !            81: ^lanoi.+       {
        !            82:        look(ional,5,ADJ);
        !            83:        }
        !            84: ^luf.+ {
        !            85:        look(ful,3,ADJ);
        !            86:        }
        !            87: ^msi.+ {
        !            88:        OUT1(NOUN);
        !            89:        }
        !            90: ^nam.* {
        !            91:        look(man,3,NOUN);
        !            92:        }
        !            93: ^nem.* {
        !            94:        OUT1(NV_PL);
        !            95:        }
        !            96: ^noi.+ {
        !            97:        if(look(ion,3,NOM))nomin++;
        !            98:        }
        !            99: ^pihs.+        {
        !           100:        look(ship,4,NOUN);
        !           101:        }
        !           102: ^ral.+ {
        !           103:        look(lar,3,ADJ);
        !           104:        }
        !           105: ^ronoh {
        !           106:        OUT1(NOUN_VERB);
        !           107:        }
        !           108: ^ro.+  {
        !           109:        OUT1(NOUN);
        !           110:        }
        !           111: ^si.+  {
        !           112:        look(is,2,NOUN);
        !           113:        }
        !           114: ^ssel.+        {
        !           115:        look(less,4,ADJ);
        !           116:        }
        !           117: ^ssen.+        {
        !           118:        look(ness,4,NOUN);
        !           119:        }
        !           120: ^sse.+ {
        !           121:        look(ess,3,NOUN);
        !           122:        }
        !           123: ^ss.+  {
        !           124:        look(ss,2,NOUN);
        !           125:        }
        !           126: ^suo.+ {
        !           127:        look(ous,3,ADJ);
        !           128:        }
        !           129: ^su.+  {
        !           130:        look(us,2,NOUN);
        !           131:        }
        !           132: ^snoi.+        {
        !           133:        if(look(ion,4,PNOUN))nomin++;
        !           134:        }
        !           135: ^stnem.+       {
        !           136:                if(look(ment,5,PNOUN))nomin++;
        !           137:                }
        !           138: ^secne.+       {
        !           139:                if(look(ence,5,PNOUN))nomin++;
        !           140:                }
        !           141: ^secna.+       {
        !           142:                if(look(ance,5,PNOUN))nomin++;
        !           143:                }
        !           144: ^s.+   {
        !           145:        if(isupper(yytext[yyleng-1])){
        !           146:                if(NOCAPS){
        !           147:                        yytext[yyleng-1] = tolower(yytext[yyleng-1]);
        !           148:                        POUT1(PNOUN);
        !           149:                }
        !           150:                else { OUT1(PNOUN); }
        !           151:        }
        !           152:        else {
        !           153:                if(NOCAPS){POUT1(NV_PL);}
        !           154:                else{ OUT1(NV_PL); }
        !           155:        }
        !           156:        }
        !           157: ^tna.+ {
        !           158:        look(ant,3,NOUN_ADJ);
        !           159:        }
        !           160: ^tnem.+        {
        !           161:        if(look(ment,4,NOM))nomin++;
        !           162:        }
        !           163: ^tse.+ {
        !           164:        look(est,3,ADJ);
        !           165:        }
        !           166: ^tsi.+ {
        !           167:        look(ist,3,NOUN);
        !           168:        }
        !           169: [,\n]  {
        !           170:        putchar(yytext[0]);
        !           171:        }
        !           172: {L}+   {
        !           173:        if(isupper(yytext[yyleng-1])){
        !           174:                if(NOCAPS)
        !           175:                        yytext[yyleng-1] = tolower(yytext[yyleng-1]);
        !           176:                if((yytext[0] == 'n' || yytext[0] == 'l') && yytext[1] == 'a'){
        !           177:                        OUT1(NOUN_ADJ);
        !           178:                }
        !           179:                else {
        !           180:                        OUT1(NOUN);
        !           181:                }
        !           182:        }
        !           183:        else {
        !           184:                OUT1(UNK);
        !           185:        }
        !           186:        }
        !           187: ^:[\n] {
        !           188:        egetd();
        !           189:        }
        !           190: ^:.+[\n]       {
        !           191:        printf("%s",yytext);
        !           192:        }
        !           193: %%
        !           194: look(f,n,nc)
        !           195: char (*f)();
        !           196: int n;
        !           197: char nc;
        !           198: {
        !           199:        int in,nn,ret;
        !           200:        char sch;
        !           201:        in=0;
        !           202:        sch=yytext[yyleng-1];
        !           203:        if(isupper(sch)){
        !           204:                yytext[yyleng-1] = tolower(sch);
        !           205:                in=1;
        !           206:        }
        !           207:        if((*f)(&yytext[n],1,0) != 0){
        !           208:                nn = (*f)(&yytext[n],1,0);
        !           209:                if(nc == PNOUN)
        !           210:                        if(nn == NOUN_VERB){
        !           211:                                if(in == 1)nn=PNOUN;
        !           212:                                else nn=NV_PL;
        !           213:                        }
        !           214:                ret = 0;
        !           215:        }
        !           216:        else {
        !           217:                nn = nc;
        !           218:                ret = 1;
        !           219:        }
        !           220:        if(in==1){
        !           221:                if(nn == NOUN_VERB)nn=NOUN;
        !           222:                if(!NOCAPS)yytext[yyleng-1]=sch;        
        !           223:        }
        !           224:        if(nn==PNOUN && yytext[0] == 's' && NOCAPS){
        !           225:                POUT1(nn);
        !           226:        }
        !           227:        else {
        !           228:                OUT1(nn);
        !           229:        }
        !           230:        return(ret);
        !           231: }
        !           232: yywrap(){
        !           233:        printf(";%d\n",nomin);
        !           234:        return(1);
        !           235: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.