diff --git a/examples/examples_v2/CMakeLists.txt b/examples/examples_v2/CMakeLists.txt index 8bf707c1b3f..cefb74894ae 100644 --- a/examples/examples_v2/CMakeLists.txt +++ b/examples/examples_v2/CMakeLists.txt @@ -3,8 +3,6 @@ # Check which interfaces are turned on # Add CMakeLists file for each turned on interface -# Generate type list -#execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/generator/types/get_type_list.sh > ${CMAKE_CURRENT_SOURCE_DIR}/generator/types/typelist) # Check if PLY is installed find_package(PLY) @@ -12,6 +10,10 @@ IF(NOT PLY_FOUND) message(WARNING "Python module PLY was not found. This may cause example generation to be very slow.") ENDIF() +# Disabled (temporary) as non-portable solution. This is replaced by allowing any [a-zA-Z_][a-zA-Z0-9_]* as shogun keyword +# Generate type list +# execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/generator/types/get_type_list.sh > ${CMAKE_CURRENT_SOURCE_DIR}/generator/types/typelist) + # Run example generation script add_custom_target(shogun_meta_examples COMMAND ${PYTHON_EXECUTABLE} diff --git a/examples/examples_v2/generator/parse.py b/examples/examples_v2/generator/parse.py index ccbdc10188f..863b58b981c 100644 --- a/examples/examples_v2/generator/parse.py +++ b/examples/examples_v2/generator/parse.py @@ -26,12 +26,15 @@ def parse(self, programString, filePath="Unknown"): def shogunType(self): basepath = os.path.dirname(__file__) type = self.pp.Forward() - with open(os.path.join(basepath,"types/typelist"), "r") as typelist: - for line in typelist: - # Make sure the line is not an empty string - if line.replace('\n', '') != '': - type = type ^ self.pp.Literal(line.replace('\n', '')) + # This is probably a temporary solution, we treat any [a-zA-Z_][a-zA-Z0-9_]* as valid shogun keyword + type = type ^ self.pp.Word(self.pp.srange("[a-zA-Z_]"), self.pp.srange("[a-zA-Z0-9_]")) + + # with open(os.path.join(basepath,"types/typelist"), "r") as typelist: + # for line in typelist: + # # Make sure the line is not an empty string + # if line.replace('\n', '') != '': + # type = type ^ self.pp.Literal(line.replace('\n', '')) return type def grammar(self): @@ -426,4 +429,4 @@ def parse(programString, filePath): # Parse input and print json output program = parse(programString, filePath) - print json.dumps(program, indent=indentWidth) \ No newline at end of file + print json.dumps(program, indent=indentWidth)