3 # Copyright (C) 2010 Mason Larobina <mason.larobina@gmail.com>
4 # Copyright (C) 2008 Pierre Habouzit <madcoder@debian.org>
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
27 /* This file is autogenerated by $(basename $0) */
36 test $# -gt 2 ||
break
38 -o) shift; out
="$1"; shift;;
39 -t) shift; type_t
="$1"; shift;;
47 #ifndef LUAKIT_COMMON_TOKENIZE_H
48 #define LUAKIT_COMMON_TOKENIZE_H
50 typedef enum luakit_token_t {
52 `tr '[:lower:]' '[:upper:]' | sed -e "s/^[^/].*/ L_TK_&,/"`
55 __attribute__((pure)) enum luakit_token_t l_tokenize(const char *s, int len);
65 echo "$tok, L_TK_`echo $tok | tr '[:lower:]' '[:upper:]'`"
72 which gperf
> /dev
/null
74 echo "gperf not found. You need to install gperf." > /dev
/stderr
;
78 gperf
-l -t -C -F",0" \
79 --language=ANSI-C
-Nl_tokenize_aux <<EOF \
80 | sed -e '/__gnu_inline__/d;s/\<\(__\|\)inline\>//g'
85 #include "common/tokenize.h"
87 static const struct tok *l_tokenize_aux(const char *str, unsigned int len);
90 struct tok { const char *name; int val; };
95 luakit_token_t l_tokenize(const char *s, int len)
101 const struct tok *res = l_tokenize_aux(s, len);
102 return res ? res->val : L_TK_UNKNOWN;
111 grep '^### ' "$1" | cut
-d ' ' -f 2
118 trap "rm -f ${TARGET}" 0
122 *.h
) do_h
> "${TARGET}" < "${TOKENS_FILE}" ;;
123 *.c
) do_c
> "${TARGET}" < "${TOKENS_FILE}" ;;
124 *) die
"you must ask for the 'h' or 'c' generation";;