summaryrefslogtreecommitdiff
path: root/src/pmdas/hotproc/src/lex.l
blob: d19f9992c5355880e7220c9cb6004f4be7d5b499 (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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
 * Copyright (c) 1995 Silicon Graphics, Inc.  All Rights Reserved.
 * 
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

%{
#include "./gram_node.h"
#include "./gram.h"

void yyerror(char *s);

static char emsg[256]; /* error message */
static char yy_ichar;  /* input char from conf_buffer */
extern char *conf_buffer_ptr;

#undef input
#undef unput
#define input() ( (yy_ichar = *conf_buffer_ptr++) == '\n' ? (yylineno++, yy_ichar) : yy_ichar)
#define unput(c) { if ((*--conf_buffer_ptr = c) == '\n') yylineno--; }

%}

%option noinput
%option nounput

%%

Version		{ return VERSION; }
schedwait	{ return SCHEDWAIT; }
iowait		{ return IOWAIT; }
iodemand	{ return IODEMAND; }
residentsize	{ return RESIDENTSIZE; }
virtualsize	{ return VIRTUALSIZE; }
ctxswitch	{ return CTXSWITCH; }
syscalls	{ return SYSCALLS; }
gid		{ return GID; }
uid		{ return UID; }
uname		{ return UNAME; }
gname		{ return GNAME; }
fname		{ return FNAME; }
psargs		{ return PSARGS; }
cpuburn		{ return CPUBURN; }
"&&"		{ return AND; }
"||"		{ return OR; }
"!"		{ return NOT; }
"("		{ return LPAREN; }	
")"		{ return RPAREN; }	
true		{ return TRUE; }
false		{ return FALSE; }
"=="		{ return EQUAL; }
"!="		{ return NEQUAL; }
"<"		{ return LTHAN; }
"<="		{ return LEQUAL; }
">"		{ return GTHAN; }
">="		{ return GEQUAL; }
"~"		{ return MATCH; }
"!~"		{ return NMATCH; }

\/[^/\n]*[/\n] {
	    char *str;
	    yylval.y_str = (char *)malloc(yyleng-1);
	    if (yylval.y_str == 0) {
		(void)sprintf(emsg, "malloc failed: %s", osstrerror());
		yyerror(emsg);
	    }
	    strncpy(yylval.y_str, &yytext[1], yyleng-2);
	    yylval.y_str[yyleng-2] = '\0';
	    if ((str = re_comp(yylval.y_str)) != 0) {
	        yyerror(str);
	    }
	    return PATTERN;
	}

\"[^"\n]*["\n] {
	    yylval.y_str = (char *)malloc(yyleng-1);
	    if (yylval.y_str == 0) {
		(void)sprintf(emsg, "malloc failed: %s", osstrerror());
		yyerror(emsg);
	    }
	    strncpy(yylval.y_str, &yytext[1], yyleng-2);
	    yylval.y_str[yyleng-2] = '\0';
	    return STRING;
	}


[0-9]+ |
[0-9]*"."[0-9]+ |
[0-9]+"."[0-9]*	{
	    yylval.y_number = atof(yytext);
	    return NUMBER;
	}

\#.*\n	{ }

[\t \r\n]+ { }


[a-zA-Z]+ {
	    yyerror("Illegal word");
	}

.	{
	    yyerror("Illegal character");
	}
%%