Home » Modeling » TMF (Xtext) » Format for specifying a list of source files for a DSL
Format for specifying a list of source files for a DSL [message #1708740] |
Sat, 19 September 2015 18:44 |
Elvis Dowson Messages: 65 Registered: December 2011 |
Member |
|
|
Hi,
I need to generate the following list of source files to exclude from a build, by inserting the following text snippet into a CMakeLists.txt file:
# Exclude specific files from the build.
set (CTR_SOURCES_EXCLUDE dir1/file1.cpp
dir1/file2.cpp
dir2/file3.cpp
dir2/file4.cpp)
What would be the best option to represent this list in my DSL?
project test_project {
// Project information.
name = "test_project";
description = "Test project";
version = "1.0";
// Exclude files.
exclude_files = "dir1/file1.cpp,
dir1/file2.cpp,
dir2/file3.cpp,
dir2/file4.cpp"; // Is there a better way to specify the list of files to exclude here?
}
Is there a better or more natural way to specify the list of exclude files, other than the one described above?
Regards,
Elvsi Dowson
[Updated on: Sat, 19 September 2015 18:57] Report message to a moderator
|
|
|
Re: Format for specifying a list of source files for a DSL [message #1709045 is a reply to message #1708740] |
Wed, 23 September 2015 14:19 |
Stephan Herrmann Messages: 1853 Registered: July 2009 |
Senior Member |
|
|
Quote:Is there a better or more natural way to specify the list of exclude files, other than the one described above?
Firstly, why hide the list inside the string, rather than saying:
exclude_files = "dir1/file1.cpp",
"dir1/file2.cpp",
"dir2/file3.cpp",
"dir2/file4.cpp";
Secondly, IMHO, using a quoted string for anything that is supposed to refer some existing thing is a bad smell. Question: is it necessary to cope with white space inside file names? If not I'd suggest:
exclude_files = dir1/file1.cpp,
dir1/file2.cpp,
dir2/file3.cpp,
dir2/file4.cpp;
Next you could challenge the necessity of semicolons and commas etc.
Or, if you want to reflect the directory structure, why not:
exclude_files = dir1 { file1.cpp, file2.cpp },
dir2 { file3.cpp, file4.cpp };
etc.
Quote:Is there a better or more natural way ...
What is "better" or "more natural" in your context?
Stephan
|
|
|
Re: Format for specifying a list of source files for a DSL [message #1709079 is a reply to message #1708740] |
Wed, 23 September 2015 19:23 |
Elvis Dowson Messages: 65 Registered: December 2011 |
Member |
|
|
Hi Stephane,
I like the following option for specifying the file list:
exclude_files = dir1 { file1.cpp, file2.cpp },
dir2 { file3.cpp, file4.cpp };
How can I go about refactoring my existing DSL, to incorporate this change? At the moment, all the ProjectTypes in the DSL simply take string value inputs. What should I do to be able to change each project type expression in a modular manner, e.g. change exclude_files to accept the above expression, but leave the rest the same?
// Project.
Project:
('abstract')? 'project' name=ID ('extends' superclass = [Project])? '{'
projectAttributes += ProjectAttribute*
('maintainer' maintainers = [Maintainer] ';')?
'}';
ProjectAttribute:
type=ProjectAttributeType (name=ID)? '=' expression=TerminalExpression ';';
ProjectAttributeType:
projectElementType=ProjectElementType (array ?= '[' (length=INT)? ']')?;
ProjectElementType:
ProjectType;
ProjectType:
typeName=('name' |
'description' |
'version' |
'license' |
'library' |
'executable' |
'tool' |
'include_directories' |
'header_files' |
'source_directories' |
'source_files' |
'exclude_files' |
'model_directories' |
'model_files' |
'build_dependency' |
'run_dependency' |
'test_dependency');
// Maintainer information.
Maintainer:
'maintainer' name=ID 'full_name' fullname=STRING 'email' email=STRING;
NameWithSpaces:
ID (WS)* (ID)*;
// Expressions.
TerminalExpression returns Expression:
{StringConstant} value=STRING |
{IntConstant} value=INT |
{BoolConstant} value = ('true' | 'false') |
{ProjectRef} (project += [Project] ("," project += [Project])*);
Regards,
Elvis Dowson
[Updated on: Wed, 23 September 2015 19:26] Report message to a moderator
|
|
| | | |
Goto Forum:
Current Time: Fri Apr 19 21:36:41 GMT 2024
Powered by FUDForum. Page generated in 0.02830 seconds
|