summaryrefslogtreecommitdiff
path: root/scripts/kconfig/help.l
Unidiff
Diffstat (limited to 'scripts/kconfig/help.l') (more/less context) (ignore whitespace changes)
-rw-r--r--scripts/kconfig/help.l78
1 files changed, 78 insertions, 0 deletions
diff --git a/scripts/kconfig/help.l b/scripts/kconfig/help.l
new file mode 100644
index 0000000..5ac4c2f
--- a/dev/null
+++ b/scripts/kconfig/help.l
@@ -0,0 +1,78 @@
1%option nounput nostdinit noyywrap 8bit
2%x ENTRY
3%{
4/*
5 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
6 * Released under the terms of the GNU GPL v2.0.
7 */
8
9#include <string.h>
10#include <unistd.h>
11#include "cml1.h"
12
13#define YY_DECL void helplex(char *help)
14#undef YY_NULL
15#define YY_NULL
16%}
17
18%%
19 struct symbol *sym = NULL;
20 helpin = fopen(help, "r");
21 if (!helpin)
22 return;
23 //help_flex_debug = 1;
24 yyrestart(helpin);
25 BEGIN(INITIAL);
26
27 ^#.*\n/* skip */
28
29^CONFIG_[[:alnum:]_]+ {
30 char name[256];
31 int ch;
32 while ((ch = input()) != '\n' && ch != EOF)
33 ;
34 memcpy(name, yytext, yyleng);
35 name[yyleng] = 0;
36 sym = lookup_symbol(name, SYMBOL_UNKNOWN);
37 new_string();
38 BEGIN(ENTRY);
39}
40
41<ENTRY>{
42 [ \t].*\n+/[^ \t\n] |
43 <<EOF>> {
44 append_string(yytext, yyleng);
45 if (sym) {
46 if (sym->help) {
47 //printf("symbol %s has duplicated help?\n", sym->name);
48 free(text);
49 } else
50 sym->help = text;
51 sym = NULL;
52 } else
53 printf("no symbol?\n");
54 BEGIN(INITIAL);
55 }
56 \n/[^ \t\n] {
57 append_string(yytext, yyleng);
58 if (sym) {
59 if (sym->help) {
60 //printf("symbol %s has duplicated help?\n", sym->name);
61 free(text);
62 } else
63 sym->help = text;
64 sym = NULL;
65 } else
66 printf("no symbol?\n");
67 BEGIN(INITIAL);
68 }
69 [ \t].*\n |
70 .|
71 \n{
72 append_string(yytext, yyleng);
73 }
74}
75
76.
77\n
78%%