|
|
1.1 root 1: %{
2: /*
3: * lex.l 1.3
4: *
5: * Lexical Analyzer Description for Spreadsheet Program `vis'
6: *
7: * A. F. Gettier
8: * Bell Laboratories
9: * Update made 11/1/82 11:12:08
10: * Retrieved 11/15/82 13:22:28
11: */
12: #include <stdio.h>
13: #include <ctype.h>
14: #include "vis.h"
15: #include "y.tab.h"
16: #undef input()
17: #undef unput(c)
18: char input();
19: extern int Inrow, Incol;
20: extern char Inline[];
21: %}
22:
23: D [0-9]
24: L [A-Za-z]
25: A [A-Za-z0-9]
26:
27: %%
28: [ \t] ;
29: \"[^\"]*\" {
30: yytext[yyleng-1] = '\0';
31: yylval.sval = copystr( yytext + 1 );
32: return( STR );
33: }
34: \'[^\']*\' {
35: yytext[yyleng-1] = '\0';
36: yylval.sval = copystr( yytext + 1 );
37: return( STR );
38: }
39: ^[ \t]*{L}+{D}+ {
40: int i;
41: (void)foldup( yytext );
42: yylval.vval.col = -1;
43: i = 0;
44: while ( yytext[i] == ' ' || yytext[i] == '\t' ) i++;
45: while ( ! isdigit( yytext[i] ) ) {
46: yylval.vval.col = ( yylval.vval.col + 1 ) * 26
47: + yytext[i] - 'A';
48: i++;
49: }
50: yylval.vval.row = atoi( &(yytext[i]) ) - 1;
51: Inrow = yylval.vval.row;
52: Incol = yylval.vval.col;
53: yylval.vval.tval = copystr( Inline );
54: return( AVARIABLE );
55: }
56: {L}+{D}+ {
57: int i;
58: (void)foldup( yytext );
59: yylval.nval.col = -1;
60: i = 0;
61: while ( ! isdigit( yytext[i] ) ) {
62: yylval.nval.col = ( yylval.nval.col + 1 ) * 26
63: + yytext[i] - 'A';
64: i++;
65: }
66: yylval.nval.row = atoi( &(yytext[i]) ) - 1;
67: return( VARIABLE );
68: }
69: {L}+ {
70: char tbuf[128];
71: int tval;
72: (void)strcpy( tbuf, yytext );
73: (void)foldup( tbuf );
74: tval = hashsearch( tbuf );
75: switch( tval ) {
76: /*
77: * Numbers
78: */
79: case PI:
80: yylval.dval = 3.14159265358979;
81: return( NUMBER );
82: /*
83: * Functions
84: */
85: case ABS:
86: case ACOS:
87: case ASIN:
88: case ATAN:
89: case ATAN2:
90: case COS:
91: case EXP:
92: case GAMMA:
93: case HYPOT:
94: case INT:
95: case LOG:
96: case POW:
97: case SIN:
98: case SQRT:
99: yylval.ival = tval;
100: return( FUNC );
101: /*
102: * Actual Tokens
103: */
104: case AT:
105: case COL:
106: case DEBUG:
107: case DOWN:
108: case DUP:
109: case DUPLICATE:
110: case EDIT:
111: case HELP:
112: case LEFT:
113: case LIST:
114: case POSITION:
115: case REDRAW:
116: case REFRESH:
117: case REP:
118: case REPLICATE:
119: case RIGHT:
120: case ROW:
121: case SCALE:
122: case SHIFT:
123: case SLIDE:
124: case SHELL:
125: case SH:
126: case THRU:
127: case UP:
128: case VER:
129: case WIDTH:
130: case ZERO:
131: case QUIT:
132: return( tval );
133: case COPY:
134: case READ:
135: case WRITE:
136: yylval.sval = collect();
137: return( tval );
138: }
139: yylval.sval = copystr( yytext );
140: return( LETTERS );
141: }
142: {D}*\.?{D}*[eE][\+\-]?{D}+ { yylval.dval = atof(yytext);return(NUMBER); }
143: {D}*\.?{D}* { yylval.dval = atof(yytext);return(NUMBER); }
144: "=" return( '=' );
145: "," return( ',' );
146: "[" return( '[' );
147: "]" return( ']' );
148: "(" return( '(' );
149: ")" return( ')' );
150: "+" return( '+' );
151: "%" return( '%' );
152: "-" return( '-' );
153: "**" return( EXPON );
154: "^" return( EXPON );
155: "*" return( '*' );
156: "/" return( '/' );
157: "\n" return( TERM );
158: . return( ERROR );
159: %%
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.