From cbdc2a212c4c42dc321d616a61f0c1d65f72f64a Mon Sep 17 00:00:00 2001 From: James Gilles Date: Sat, 8 Apr 2017 18:04:46 -0400 Subject: [PATCH] Add scons, handle languages with no extensions --- README.md | 2 ++ languages.json | 26 ++++++++++++++++++++++++++ src/language/language_type.hbs.rs | 10 ++++++---- tests/data/SConstruct | 10 ++++++++++ 4 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 tests/data/SConstruct diff --git a/README.md b/README.md index 197632ef5..aad3f8db8 100644 --- a/README.md +++ b/README.md @@ -266,6 +266,7 @@ C Header C# C Shell Clojure +CMake CoffeeScript Cogent ColdFusion @@ -334,6 +335,7 @@ Ruby HTML Rust Sass Scala +Scons Standard ML SQL Swift diff --git a/languages.json b/languages.json index f7a40cac5..3b3a92153 100644 --- a/languages.json +++ b/languages.json @@ -1187,6 +1187,32 @@ "scala" ] }, + "Scons":{ + "base":"hash", + "quotes":[ + [ + "\\\"", + "\\\"" + ], + [ + "'", + "'" + ], + [ + "\\\"\\\"\\\"", + "\\\"\\\"\\\"" + ], + [ + "'''", + "'''" + ] + ], + "filenames":[ + "sconstruct", + "sconscript" + ] + }, + "Sml":{ "name":"Standard ML (SML)", "base":"func", diff --git a/src/language/language_type.hbs.rs b/src/language/language_type.hbs.rs index 95347be9f..826e8eded 100644 --- a/src/language/language_type.hbs.rs +++ b/src/language/language_type.hbs.rs @@ -85,10 +85,12 @@ impl LanguageType { if let Some(extension) = extension { match &*extension { {{~#each languages}} - {{~#each this.extensions}} - "{{~this}}" {{~#unless @last}} | {{~/unless}} - {{~/each}} - => Some({{~@key}}), + {{~#if this.extensions}} + {{~#each this.extensions}} + "{{~this}}" {{~#unless @last}} | {{~/unless}} + {{~/each}} + => Some({{~@key}}), + {{~/if}} {{~/each}} extension => { warn!("Unknown extension: {}", extension); diff --git a/tests/data/SConstruct b/tests/data/SConstruct new file mode 100644 index 000000000..d5a4641cb --- /dev/null +++ b/tests/data/SConstruct @@ -0,0 +1,10 @@ +#!python +# 10 lines 3 code 3 comments 4 blanks + +# this is a comment + +Program('cpp.cpp') # this is a line-ending comment + +env = Environment(CCFLAGS='-O3') +env.Append(CCFLAGS='-O3') +