remove dependency on flex/bison; store golden parser file in github

This commit is contained in:
Laurent Perron
2017-03-31 09:58:07 +02:00
parent f8cace6b14
commit 2cf3850457
8 changed files with 4797 additions and 71 deletions

View File

@@ -97,7 +97,7 @@ FLATZINC_DEPS = \
$(SRC_DIR)/flatzinc/logging.h \
$(SRC_DIR)/flatzinc/model.h \
$(SRC_DIR)/flatzinc/parser.h \
$(GEN_DIR)/flatzinc/parser.tab.hh \
$(SRC_DIR)/flatzinc/parser.tab.hh \
$(SRC_DIR)/flatzinc/presolve.h \
$(SRC_DIR)/flatzinc/reporting.h \
$(SRC_DIR)/flatzinc/sat_constraint.h \
@@ -209,14 +209,9 @@ FLATZINC_OBJS=\
$(OBJ_DIR)/flatzinc/solver_data.$O \
$(OBJ_DIR)/flatzinc/solver_util.$O
$(GEN_DIR)/flatzinc/parser.yy.cc: $(SRC_DIR)/flatzinc/parser.lex $(FLEX)
$(FLEX) -o$(GEN_DIR)/flatzinc/parser.yy.cc $(SRC_DIR)/flatzinc/parser.lex
$(GEN_DIR)/flatzinc/parser.tab.cc: $(SRC_DIR)/flatzinc/parser.yy $(BISON)
$(BISON) -t -o $(GEN_DIR)/flatzinc/parser.tab.cc -d $<
$(GEN_DIR)/flatzinc/parser.tab.hh: $(GEN_DIR)/flatzinc/parser.tab.cc
fz_parser: $(SRC_DIR)/flatzinc/parser.lex $(SRC_DIR)/flatzinc/parser.yy
flex -o$(SRC_DIR)/flatzinc/parser.yy.cc $(SRC_DIR)/flatzinc/parser.lex
bison -t -o $(SRC_DIR)/flatzinc/parser.tab.cc -d $<
$(OBJ_DIR)/flatzinc/checker.$O: $(SRC_DIR)/flatzinc/checker.cc $(FLATZINC_DEPS)
$(CCC) $(CFLAGS) -c $(SRC_DIR)$Sflatzinc$Schecker.cc $(OBJ_OUT)$(OBJ_DIR)$Sflatzinc$Schecker.$O
@@ -236,11 +231,11 @@ $(OBJ_DIR)/flatzinc/model.$O: $(SRC_DIR)/flatzinc/model.cc $(SRC_DIR)/flatzinc/m
$(OBJ_DIR)/flatzinc/parser.$O: $(SRC_DIR)/flatzinc/parser.cc $(FLATZINC_DEPS)
$(CCC) $(CFLAGS) -c $(SRC_DIR)$Sflatzinc$Sparser.cc $(OBJ_OUT)$(OBJ_DIR)$Sflatzinc$Sparser.$O
$(OBJ_DIR)/flatzinc/parser.tab.$O: $(GEN_DIR)/flatzinc/parser.tab.cc $(FLATZINC_DEPS)
$(CCC) $(CFLAGS) -c $(GEN_DIR)$Sflatzinc$Sparser.tab.cc $(OBJ_OUT)$(OBJ_DIR)$Sflatzinc$Sparser.tab.$O
$(OBJ_DIR)/flatzinc/parser.tab.$O: $(SRC_DIR)/flatzinc/parser.tab.cc $(FLATZINC_DEPS)
$(CCC) $(CFLAGS) -c $(SRC_DIR)$Sflatzinc$Sparser.tab.cc $(OBJ_OUT)$(OBJ_DIR)$Sflatzinc$Sparser.tab.$O
$(OBJ_DIR)/flatzinc/parser.yy.$O: $(GEN_DIR)/flatzinc/parser.yy.cc $(FLATZINC_DEPS)
$(CCC) $(CFLAGS) -c $(GEN_DIR)$Sflatzinc$Sparser.yy.cc $(OBJ_OUT)$(OBJ_DIR)$Sflatzinc$Sparser.yy.$O
$(OBJ_DIR)/flatzinc/parser.yy.$O: $(SRC_DIR)/flatzinc/parser.yy.cc $(FLATZINC_DEPS)
$(CCC) $(CFLAGS) -c $(SRC_DIR)$Sflatzinc$Sparser.yy.cc $(OBJ_OUT)$(OBJ_DIR)$Sflatzinc$Sparser.yy.$O
$(OBJ_DIR)/flatzinc/presolve.$O: $(SRC_DIR)/flatzinc/presolve.cc $(FLATZINC_DEPS)
$(CCC) $(CFLAGS) -c $(SRC_DIR)$Sflatzinc$Spresolve.cc $(OBJ_OUT)$(OBJ_DIR)$Sflatzinc$Spresolve.$O
@@ -655,4 +650,4 @@ printdir:
@echo GEN_DIR = $(GEN_DIR)
@echo OBJ_DIR = $(OBJ_DIR)
@echo SRC_DIR = $(SRC_DIR)
@echo EX_DIR = $(EX_DIR)
@echo EX_DIR = $(EX_DIR)

