File: tclex.c

package info (click to toggle)
magnus 20060324-5.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 19,436 kB
  • ctags: 20,462
  • sloc: cpp: 130,217; ansic: 37,090; tcl: 10,970; perl: 1,109; makefile: 966; sh: 403; yacc: 372; csh: 57; awk: 33; asm: 10
file content (62 lines) | stat: -rw-r--r-- 1,768 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "tcyacc.h" 
#include "y.tab.h" 
#include "string.h"
#include "parser.h"
#include "stdio.h"
#include <stdlib.h>
extern int lineno;
extern FILE *fin;
char match[] = {
00,
00  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,03  ,04  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
03  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
02  ,02  ,02  ,01  ,02  ,'0' ,01  ,01  ,
'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,
'0' ,'0' ,01  ,02  ,01  ,01  ,01  ,01  ,
01  ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
'A' ,'A' ,'A' ,02  ,01  ,02  ,02  ,01  ,
01  ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
'A' ,'A' ,'A' ,01  ,01  ,01  ,01  ,01  ,
0};
yylex(){
register	int     c;
register	int     s;
	for(;;) {
	c = getc(fin);
/* skip comments which are started with # */
        if (c == '#')
                do {
                while ((c=getc(fin)) != EOF && c != '\n');
                lineno++;
                if (c == EOF)
                        return 0;
                } while ((c=getc(fin)) == '#');

	switch (match[c + 1]) {
		case	0:	return (0);
		case	1:	fprintf(fout," lexical ERROR in line %d near %c\n",lineno, c);
	                        exit(1);
		case	2:	return c;
		case  'A':	yylval.gen[0] = c;
				return(TOKEN_GEN);
		case    3:	break;
		case    4:	lineno++;
				break;
		case  '0':      ungetc(c, fin);
                                fscanf(fin, "%d", &yylval.vali);
                                return (TOKEN_INT);
		default:        fprintf(fout," lexical ERROR in line %d near %c\n",lineno, c);
                        exit(1);
        }
	}
}