File: drbdmeta_scanner.fl

package info (click to toggle)
drbd-utils 9.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,388 kB
  • sloc: ansic: 43,698; xml: 15,968; cpp: 7,783; sh: 3,699; makefile: 1,353; perl: 353
file content (94 lines) | stat: -rw-r--r-- 2,672 bytes parent folder | download | duplicates (6)
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
%{

#include "drbd_endian.h"
#include "drbdmeta_parser.h"
#include "drbdtool_common.h"

static void bad_token(char*);

//#define DP printf("%s ",yytext);
#define DP
#define CP yylval.txt=yytext
#define YY_NO_INPUT 1
#define YY_NO_UNPUT 1

%}

%option noyywrap
%option yylineno
%option nounput

/* remember to avoid backing up.
 * tell user about bad/unexpected tokens. */

OP		[{};\[\]]
WS		[ \r\t\n]
COMMENT		\#[^\n]*

/* 1<<63 is 19 digits. has to be enough.
 * 20 digits would risk overflow of 64bit unsigned int */
NUM		-?[0-9]{1,19}
NUM_TOO_LONG	{NUM}[0-9]

U64		0x[0-9A-Fa-f]{16}
U32		0x[0-9A-Fa-f]{8}
INVALID_HEX	0x[0-9A-Fa-f]{0,17}

STRING		\"[^\"\r\n]{1,20}\"
EMPTY_STRING    \"\"?
INVALID_STRING  \"[^\"\r\n]{1,20}

INVALID_TOKEN	 [-_a-zA-Z0-9]{1,100}
INVALID_CHAR    [^-_a-zA-Z0-9 \t\r\n\";{}]

%%

{WS}		/* skip silently */
{COMMENT}	/* skip silently */
{OP}		DP; return yytext[0];
{STRING}	unescape(yytext); DP; CP; return TK_STRING;
{U64}		yylval.u64 = strto_u64(yytext, NULL, 16); DP; return TK_U64;
{U32}		yylval.u64 = strto_u64(yytext, NULL, 16); DP; return TK_U32;
{NUM}		yylval.u64 = strto_u64(yytext, NULL, 10); DP; return TK_NUM;
gc		DP; CP; return TK_GC;
bm		DP; CP; return TK_BM;
uuid		DP; CP; return TK_UUID;
version		DP; CP; return TK_VERSION;
la-size-sect	DP; CP; return TK_LA_SIZE;
bm-byte-per-bit DP; CP; return TK_BM_BYTE_PER_BIT;
device-uuid	DP; CP; return TK_DEVICE_UUID;
times		DP; CP; return TK_TIMES;
flags		DP; CP; return TK_FLAGS;
al-stripes	DP; CP; return TK_AL_STRIPES;
al-stripe-size-4k	DP; CP; return TK_AL_STRIPE_SIZE_4K;
la-peer-max-bio-size DP; CP; return TK_LA_BIO_SIZE;
node-id	DP; CP; return TK_NODE_ID;
current-uuid	DP; CP; return TK_CURRENT_UUID;
bitmap		DP; CP; return TK_BITMAP;
bitmap-uuid	DP; CP; return TK_BITMAP_UUID;
bitmap-dagtag	DP; CP; return TK_BITMAP_DAGTAG;
history-uuids	DP; CP; return TK_HISTORY_UUIDS;
peer		DP; CP; return TK_PEER;
hash		DP; CP; return TK_HASH;
max-peers	DP; CP; return TK_MAX_PEERS;
bitmap-index    DP; CP; return TK_BITMAP_INDEX;

{INVALID_STRING} CP; bad_token("invalid string"); return TK_INVALID;
{EMPTY_STRING}	 CP; bad_token("invalid string"); return TK_INVALID;
{INVALID_HEX}	 CP; bad_token("invalid hex number (only 8 or 16 hex digits accepted)"); return TK_INVALID;
{NUM_TOO_LONG}	 CP; bad_token("number too big"); return TK_INVALID;
{INVALID_TOKEN}	 CP; bad_token("unknown token"); return TK_INVALID;
{INVALID_CHAR}	 CP; return TK_INVALID_CHAR;

%%

static void bad_token(char *msg)
{
	fflush(stdout);
	fprintf(stderr,"line %u: %s: %s ...\n", yylineno, msg, yytext);
}

int my_yy_unscaned_characters(void)
{
	return (yy_n_chars) - ((yy_c_buf_p) - YY_CURRENT_BUFFER->yy_ch_buf);
}