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