From cf6dd6e86ece32a32c078f8619a76f76432e504d Mon Sep 17 00:00:00 2001 From: BenceJanosSzabo <bence.janos.szabo@ericsson.com> Date: Mon, 12 Dec 2016 15:58:33 +0100 Subject: [PATCH] Config file exclusive range and infinity fix Change-Id: Ibb4cd12e485244bf82d301cb0cb4fed43cb14e4a Signed-off-by: BenceJanosSzabo <bence.janos.szabo@ericsson.com> --- core/config_process.l | 2 +- core/config_process.y | 15 +++- mctr2/cli/config_read.l | 2 +- mctr2/cli/config_read.y | 25 ++++++- .../templateExclusiveRange/Makefile | 75 +++++++++++-------- 5 files changed, 81 insertions(+), 38 deletions(-) diff --git a/core/config_process.l b/core/config_process.l index 42a98aee3..4e0979486 100644 --- a/core/config_process.l +++ b/core/config_process.l @@ -96,7 +96,7 @@ LINECOMMENT ("//"|"#")[^\r\n]*{NEWLINE} NUMBER 0|([1-9][0-9]*) -FLOAT [+-]?({NUMBER}\.[0-9]+)|((({NUMBER}(\.[0-9]+)?)|(\.[0-9]+))[Ee][+-]?{NUMBER})|infinity|not_a_number +FLOAT [+-]?({NUMBER}\.[0-9]+)|((({NUMBER}(\.[0-9]+)?)|(\.[0-9]+))[Ee][+-]?{NUMBER})|not_a_number BIN 0|1 BITSTRING '{BIN}*'B diff --git a/core/config_process.y b/core/config_process.y index ccc4e90f0..46d7682d0 100644 --- a/core/config_process.y +++ b/core/config_process.y @@ -63,6 +63,12 @@ #include "config_process.lex.hh" +#ifndef INFINITY +#include <float.h> +static const double INFINITY = (DBL_MAX*DBL_MAX); +#endif + + extern void reset_config_process_lex(const char* fname); extern void config_process_close(); extern int config_process_get_current_line(); @@ -387,13 +393,16 @@ ParameterNameSegment %left '*' '/' %left UnarySign -%expect 1 +%expect 2 /* 1 conflict: When seeing a '*' token after a module parameter expression the parser cannot decide whether the token is a multiplication operator (shift) or it refers to all modules in the next module parameter (reduce). +1 conflict: +infinity can be a float value in LengthMatch's upper bound (SimpleParameterValue) +or an infinityKeyword. */ %% @@ -596,6 +605,10 @@ SimpleParameterValue: { $$ = new Module_Param_Float($1); } +| InfinityKeyword + { + $$ = new Module_Param_Float(INFINITY); + } | BooleanValue { $$ = new Module_Param_Boolean($1); diff --git a/mctr2/cli/config_read.l b/mctr2/cli/config_read.l index 606cde048..b0ba7810c 100644 --- a/mctr2/cli/config_read.l +++ b/mctr2/cli/config_read.l @@ -95,7 +95,7 @@ LINECOMMENT ("//"|"#")[^\r\n]*{NEWLINE} NUMBER 0|([1-9][0-9]*) -FLOAT [+-]?({NUMBER}\.[0-9]+)|((({NUMBER}(\.[0-9]+)?)|(\.[0-9]+))[Ee][+-]?{NUMBER})|infinity|not_a_number +FLOAT [+-]?({NUMBER}\.[0-9]+)|((({NUMBER}(\.[0-9]+)?)|(\.[0-9]+))[Ee][+-]?{NUMBER})|not_a_number BIN 0|1 BITSTRING '{BIN}*'B diff --git a/mctr2/cli/config_read.y b/mctr2/cli/config_read.y index e1833084c..0f66228c7 100644 --- a/mctr2/cli/config_read.y +++ b/mctr2/cli/config_read.y @@ -233,7 +233,7 @@ MPNumber %left '*' '/' %left UnarySign -%expect 1 +%expect 2 /* Source of conflicts (1 S/R): @@ -245,6 +245,9 @@ all modules in the next module parameter (reduce). The built-in Bison behavior always chooses the shift over the reduce (the * is interpreted as multiplication). +1 conflict: +infinity can be a float value in LengthMatch's upper bound (SimpleParameterValue) +or an infinityKeyword. */ %% @@ -331,6 +334,7 @@ ParameterReference: SimpleParameterValue: MPNumber { BN_free($1); } | MPFloat +| InfinityKeyword | BooleanValue | ObjIdValue | VerdictValue @@ -364,18 +368,35 @@ PatternChunk: IntegerRange: '(' '-' InfinityKeyword DotDot MPNumber ')' { BN_free($5); } +| '(' '-' InfinityKeyword DotDot '!' MPNumber ')' { BN_free($6); } | '(' MPNumber DotDot MPNumber ')' { BN_free($2); BN_free($4); } +| '(' '!' MPNumber DotDot MPNumber ')' { BN_free($3); BN_free($5); } +| '(' MPNumber DotDot '!' MPNumber ')' { BN_free($2); BN_free($5); } +| '(' '!' MPNumber DotDot '!' MPNumber ')' { BN_free($3); BN_free($6); } | '(' MPNumber DotDot InfinityKeyword ')' { BN_free($2); } +| '(' '!' MPNumber DotDot InfinityKeyword ')' { BN_free($3); } ; FloatRange: '(' '-' InfinityKeyword DotDot MPFloat ')' +| '(' '!' '-' InfinityKeyword DotDot MPFloat ')' +| '(' '-' InfinityKeyword DotDot '!' MPFloat ')' +| '(' '!' '-' InfinityKeyword DotDot '!' MPFloat ')' | '(' MPFloat DotDot MPFloat ')' +| '(' '!' MPFloat DotDot MPFloat ')' +| '(' MPFloat DotDot '!' MPFloat ')' +| '(' '!' MPFloat DotDot '!' MPFloat ')' | '(' MPFloat DotDot InfinityKeyword ')' +| '(' '!' MPFloat DotDot InfinityKeyword ')' +| '(' MPFloat DotDot '!' InfinityKeyword ')' +| '(' '!' MPFloat DotDot '!' InfinityKeyword ')' ; - + StringRange: '(' UniversalCharstringFragment DotDot UniversalCharstringFragment ')' +| '(' '!' UniversalCharstringFragment DotDot UniversalCharstringFragment ')' +| '(' UniversalCharstringFragment DotDot '!' UniversalCharstringFragment ')' +| '(' '!' UniversalCharstringFragment DotDot '!' UniversalCharstringFragment ')' IntegerValue: Number { $$ = $1; } diff --git a/regression_test/templateExclusiveRange/Makefile b/regression_test/templateExclusiveRange/Makefile index 850be31fb..3543d54b2 100644 --- a/regression_test/templateExclusiveRange/Makefile +++ b/regression_test/templateExclusiveRange/Makefile @@ -9,48 +9,57 @@ # Szabo, Bence Janos # ############################################################################## -TOPDIR := .. -include $(TOPDIR)/Makefile.regression +TOPDIR := ../ +include $(TOPDIR)/Makefile.regression -.SUFFIXES: .ttcn .hh -.PHONY: all clean dep run +FILES := ExclusiveRangeTemplate.ttcn ExclusiveRangeTemplateMP.ttcn config.cfg +RUNNABLE := ExclusiveRangeTemplate +CFG := config.cfg +DIR_SINGLE := dir_single_mode +DIR_PARALLEL := dir_parallel_mode +GENERATED_DIRS := $(DIR_SINGLE) $(DIR_PARALLEL) -TTCN3_LIB = ttcn3$(RT2_SUFFIX)$(DYNAMIC_SUFFIX) - -TTCN3_MODULES = ExclusiveRangeTemplate.ttcn ExclusiveRangeTemplateMP.ttcn - -GENERATED_SOURCES = $(TTCN3_MODULES:.ttcn=.cc) -GENERATED_HEADERS = $(GENERATED_SOURCES:.cc=.hh) -ifdef CODE_SPLIT -GENERATED_SOURCES := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), .cc _seq.cc _set.cc _seqof.cc _setof.cc _union.cc)) -else ifdef SPLIT_TO_SLICES -POSTFIXES := $(foreach file, $(SPLIT_TO_SLICES), $(addsuffix $(file), _part_)) -POSTFIXES := $(foreach file, $(POSTFIXES), $(addprefix $(file), .cc)) -GENERATED_SOURCES2 := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), $(POSTFIXES))) -GENERATED_SOURCES += $(GENERATED_SOURCES2) +COVERAGE_FLAG := +ifeq ($(COVERAGE), yes) + COVERAGE_FLAG += -C endif -OBJECTS = $(GENERATED_SOURCES:.cc=.o) - -TARGET = ExclusiveRangeTemplate$(EXESUFFIX) +ifdef DYN +ifeq ($(PLATFORM), WIN32) + export PATH+=:$(TTCN3_DIR)/lib:$(ABS_SRC)/$(DIR_SINGLE):$(ABS_SRC)/$(DIR_PARALLEL): +else + export LD_LIBRARY_PATH+=:$(ABS_SRC)/$(DIR_SINGLE):$(ABS_SRC)/$(DIR_PARALLEL): +endif +endif -all: $(TARGET) +MAKE_PROG := $(MAKE) -$(TARGET): $(GENERATED_SOURCES) $(USER_SOURCES) - $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ -L$(TTCN3_DIR)/lib -l$(TTCN3_LIB) -L$(OPENSSL_DIR)/lib -lcrypto $($(PLATFORM)_LIBS) +# List of fake targets: +.PHONY: all clean run run_single run_parallel runall -.ttcn.cc .ttcn.hh: - $(TTCN3_COMPILER) $< +all: $(GENERATED_DIRS) -clean distclean: - -rm -f $(TARGET) $(OBJECTS) $(GENERATED_HEADERS) \ - $(GENERATED_SOURCES) *.log Makefile.bak +dir_single_mode: + mkdir $@ + cd $@ && for file in $(FILES); do ln -s ../$$file || exit; done + cd $@ && $(TTCN3_DIR)/bin/ttcn3_makefilegen $(COVERAGE_FLAG) $(SPLIT_FLAG) $(RT2_FLAG) -s ./* && $(MAKE_PROG) + +dir_parallel_mode: + mkdir $@ + cd $@ && for file in $(FILES); do ln -s ../$$file || exit; done + cd $@ && $(TTCN3_DIR)/bin/ttcn3_makefilegen $(COVERAGE_FLAG) $(SPLIT_FLAG) $(RT2_FLAG) ./* && $(MAKE_PROG) -dep: $(GENERATED_SOURCES) - makedepend $(CPPFLAGS) $(GENERATED_SOURCES) +run: $(GENERATED_DIRS) + cd $(DIR_SINGLE) && ./$(RUNNABLE) $(CFG) + cd $(DIR_PARALLEL) && $(TTCN3_DIR)/bin/ttcn3_start $(RUNNABLE) $(CFG) -run: $(TARGET) config.cfg - ./$^ +# To run all tests, possibly in parallel +run_single: $(DIR_SINGLE) + cd $(DIR_SINGLE) && ./$(RUNNABLE) $(CFG) +run_parallel: $(DIR_PARALLEL) + cd $(DIR_PARALLEL) && $(TTCN3_DIR)/bin/ttcn3_start $(RUNNABLE) $(CFG) +runall: run_single run_parallel -.NOTPARALLEL: +clean distclean: + rm -rf $(GENERATED_DIRS) -- GitLab