blob: 5ac4c2f8748fe944faa04bf129c50bf4afb76f79 (
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
|
%option nounput nostdinit noyywrap 8bit
%x ENTRY
%{
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
* Released under the terms of the GNU GPL v2.0.
*/
#include <string.h>
#include <unistd.h>
#include "cml1.h"
#define YY_DECL void helplex(char *help)
#undef YY_NULL
#define YY_NULL
%}
%%
struct symbol *sym = NULL;
helpin = fopen(help, "r");
if (!helpin)
return;
//help_flex_debug = 1;
yyrestart(helpin);
BEGIN(INITIAL);
^#.*\n /* skip */
^CONFIG_[[:alnum:]_]+ {
char name[256];
int ch;
while ((ch = input()) != '\n' && ch != EOF)
;
memcpy(name, yytext, yyleng);
name[yyleng] = 0;
sym = lookup_symbol(name, SYMBOL_UNKNOWN);
new_string();
BEGIN(ENTRY);
}
<ENTRY>{
[ \t].*\n+/[^ \t\n] |
<<EOF>> {
append_string(yytext, yyleng);
if (sym) {
if (sym->help) {
//printf("symbol %s has duplicated help?\n", sym->name);
free(text);
} else
sym->help = text;
sym = NULL;
} else
printf("no symbol?\n");
BEGIN(INITIAL);
}
\n/[^ \t\n] {
append_string(yytext, yyleng);
if (sym) {
if (sym->help) {
//printf("symbol %s has duplicated help?\n", sym->name);
free(text);
} else
sym->help = text;
sym = NULL;
} else
printf("no symbol?\n");
BEGIN(INITIAL);
}
[ \t].*\n |
. |
\n {
append_string(yytext, yyleng);
}
}
.
\n
%%
|