提交 833e6224 编写于 作者: M Masahiro Yamada

genksyms: generate lexer and parser during build instead of shipping

Now that the kernel build supports flex and bison, remove the _shipped
files and generate them during the build instead.

There are no more shipped lexer and parser, so I ripped off the rules
in scripts/Malefile.lib that were used for REGENERATE_PARSERS.

The genksyms parser has ambiguous grammar, which would emit warnings:

 scripts/genksyms/parse.y: warning: 9 shift/reduce conflicts [-Wconflicts-sr]
 scripts/genksyms/parse.y: warning: 5 reduce/reduce conflicts [-Wconflicts-rr]

They are normally suppressed, but displayed when W=1 is given.
Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
上级 9a8dfb39
......@@ -184,14 +184,8 @@ endef
quiet_cmd_flex = LEX $@
cmd_flex = $(LEX) -o$@ -L $<
ifdef REGENERATE_PARSERS
.PRECIOUS: $(src)/%.lex.c_shipped
$(src)/%.lex.c_shipped: $(src)/%.l
$(call cmd,flex)
endif
.PRECIOUS: $(obj)/%.lex.c
$(filter %.lex.c,$(targets)): $(obj)/%.lex.c: $(src)/%.l FORCE
$(obj)/%.lex.c: $(src)/%.l FORCE
$(call if_changed,flex)
# YACC
......@@ -199,27 +193,15 @@ $(filter %.lex.c,$(targets)): $(obj)/%.lex.c: $(src)/%.l FORCE
quiet_cmd_bison = YACC $@
cmd_bison = $(YACC) -o$@ -t -l $<
ifdef REGENERATE_PARSERS
.PRECIOUS: $(src)/%.tab.c_shipped
$(src)/%.tab.c_shipped: $(src)/%.y
$(call cmd,bison)
endif
.PRECIOUS: $(obj)/%.tab.c
$(filter %.tab.c,$(targets)): $(obj)/%.tab.c: $(src)/%.y FORCE
$(obj)/%.tab.c: $(src)/%.y FORCE
$(call if_changed,bison)
quiet_cmd_bison_h = YACC $@
cmd_bison_h = bison -o/dev/null --defines=$@ -t -l $<
ifdef REGENERATE_PARSERS
.PRECIOUS: $(src)/%.tab.h_shipped
$(src)/%.tab.h_shipped: $(src)/%.y
$(call cmd,bison_h)
endif
.PRECIOUS: $(obj)/%.tab.h
$(filter %.tab.h,$(targets)): $(obj)/%.tab.h: $(src)/%.y FORCE
$(obj)/%.tab.h: $(src)/%.y FORCE
$(call if_changed,bison_h)
# Shipped files
......
......@@ -5,9 +5,36 @@ always := $(hostprogs-y)
genksyms-objs := genksyms.o parse.tab.o lex.lex.o
# FIXME: fix the ambiguous grammar in parse.y and delete this hack
#
# Suppress shift/reduce, reduce/reduce conflicts warnings
# unless W=1 is specified.
#
# Just in case, run "$(YACC) --version" without suppressing stderr
# so that 'bison: not found' will be displayed if it is missing.
ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
quiet_cmd_bison_no_warn = $(quet_cmd_bison)
cmd_bison_no_warn = $(YACC) --version >/dev/null; \
$(cmd_bison) 2>/dev/null
$(obj)/parse.tab.c: $(src)/parse.y FORCE
$(call if_changed,bison_no_warn)
quiet_cmd_bison_h_no_warn = $(quet_cmd_bison_h)
cmd_bison_h_no_warn = $(YACC) --version >/dev/null; \
$(cmd_bison_h) 2>/dev/null
$(obj)/parse.tab.h: $(src)/parse.y FORCE
$(call if_changed,bison_h_no_warn)
endif
# -I needed for generated C source (shipped source)
HOSTCFLAGS_parse.tab.o := -I$(src)
HOSTCFLAGS_lex.lex.o := -I$(src)
# dependencies on generated files need to be listed explicitly
$(obj)/lex.lex.o: $(obj)/parse.tab.h
targets := lex.lex.c parse.tab.c parse.tab.h
此差异已折叠。
此差异已折叠。
/* A Bison parser, made by GNU Bison 2.7. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_YY_SCRIPTS_GENKSYMS_PARSE_TAB_H_SHIPPED_INCLUDED
# define YY_YY_SCRIPTS_GENKSYMS_PARSE_TAB_H_SHIPPED_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
ASM_KEYW = 258,
ATTRIBUTE_KEYW = 259,
AUTO_KEYW = 260,
BOOL_KEYW = 261,
CHAR_KEYW = 262,
CONST_KEYW = 263,
DOUBLE_KEYW = 264,
ENUM_KEYW = 265,
EXTERN_KEYW = 266,
EXTENSION_KEYW = 267,
FLOAT_KEYW = 268,
INLINE_KEYW = 269,
INT_KEYW = 270,
LONG_KEYW = 271,
REGISTER_KEYW = 272,
RESTRICT_KEYW = 273,
SHORT_KEYW = 274,
SIGNED_KEYW = 275,
STATIC_KEYW = 276,
STRUCT_KEYW = 277,
TYPEDEF_KEYW = 278,
UNION_KEYW = 279,
UNSIGNED_KEYW = 280,
VOID_KEYW = 281,
VOLATILE_KEYW = 282,
TYPEOF_KEYW = 283,
VA_LIST_KEYW = 284,
EXPORT_SYMBOL_KEYW = 285,
ASM_PHRASE = 286,
ATTRIBUTE_PHRASE = 287,
TYPEOF_PHRASE = 288,
BRACE_PHRASE = 289,
BRACKET_PHRASE = 290,
EXPRESSION_PHRASE = 291,
CHAR = 292,
DOTS = 293,
IDENT = 294,
INT = 295,
REAL = 296,
STRING = 297,
TYPE = 298,
OTHER = 299,
FILENAME = 300
};
#endif
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE yylval;
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_YY_SCRIPTS_GENKSYMS_PARSE_TAB_H_SHIPPED_INCLUDED */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册