Annotation of researchv10dc/cmd/wwb/org.l, revision 1.1

1.1     ! root        1: %{
        !             2: /* NOTICE-NOT TO BE DISCLOSED OUTSIDE BELL SYS EXCEPT UNDER WRITTEN AGRMT */
        !             3: /* Writer's Workbench version 2.0, January 1981 */
        !             4:                /* flag=0 means processing is in middle of sentence, */
        !             5: /*                flag=1 means have just finished a sentence, */
        !             6: /*                flag=2 means should print current sentence at its end */
        !             7: #define MAXCHARS 1000
        !             8: #define STORE if (ptr+yyleng >= str+MAXCHARS) ptr=str;  for(i=0;i<yyleng; ++i) *ptr++=yytext[i]
        !             9:  char *ptr,str[MAXCHARS];
        !            10: %}
        !            11: %START IN OUT 
        !            12: B      [\t \n]
        !            13: BP     [\t \n()"]
        !            14: U      [A-Z]
        !            15: A      [a-zA-Z]
        !            16: N      [0-9]
        !            17: %%
        !            18:  int i,flag,begin,in, eqn;
        !            19:  in=begin=eqn=0;
        !            20:  flag=1;
        !            21:  ptr= str;
        !            22:  BEGIN OUT;
        !            23: 
        !            24: ^"."DS.*\n     |
        !            25: ^"."AL.*\n     |
        !            26: ^"."BL.*\n     |
        !            27: ^"."VL.*\n     |
        !            28: ^"."RL.*\n     |
        !            29: ^"."ML.*\n     |
        !            30: ^"."DL.*\n     |
        !            31: ^"."LB.*\n     |
        !            32: ^"."FS.*\n     |
        !            33: ^"."EQ.*\n     |
        !            34: ^"."TS.*\n     {in++; BEGIN IN;}
        !            35: 
        !            36: ^"."TE.*\n     |
        !            37: ^"."FE.*\n     |
        !            38: ^"."LE.*\n     |
        !            39: ^"."EN.*\n     |
        !            40: ^"."DE.*\n     {in--; if(in <=0) BEGIN OUT;}
        !            41: 
        !            42: ^"."EQ{B}+delim{B}+\$\${B}+"."EN{B}+   eqn=1;
        !            43: \$[^$\n]*\$    {if (eqn==1);
        !            44:                 else REJECT;
        !            45:                }
        !            46: 
        !            47: ^"."TL.*\n.*\n |
        !            48: ^"."AS.*\n     |
        !            49: ^"."AE.*\n     |
        !            50: ^"."MT.*\n      |
        !            51: ^"."TM.*\n      |
        !            52: ^"."AU.*\n      ECHO;
        !            53: 
        !            54: ^"."ce.*\n     ;
        !            55: 
        !            56: <OUT>^"."P.*\n |
        !            57: <OUT>^"."H.*\n {if(ptr> str){
        !            58:                        if (*ptr!='\0') {
        !            59:                                        *ptr='\0';
        !            60:                        }
        !            61:                        printf("%s",str);
        !            62:                }
        !            63:                flag=2; /* flag==2 means print next sentence */
        !            64:                ptr= str;
        !            65:                ECHO;
        !            66:                }
        !            67: 
        !            68: <OUT>^"."I{B}+\".*\"   {for(i=4; i<yyleng-1;i++) *ptr++=yytext[i];}
        !            69: <OUT>^"."I{B}+/[^"].*\n                ;
        !            70: 
        !            71: <OUT>^"."[^I].*\n      {if(begin==0) ECHO;
        !            72:                else ;
        !            73:                }
        !            74: 
        !            75: <OUT>(et"."{B}+al|a"."d|A"."M|a"."m|b"."c|Ch|{B}ch|{B}ckts|dB|Dept|dept|Depts|depts)"."        |
        !            76: <OUT>(Dr|Drs|e"."g|Eq|eq|et"."al|etc|Fig|fig|Figs|figs)"."     |
        !            77: <OUT>({B}ft|i"."e|{B}in|Inc|Jr|jr|lb|lbs|{B}mi|Mr|Mrs|Ms|No|{B}no|Nos|{B}nos)"."       |
        !            78: <OUT>(P"."{B}*M|p"."m|Ph"."D|Ph"."d|PhD|Ref|ref|Refs|refs|sec|St|vs|v|yr)"."   |
        !            79: <OUT>"."{N}    |/* this is the main place text is stored to be output later */
        !            80: <OUT>{B}+{A}"."{B}+    |
        !            81: <OUT>"\n"      |
        !            82: <OUT>. {if(flag==1) {ptr= str;
        !            83:                flag=0;
        !            84:                }
        !            85:        STORE;
        !            86:        begin=1;
        !            87:        }
        !            88: 
        !            89: <OUT>\:/.*\n"."TS      |/* end a list,table, display after the preceding "*"*/
        !            90: <OUT>\:/.*\n"."DS      |
        !            91: <OUT>\:/.*\n".".L      {BEGIN IN;
        !            92:                        if(flag==2){
        !            93:                                if(ptr > str){*ptr++=':';
        !            94:                                        *ptr++='.';
        !            95:                                        *ptr++='\0';
        !            96:                                        printf("%s\n",str);
        !            97:                                }
        !            98:                                flag=1;
        !            99:                                ptr= str;
        !           100:                        }
        !           101:                        else {flag=1;
        !           102:                                *ptr++=':';
        !           103:                                *ptr++='.';
        !           104:                        }
        !           105: }
        !           106: <OUT>[.?][ \t]*\n/"."[^PH]     |  /* if sentence end & flag==2, print it */
        !           107: <OUT>[.?]{BP}+/{U}     {if(flag==2){
        !           108:                                if(ptr > str){*ptr++=yytext[0];
        !           109:                                        *ptr++='\0';
        !           110:                                        printf("%s\n",str);
        !           111:                                }
        !           112:                                flag=1;
        !           113:                                ptr= str;
        !           114:                        }
        !           115:                        else {flag=1;
        !           116:                        }
        !           117:                        }
        !           118: 
        !           119: <IN>.  ;
        !           120: <IN>\n ;
        !           121: %%
        !           122: yywrap(){
        !           123:        if(ptr> str) {*ptr++='\0';
        !           124:                        printf("%s",str);
        !           125:        }
        !           126:        return(1);
        !           127: }
        !           128: main(argc,argv)
        !           129: char *argv[];
        !           130: {
        !           131:        if(argc <= 1)
        !           132:                yylex();
        !           133:        else {
        !           134:                while(argc > 1){
        !           135:                        argc--; argv++;
        !           136:                        if(freopen(argv[0],"r",stdin) == NULL){
        !           137:                                fprintf(stderr,"org cannot open %s\n",argv[0]);
        !           138:                                exit(1);
        !           139:                        }
        !           140:                        yylex();
        !           141:                }
        !           142:        }
        !           143: }

unix.superglobalmegacorp.com

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