View File

@@ -5,10 +5,7 @@ PROTOBUF_TAG = 3.0.0
CBC_TAG = 2.9.8
SWIG_TAG = 3.0.12
PCRE_TAG = 8.37
# BISON, FLEX
BISON_TAG = 3.0.4
FLEX_TAG = 2.6.0
# help2man is needed by bison
HELP2MAN_TAG = 1.43.3
# Autoconf support
AUTOCONF_TAG = 2.69
@@ -115,8 +112,6 @@ install_third_party: \
install_cbc \
install_glpk \
install_scip \
install_bison \
install_flex \
$(CSHARP_THIRD_PARTY)
bin:
@@ -330,36 +325,6 @@ dependencies/sources/patchelf-0.8/Makefile: dependencies/sources/patchelf-0.8/co
dependencies/sources/patchelf-0.8/configure: dependencies/archives/patchelf-0.8.tar.gz
cd dependencies/sources && tar xzmf ../archives/patchelf-0.8.tar.gz
# Install bison
install_bison: dependencies/install/bin/bison
dependencies/install/bin/bison: dependencies/sources/bison-$(BISON_TAG)/Makefile $(ACLOCAL_TARGET) dependencies/install/bin/help2man
cd dependencies/sources/bison-$(BISON_TAG) && $(SET_PATH) make install
dependencies/sources/bison-$(BISON_TAG)/Makefile: dependencies/sources/bison-$(BISON_TAG)/configure $(ACLOCAL_TARGET)
cd dependencies/sources/bison-$(BISON_TAG) && $(SET_PATH) autoreconf
cd dependencies/sources/bison-$(BISON_TAG) && $(SET_PATH) ./configure --prefix=$(OR_ROOT_FULL)/dependencies/install
dependencies/sources/bison-$(BISON_TAG)/configure: dependencies/archives/bison-$(BISON_TAG).tar.gz
cd dependencies/sources && tar xvzf ../archives/bison-$(BISON_TAG).tar.gz
dependencies/archives/bison-$(BISON_TAG).tar.gz:
cd dependencies/archives && curl -OL http://ftpmirror.gnu.org/bison/bison-$(BISON_TAG).tar.gz
# Install flex
install_flex: dependencies/install/bin/flex
dependencies/install/bin/flex: dependencies/sources/flex-$(FLEX_TAG)/Makefile $(ACLOCAL_TARGET)
cd dependencies/sources/flex-$(FLEX_TAG) && $(SET_PATH) make install
dependencies/sources/flex-$(FLEX_TAG)/Makefile: dependencies/sources/flex-$(FLEX_TAG)/configure $(ACLOCAL_TARGET)
cd dependencies/sources/flex-$(FLEX_TAG) && $(SET_PATH) ./configure --prefix=$(OR_ROOT_FULL)/dependencies/install
dependencies/sources/flex-$(FLEX_TAG)/configure: dependencies/archives/flex-$(FLEX_TAG).tar.bz2
cd dependencies/sources && tar xvjmf ../archives/flex-$(FLEX_TAG).tar.bz2
dependencies/archives/flex-$(FLEX_TAG).tar.bz2:
cd dependencies/archives && curl -OL http://sourceforge.net/projects/flex/files/flex-$(FLEX_TAG).tar.bz2
# Install help2man
dependencies/install/bin/help2man: dependencies/sources/help2man-$(HELP2MAN_TAG)/Makefile

View File

