Annotation of 43BSDTahoe/new/xns/compiler/scanner.l, revision 1.1.1.1

1.1       root        1: %{
                      2: #ifndef lint
                      3: static char RCSid[] = "$Header: scanner.l,v 2.1 86/07/29 06:48:21 jqj Exp $";
                      4: #endif
                      5: /*
                      6:  * scanner.l -- scanner for the XNS courier compiler
                      7:  */
                      8: 
                      9: /* $Log:       scanner.l,v $
                     10:  * Revision 2.1  86/07/29  06:48:21  jqj
                     11:  * added support for 37D style comments.
                     12:  * 
                     13:  * Revision 2.0  85/11/21  07:21:45  jqj
                     14:  * 4.3BSD standard release
                     15:  * 
                     16:  * Revision 1.1  85/11/20  12:56:17  jqj
                     17:  * Initial revision
                     18:  * 
                     19:  * Revision 1.3  85/03/11  16:40:08  jqj
                     20:  * Public alpha-test version, released 11 March 1985
                     21:  * 
                     22:  * Revision 1.2  85/02/21  11:05:51  jqj
                     23:  * alpha test version
                     24:  * 
                     25:  * Revision 1.1  85/02/15  13:55:58  jqj
                     26:  * Initial revision
                     27:  * 
                     28:  */
                     29: 
                     30: #include "compiler.h"
                     31: #include "y.tab.h"
                     32: %}
                     33: %%
                     34: "--"$                  |
                     35: "----"                 |
                     36: \-(\-[^\n-]+)+(\n|"--")        |
                     37: [ \t\n]                        /* whitespace */;
                     38: ARRAY                  { return (ARRAY); }
                     39: BEGIN                  { return (_BEGIN); }
                     40: BOOLEAN                        { return (BOOLEAN); }
                     41: CARDINAL               { return (CARDINAL); }
                     42: CHOICE                 { return (CHOICE); }
                     43: DEPENDS                        { return (DEPENDS); }
                     44: END                    { return (END); }
                     45: ERROR                  { return (ERROR); }
                     46: INTEGER                        { return (INTEGER); }
                     47: LONG                   { return (LONG); }
                     48: OF                     { return (OF); }
                     49: PROCEDURE              { return (PROCEDURE); }
                     50: PROGRAM                        { return (PROGRAM); }
                     51: RECORD                 { return (RECORD); }
                     52: REPORTS                        { return (REPORTS); }
                     53: RETURNS                        { return (RETURNS); }
                     54: SEQUENCE               { return (SEQUENCE); }
                     55: STRING                 { return (STRING); }
                     56: TYPE                   { return (TYPE); }
                     57: UNSPECIFIED            { return (UNSPECIFIED); }
                     58: UPON                   { return (UPON); }
                     59: VERSION                        { return (VERSION); }
                     60: TRUE                   { return (TRUE); }
                     61: FALSE                  { return (FALSE); }
                     62: "=>"                   { return (_CHOOSES); }
                     63: "-"?[0-9]+             {
                     64:                                /*
                     65:                                 * decimal constant.
                     66:                                 */
                     67:                                yylval.stringvalue = copy(yytext);
                     68:                                return (number);
                     69:                        }
                     70: "-"?[0-9]+[Dd]         {
                     71:                                /*
                     72:                                 * decimal constant.
                     73:                                 */
                     74:                                yytext[yyleng-1] = '\0';
                     75:                                yylval.stringvalue = copy(yytext);
                     76:                                return (number);
                     77:                        }
                     78: "-"?[0-7]+[Bb]         {
                     79:                                char buf[BUFSIZ];
                     80:                                /*
                     81:                                 * octal constant.
                     82:                                 * change to C representation
                     83:                                 */
                     84:                                yytext[yyleng-1] = '\0';
                     85:                                if (*yytext != '-')
                     86:                                        sprintf(buf,"0%s", yytext);
                     87:                                else
                     88:                                        sprintf(buf,"-0%s", yytext+1);
                     89:                                yylval.stringvalue = copy(buf);
                     90:                                return (number);
                     91:                        }
                     92: "-"?[0-9][0-9A-Fa-f]*[Xx]      {
                     93:                                char buf[BUFSIZ];
                     94:                                /*
                     95:                                 * hex constant.
                     96:                                 * change to C representation
                     97:                                 */
                     98:                                yytext[yyleng-1] = '\0';
                     99:                                if (*yytext != '-')
                    100:                                        sprintf(buf,"0x%s", yytext);
                    101:                                else
                    102:                                        sprintf(buf,"-0x%s", yytext+1);
                    103:                                yylval.stringvalue = copy(buf);
                    104:                                return (number);
                    105:                        }
                    106: \"[^"\n"]*\"           {
                    107:                                /*
                    108:                                 * string constant
                    109:                                 */
                    110:                                
                    111:                                yylval.stringvalue = copy(yytext);
                    112:                                return (string);
                    113:                        }
                    114: \"([^\n"]|\"\")*\"     {
                    115:                                register char *p;
                    116:                                /*
                    117:                                 * string constant with embedded ""
                    118:                                 */
                    119: 
                    120:                                for (p=yytext+1; p<yytext+yyleng-1; p++)
                    121:                                        if (*p == '"') *p++='\\';
                    122:                                yylval.stringvalue = copy(yytext);
                    123:                                return (string);
                    124:                        }
                    125: [a-zA-Z_][a-zA-Z0-9_]* {
                    126:                                yylval.stringvalue = copy(yytext);
                    127:                                return (identifier);
                    128:                        }
                    129: .                      {
                    130:                                return ((int) yytext[0]);
                    131:                        }
                    132: 
                    133: %%

unix.superglobalmegacorp.com

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