aboutsummaryrefslogtreecommitdiff
path: root/src/input.l
blob: 542c897336244746b70a397f2ba767ce84421610 (plain)
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
%{
#include "trans.h"
#include "y.tab.h"

char *file_name = "<stdin>";
int input_line = 1;

#define isws(c) ((c)==' ' || (c)=='\t') 
%}

MWS [ \t]*
WS [ \t]+
%%
#.*\n                          input_line++; 
^[nN][oO][dD][eE]              return NODE;
^[pP][oO][sS]                  return POS;
^[eE][nN][dD]                  return END;
^[mM][eE][aA][nN][iI][nN][gG]  return MEANING;
^[aA][lL][iI][aA][sS]          return ALIAS;
^[aA][nN][tT]                  return ANT; 
^[tT][oO][pP][iI][cC]          return TOPIC;
^[fF][oO][rR][mM][sS]          return FORMS;
^[xX][rR][eE][fF]              return XREF;
\n                             input_line++; 
{WS}[^\n]+\n                   {
	char *p, *q;

	for (p = yytext + yyleng - 1; p > yytext && isspace(*p); p--)
		;
	p[1] = 0;
	input_line++;
	yylval.string = yytext+1;
	return STRING;
}
.                              { fprintf (stderr, "%s:%d: stray character %c\n",
					  file_name, input_line, yytext[0]);
                                  exit(1); }
				  
%%

void
open_input(char *name)
{
	yyin = fopen(name, "r");
	if (!yyin) {
		fprintf (stderr, "cannot open ");
		perror (name);
		exit (1);
	}
	file_name = name;
}
			
		
		

Return to:

Send suggestions and report system problems to the System administrator.