@@ -5,7 +5,6 @@ CBC_TAG = 2.9.8
ZLIB_TAG = 1.2.11
ZLIB_ARCHIVE_TAG = 1211
SWIG_TAG = 3.0.12
BISON_FLEX_TAG = 2.5.5
# Build extra dependencies (GLPK, SCIP) from archive only if the archive is present.
# The archive should be glpk-4.57.tar.gz
@@ -88,8 +87,7 @@ build_third_party: \
install_swig \
install_coin_cbc \
install_glpk \
install_scip \
install_bison
install_scip
bin:
$(MKDIR_P) bin
@@ -378,18 +376,6 @@ dependencies/install/lib/scip.lib: dependencies/archives/scipoptsuite-$(SCIP_TAG
git checkout dependencies/solutions/Scip/soplex/soplex.vcxproj
git checkout dependencies/solutions/Scip/scip/scip.vcxproj
# Install bison and flex in one package.
install_bison: dependencies\install\bin\win_bison.exe
dependencies\install\bin\win_flex.exe: dependencies\install\bin\win_bison.exe
dependencies\install\bin\win_bison.exe: dependencies\archives\win_flex_bison-$(BISON_FLEX_TAG).zip
tools\unzip -d dependencies\install\bin dependencies\archives\win_flex_bison-$(BISON_FLEX_TAG).zip
tools\touch.exe dependencies\install\bin/win_bison.exe
dependencies\archives\win_flex_bison-$(BISON_FLEX_TAG).zip:
tools\wget -P dependencies\archives --no-check-certificate https://sourceforge.net/projects/winflexbison/files/win_flex_bison-$(BISON_FLEX_TAG).zip
# Install Java protobuf
install_java_protobuf: dependencies/install/lib/protobuf.jar

View File

@@ -248,9 +248,6 @@ ifeq ($(PLATFORM),MACOSX)
endif
endif # MAC OS X
BISON = dependencies/install/bin/bison
FLEX = dependencies/install/bin/flex
CFLAGS = $(DEBUG) -I$(INC_DIR) -I$(EX_DIR) -I$(GEN_DIR) $(GFLAGS_INC) $(ARCH) \
-Wno-deprecated $(PROTOBUF_INC) $(CBC_INC) $(CLP_INC) $(GLPK_INC) \
$(SCIP_INC) $(SLM_INC) $(GUROBI_INC) $(CPLEX_INC) -DUSE_GLOP -DUSE_BOP $(SPARSEHASH_INC)

View File

@@ -41,8 +41,6 @@ MKDIR_P = tools\mkdir.exe -p
COPY = copy
TOUCH = tools\touch.exe
SED = tools\sed.exe
BISON = dependencies\install\bin\win_bison.exe
FLEX = dependencies\install\bin\win_flex.exe
CMAKE = cmake
ARCHIVE_EXT = .zip
FZ_EXE = fzn-or-tools$E
@@ -151,4 +149,4 @@ DEPENDENCIES_LNK = $(STATIC_CBC_LNK) $(STATIC_CLP_LNK) $(STATIC_GLPK_LNK) $(STAT
OR_TOOLS_LD_FLAGS = $(ZLIB_LNK) $(SYS_LNK)
COMMA := ,
BACK_SLASH := \\
BACK_SLASH := \\

2413
src/flatzinc/parser.tab.cc Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,94 @@
/* A Bison parser, made by GNU Bison 3.0.2. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2013 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_ORFZ_SRC_FLATZINC_PARSER_TAB_HH_INCLUDED
# define YY_ORFZ_SRC_FLATZINC_PARSER_TAB_HH_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#endif
#if YYDEBUG
extern int orfz_debug;
#endif
/* "%code requires" blocks. */
#line 21 "src/flatzinc/parser.yy" /* yacc.c:1909 */
#if !defined(OR_TOOLS_FLATZINC_FLATZINC_TAB_HH_)
#define OR_TOOLS_FLATZINC_FLATZINC_TAB_HH_
#include "base/strutil.h"
#include "base/stringpiece_utils.h"
#include "flatzinc/parser_util.h"
// Tells flex to use the LexerInfo class to communicate with the bison parser.
typedef operations_research::fz::LexerInfo YYSTYPE;
// Defines the parameter to the orfz_lex() call from the orfz_parse() method.
#define YYLEX_PARAM scanner
#endif // OR_TOOLS_FLATZINC_FLATZINC_TAB_HH_
#line 60 "src/flatzinc/parser.tab.hh" /* yacc.c:1909 */
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
ARRAY = 258,
BOOL = 259,
CONSTRAINT = 260,
FLOAT = 261,
INT = 262,
MAXIMIZE = 263,
MINIMIZE = 264,
OF = 265,
PREDICATE = 266,
SATISFY = 267,
SET = 268,
SOLVE = 269,
VAR = 270,
DOTDOT = 271,
COLONCOLON = 272,
IVALUE = 273,
SVALUE = 274,
IDENTIFIER = 275,
DVALUE = 276
};
#endif
/* Value type. */
int orfz_parse (operations_research::fz::ParserContext* context, operations_research::fz::Model* model, bool* ok, void* scanner);
#endif /* !YY_ORFZ_SRC_FLATZINC_PARSER_TAB_HH_INCLUDED */

2278
src/flatzinc/parser.yy.cc Normal file

File diff suppressed because it is too large Load Diff