Add the Faust programming language (#4688)

* Add the Faust programming language

* Add Faust samples

* Add the Microsoft .dsp format, and a heuristic against Faust files

* Add Microsoft DSP samples (Freeglut, MIT license)

* Simplify the pattern to detect Microsoft DSP, add it to generated.rb

* Add Faust and Microsoft DSP to the heuristic test suite

* Stop searching for the Microsoft DSP comment past the first 3 lines

* Limit the heuristic test of Faust to .dsp files

* Add an elaborate Faust pattern for .dsp heuristics

* For now, remove the .lib extension of the Faust language

* Set the Faust license manually

* Remove some .dsp sample files
This commit is contained in:
JP Cimalando 2020-01-06 11:14:31 +01:00 коммит произвёл Colin Seymour
Родитель a3f3f56d87
Коммит ccb71a915a
12 изменённых файлов: 381 добавлений и 1 удалений

3
.gitmodules поставляемый
Просмотреть файл

@ -506,6 +506,9 @@
[submodule "vendor/grammars/language-etc"]
path = vendor/grammars/language-etc
url = https://github.com/Alhadis/language-etc
[submodule "vendor/grammars/language-faust"]
path = vendor/grammars/language-faust
url = https://github.com/jpcima/language-faust
[submodule "vendor/grammars/language-fontforge"]
path = vendor/grammars/language-fontforge
url = https://github.com/Alhadis/language-fontforge

Просмотреть файл

@ -442,6 +442,8 @@ vendor/grammars/language-etc:
- source.ssh-config
- source.wgetrc
- text.xml.svg
vendor/grammars/language-faust:
- source.faust
vendor/grammars/language-fontforge:
- source.afm
- source.bdf

Просмотреть файл

@ -93,7 +93,8 @@ module Linguist
generated_dart? ||
generated_perl_ppport_header? ||
generated_gamemakerstudio? ||
generated_gimp?
generated_gimp? ||
generated_visualstudio6?
end
# Internal: Is the blob an Xcode file?
@ -618,6 +619,14 @@ module Linguist
lines[0].match(/\/\* GIMP header image file format \([a-zA-Z0-9\- ]+\)\: .+?\.h \*\//)
end
# Internal: Is this a generated Microsoft Visual Studio 6.0 build file?
#
# Return true or false
def generated_visualstudio6?
return false unless extname.downcase == '.dsp'
lines.first(3).any? { |l| l.include? '# Microsoft Developer Studio Generated Build File' }
end
# Internal: Is this a generated HTML file?
#
# HTML documents generated by authoring tools often include a

Просмотреть файл

@ -113,6 +113,12 @@ disambiguations:
# : dependency
# path/file.ext1 : some/path/../file.ext2
pattern: '([\/\\].*:\s+.*\s\\$|: \\$|^[ %]:|^[\w\s\/\\.]+\w+\.\w+\s*:\s+[\w\s\/\\.]+\w+\.\w+)'
- extensions: ['.dsp']
rules:
- language: Microsoft Developer Studio Project
pattern: '# Microsoft Developer Studio Generated Build File'
- language: Faust
pattern: '\bprocess\s*[(=]|\b(library|import)\s*\(\s*"|\bdeclare\s+(name|version|author|copyright|license)\s+"'
- extensions: ['.ecl']
rules:
- language: ECLiPSe

Просмотреть файл

@ -1455,6 +1455,14 @@ Fantom:
tm_scope: source.fan
ace_mode: text
language_id: 110
Faust:
type: programming
color: "#c37240"
extensions:
- ".dsp"
tm_scope: source.faust
ace_mode: text
language_id: 622529198
Filebench WML:
type: programming
extensions:
@ -3153,6 +3161,13 @@ Metal:
codemirror_mode: clike
codemirror_mime_type: text/x-c++src
language_id: 230
Microsoft Developer Studio Project:
type: data
extensions:
- ".dsp"
tm_scope: none
ace_mode: text
language_id: 800983837
MiniD:
type: programming
searchable: false

26
samples/Faust/FFT.dsp Normal file
Просмотреть файл

@ -0,0 +1,26 @@
// Radix 2 FFT, decimation in time, real and imag parts interleaved
declare name "FFT"; // Faust Fourier Transform :-)
declare author "JOS";
declare license "STK-4.3";
import("stdfaust.lib");
N=32; // FFT size (power of 2)
// Number of frequency bins (including dc and SR/2) is N/2+1
No2 = N>>1;
signal = amp * cosine with {
cosine = select2(k==0,
select2(k==No2,
2.0*os.oscrc(f(k)), // 2x since negative-frequencies not displayed
1-1':+~*(-1) // Alternating sequence: 1, -1, 1, -1
),
1.0); // make sure phase is zero (freq jumps around)
f(k) = float(k) * ma.SR / float(N); // only test FFT bin frequencies
k = hslider("[2] FFT Bin Number",N/4,0,No2,0.001) : int <: _,dpy : attach;
dpy = hbargraph("[3] Measured FFT Bin Number",0,No2);
amp = hslider("[4] Amplitude",0.1,0,1,0.001);
};
process = signal : dm.fft_spectral_level_demo(N) <: _,_;

40
samples/Faust/lowCut.dsp Normal file
Просмотреть файл

@ -0,0 +1,40 @@
// WARNING: This a "legacy example based on a deprecated library". Check filters.lib
// for more accurate examples of filter functions
declare name "lowcut";
declare version "1.0";
declare author "Grame";
declare license "BSD";
declare copyright "(c)GRAME 2006";
//------------------------------------------------------------------
// DAFX, Digital Audio Effects (Wiley ed.)
// chapter 2 : filters
// section 2.3 : Equalizers
// page 53 : second order shelving filter design
//------------------------------------------------------------------
import("stdfaust.lib");
//------------------- low-frequency shelving cut (table 2.3) --------------------
V0(g) = pow(10,g/-20.0);
K(fc) = tan(ma.PI*fc/ma.SR);
squ(x) = x*x;
denom(fc,g) = 1 + sqrt(2*V0(g))*K(fc) + V0(g)*squ(K(fc));
lfcut(fc, g) = fi.TF2((1 + sqrt(2)*K(fc) + squ(K(fc))) / denom(fc,g),
2 * (squ(K(fc)) - 1) / denom(fc,g),
(1 - sqrt(2)*K(fc) + squ(K(fc))) / denom(fc,g),
2 * (V0(g)*squ(K(fc)) - 1) / denom(fc,g),
(1 - sqrt(2*V0(g))*K(fc) + V0(g)*squ(K(fc))) / denom(fc,g));
//------------------------------ User Interface -----------------------------------
freq = hslider("freq [unit:Hz][style:knob]", 100, 20, 5000, 1);
att = hslider("attenuation [unit:dB][style:knob]", 0, -96, 10, 0.1);
//----------------------------------- Process -------------------------------------
process = vgroup("low-freq shelving cut", lfcut(freq,att));

Просмотреть файл

@ -0,0 +1,218 @@
# Microsoft Developer Studio Project File - Name="freeglut" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=freeglut - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "freeglut.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "freeglut.mak" CFG="freeglut - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "freeglut - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "freeglut - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "freeglut - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREEGLUT_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREEGLUT_EXPORTS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
!ELSEIF "$(CFG)" == "freeglut - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREEGLUT_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREEGLUT_EXPORTS" /FR /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "freeglut - Win32 Release"
# Name "freeglut - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\src\freeglut_callbacks.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_cursor.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_display.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_ext.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_font.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_font_data.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_gamemode.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_geometry.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_glutfont_definitions.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_init.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_input_devices.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_joystick.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_main.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_menu.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_misc.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_overlay.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_state.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_stroke_mono_roman.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_stroke_roman.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_structure.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_teapot.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_videoresize.c
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_window.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\include\GL\freeglut.h
# End Source File
# Begin Source File
SOURCE=.\include\GL\freeglut_ext.h
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_internal.h
# End Source File
# Begin Source File
SOURCE=.\include\GL\freeglut_std.h
# End Source File
# Begin Source File
SOURCE=.\src\freeglut_teapot_data.h
# End Source File
# Begin Source File
SOURCE=.\include\GL\glut.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

Просмотреть файл

@ -136,6 +136,13 @@ class TestHeuristics < Minitest::Test
}, "test.d")
end
def test_dsp_heuristics
assert_heuristics({
"Faust" => all_fixtures("Faust", "*.dsp"),
"Microsoft Developer Studio Project" => all_fixtures("Microsoft Developer Studio Project"),
})
end
def test_ecl_by_heuristics
assert_heuristics({
"ECL" => all_fixtures("ECL", "*.ecl"),

1
vendor/README.md поставляемый
Просмотреть файл

@ -121,6 +121,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
- **Factor:** [slavapestov/factor](https://github.com/slavapestov/factor)
- **Fancy:** [fancy-lang/fancy-tmbundle](https://github.com/fancy-lang/fancy-tmbundle)
- **Fantom:** [rkoeninger/sublime-fantom](https://github.com/rkoeninger/sublime-fantom)
- **Faust:** [jpcima/language-faust](https://github.com/jpcima/language-faust)
- **Forth:** [textmate/forth.tmbundle](https://github.com/textmate/forth.tmbundle)
- **Fortran:** [textmate/fortran.tmbundle](https://github.com/textmate/fortran.tmbundle)
- **FreeMarker:** [freemarker/FreeMarker.tmbundle](https://github.com/freemarker/FreeMarker.tmbundle)

1
vendor/grammars/language-faust поставляемый Submodule

@ -0,0 +1 @@
Subproject commit 93a620e7db713a9858c123e5be5e880ca53856c9

52
vendor/licenses/grammar/language-faust.txt поставляемый Normal file
Просмотреть файл

@ -0,0 +1,52 @@
---
type: grammar
name: language-faust
version: 93a620e7db713a9858c123e5be5e880ca53856c9
license: mit
---
Copyright (c) 2014 GitHub Inc.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------
This package was derived from a TextMate bundle located at
https://github.com/rsms/faust.tmbundle and distributed under the following
license, located in `LICENSE`:
Copyright (c) 2009 Rasmus Andersson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.