File: cmd_tbl.l

package info (click to toggle)
zephyr 2.0.4-7
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,796 kB
  • ctags: 2,989
  • sloc: ansic: 29,327; sh: 1,447; makefile: 957; yacc: 498; lex: 137; lisp: 127
file content (99 lines) | stat: -rwxr-xr-x 1,629 bytes parent folder | download | duplicates (2)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
%{
#undef yywrap
int num_lines = 0;
static int l_command_table();
static int l_request();
static int l_unimplemented();
static int l_end();
static int l_quoted_string();
static int l_string();
%}

N	[0-9]
PC	[^\"]
AN      [A-Z_a-z0-9]
%%
\n	++num_lines;

command_table	return l_command_table();
request		return l_request();
unimplemented	return l_unimplemented();
end		return l_end();

[\t\n ]		;

\"{PC}*\"	return l_quoted_string();

{AN}*		return l_string();

#.*\n		;

.		return (*yytext);

%%

/*
 * User-subroutines section.
 *
 * Have to put all this stuff here so that the include file
 * from YACC output can be included, since LEX doesn't allow
 * an include file before the code it generates for the above
 * rules.
 *
 * Copyright 1987, 1988 by MIT Student Information Processing Board.
 *
 * For copyright info, see copyright.h.
 */

#include <string.h>
#include "y.tab.h"
#include "copyright.h"

extern char *last_token, *ds();

static int l_command_table()
{
     last_token = "command_table";
     return COMMAND_TABLE;
}

static int l_request()
{
     last_token = "request";
     return REQUEST;
}

static int l_unimplemented()
{
     last_token = "unimplemented";
     return UNIMPLEMENTED;
}

static int l_end()
{
     last_token = "end";
     return END;
}

static int l_quoted_string()
{
     register char *p;
     yylval.dynstr = ds(yytext+1);
     if (p=strrchr(yylval.dynstr, '"'))
	  *p='\0';
     last_token = ds(yylval.dynstr);
     return STRING;
}

static int l_string()
{
     yylval.dynstr = ds(yytext);
     last_token = ds(yylval.dynstr);
     return STRING;
}

int yywrap()
{
     return 1;
}