blob: 7e33ad03130bdc1c6b1f80f1e0f2587cb07da017 (
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
|
%{
#include <glib.h>
#include <stdio.h>
#include "ct-grammar.h"
int lex_line_number = 1;
%}
N ([0-9]+|(0X|0x)[0-9A-Fa-f]+)
B [0-9A-Fa-f][0-9A-Fa-f]?
W [A-Za-z_]
quoted \"[^"\n]*["\n]
%%
\n lex_line_number++;
[\t ]+ /* eat whitespace */
#.* /* one-line shell-style comments */
{quoted} {
wtap_lval.s = g_string_new(wtap_text + 1);
g_string_truncate(wtap_lval.s, strlen(wtap_text) - 2);
/* g_print("lex made QUOTED (%s)\n", wtap_lval.s->str);*/
return QUOTED;
}
";" return ';';
"," return ',';
"(" return '(';
")" return ')';
"@" return '@';
"[" return '[';
"]" return ']';
protocol return PROTOCOL;
parents return PARENTS;
field return FIELD;
alias return ALIAS;
boolean return BOOLEAN;
ether return ETHER;
uint8 return UINT8;
uint16 return UINT16;
uint32 return UINT32;
byte return BYTE;
and_mask return AND_MASK;
byte_offset return BYTE_OFFSET;
either_of return EITHER_OF;
{N} {
wtap_lval.d = atoi(wtap_text);
return NUMBER;
}
{W}+ {
wtap_lval.s = g_string_new(wtap_text);
/* g_print("lex made TEXT (%s)\n", wtap_lval.s->str);*/
return TEXT;
}
%%
int
wtap_wrap()
{
return 1;
}
void wtap_error(char *string)
{
fprintf(stderr,"%s on line %d\n",string, lex_line_number);
exit(0);
}
|