From da50beaff1f4ad77ecc32e395e46ece052245865 Mon Sep 17 00:00:00 2001 From: Jorgen Brandt Date: Mon, 4 Jun 2018 22:17:44 +0200 Subject: [PATCH 1/5] Add Cuneiform to languages.yml and add samples --- lib/linguist/languages.yml | 12 ++ samples/Cuneiform/ackermann.cfl | 39 +++++ samples/Cuneiform/bash_test.cfl | 191 ++++++++++++++++++++ samples/Cuneiform/erlang_test.cfl | 186 ++++++++++++++++++++ samples/Cuneiform/fizzbuzz_matlab.cfl | 78 +++++++++ samples/Cuneiform/fizzbuzz_octave.cfl | 78 +++++++++ samples/Cuneiform/fizzbuzz_python.cfl | 74 ++++++++ samples/Cuneiform/java_test.cfl | 187 ++++++++++++++++++++ samples/Cuneiform/perl_test.cfl | 194 ++++++++++++++++++++ samples/Cuneiform/python_test.cfl | 187 ++++++++++++++++++++ samples/Cuneiform/r_test.cfl | 191 ++++++++++++++++++++ samples/Cuneiform/racket_test.cfl | 182 +++++++++++++++++++ samples/Cuneiform/variant-call.cfl.erb | 234 +++++++++++++++++++++++++ 13 files changed, 1833 insertions(+) create mode 100644 samples/Cuneiform/ackermann.cfl create mode 100644 samples/Cuneiform/bash_test.cfl create mode 100644 samples/Cuneiform/erlang_test.cfl create mode 100644 samples/Cuneiform/fizzbuzz_matlab.cfl create mode 100644 samples/Cuneiform/fizzbuzz_octave.cfl create mode 100644 samples/Cuneiform/fizzbuzz_python.cfl create mode 100644 samples/Cuneiform/java_test.cfl create mode 100644 samples/Cuneiform/perl_test.cfl create mode 100644 samples/Cuneiform/python_test.cfl create mode 100644 samples/Cuneiform/r_test.cfl create mode 100644 samples/Cuneiform/racket_test.cfl create mode 100644 samples/Cuneiform/variant-call.cfl.erb diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 542826b009..1c0ceb8efb 100755 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -615,6 +615,18 @@ CSV: extensions: - ".csv" language_id: 51 +Cuneiform: + type: programming + extensions: + - ".cf" + - ".cfl" + - ".cuneiform" + interpreters: + - "cuneiform" + - "cf_client" + color: "#2772b0" + tm_scope: none + language_id: 2699 CWeb: type: programming extensions: diff --git a/samples/Cuneiform/ackermann.cfl b/samples/Cuneiform/ackermann.cfl new file mode 100644 index 0000000000..78215ff630 --- /dev/null +++ b/samples/Cuneiform/ackermann.cfl @@ -0,0 +1,39 @@ + + +def inc( x : Str ) -> Str { + + def inc( x : Str ) -> in Python *{ + y = int( x )+1 + }* + + ( inc( x = x )|y ) +} + +def dec( x : Str ) -> Str { + + def dec( x : Str ) -> in Python *{ + y = int( x )-1 + }* + + ( dec( x = x )|y ) +} + +def ackermann( m : Str, n : Str ) -> Str { + if( m == 0 ) + then + inc( x = n ) + else + if( n == 0 ) + then + ackermann( + m = dec( x = m ), + n = 1 ) + else + ackermann( + m = dec( x = m ), + n = ackermann( m = m, n = dec( x = n ) ) ) + end + end +} + +ackermann( m = 2, n = 2 ); \ No newline at end of file diff --git a/samples/Cuneiform/bash_test.cfl b/samples/Cuneiform/bash_test.cfl new file mode 100644 index 0000000000..ada640775a --- /dev/null +++ b/samples/Cuneiform/bash_test.cfl @@ -0,0 +1,191 @@ +def forall( l : [Bool] ) -> Bool { + fold acc = true, x <- l do + (acc and x) + end +} + +def boolean_list_eq( l1 : [Bool], l2 : [Bool] ) -> Bool { + + def boolean_list_compare( l1 : [Bool], l2 : [Bool] ) -> [Bool] { + for x1 <- l1, x2 <- l2 do + ( ( x1 and x2 ) or not( x1 or x2 ) ) : Bool + end + } + + let cmp : [Bool] = boolean_list_compare( l1 = l1, l2 = l2 ); + forall( l = cmp ) +} + + +def string_list_eq( l1 : [Str], l2 : [Str] ) -> Bool { + + def string_list_compare( l1 : [Str], l2 : [Str] ) -> [Bool] { + for x1 <- l1, x2 <- l2 do + ( x1 == x2 ) : Bool + end + } + + let cmp : [Bool] = string_list_compare( l1 = l1, l2 = l2 ); + forall( l = cmp ) +} + + + + + + + def output_bool() -> +in Bash *{ + out1=true + out2=false +}* + +let = + output_bool(); + +let output_bool_test : Str = + if( not c1 or d1 ) + then + error "output_bool" : Str + else + "ok" + end; + + + + +def input_bool( a : Bool, b : Bool ) -> +in Bash *{ + if [ $a == 'true' ] + then + if [ $b == 'false' ] + then + out='ok' + else + exit -1 + fi + else + exit -1 + fi +}* + +let = + input_bool( a = true, b = false ); + + + + + +def output_string() -> +in Bash *{ + out='blub' +}* + +let = output_string(); + +let output_string_test : Str = + if( c2 == "blub" ) + then + "ok" + else + error "output_string" : Str + end; + + + + + + + +def input_string( a : Str ) -> +in Bash *{ + if [ $a == 'blub' ] + then + out='ok' + else + exit -1 + fi +}* + +let = + input_string( a = "blub" ); + + + +def output_boolean_list() -> +in Bash *{ + out=('true' 'false' 'true') +}* + +let = output_boolean_list(); + +let d3 : [Bool] = [true, false, true : Bool]; + +let output_boolean_list_test : Str = + if boolean_list_eq( l1 = c3, l2 = d3 ) + then + "ok" + else + error "output_boolean_list" : Str + end; + + + + + +def output_string_list() -> +in Bash *{ + out=('a' 'b' 'c') +}* + +let = output_string_list(); + +let d4 : [Str] = ["a", "b", "c" : Str]; + +let output_string_list_test : Str = + if string_list_eq( l1 = c4, l2 = d4 ) + then + "ok" + else + error "output_string_list" : Str + end; + + + + +def write_file( inp : Str ) -> +in Bash *{ + file='out.txt' + echo $inp >> $file +}* + +def read_file( file : File ) -> +in Bash *{ + out=`cat $file` +}* + +let c5 : Str = "blub"; + +let = + read_file( file = ( write_file( inp = c5 )|file ) ); + +let file_test : Str = + if( c5 == d5 ) + then + "ok" + else + error "file_test" : Str + end; + + + + +[output_bool_test, + input_bool_test, + output_string_test, + input_string_test, + output_boolean_list_test, + output_string_list_test, + file_test : Str]; + + diff --git a/samples/Cuneiform/erlang_test.cfl b/samples/Cuneiform/erlang_test.cfl new file mode 100644 index 0000000000..6b7385c6c1 --- /dev/null +++ b/samples/Cuneiform/erlang_test.cfl @@ -0,0 +1,186 @@ +def forall( l : [Bool] ) -> Bool { + fold acc = true, x <- l do + (acc and x) + end +} + +def boolean_list_eq( l1 : [Bool], l2 : [Bool] ) -> Bool { + + def boolean_list_compare( l1 : [Bool], l2 : [Bool] ) -> [Bool] { + for x1 <- l1, x2 <- l2 do + ( ( x1 and x2 ) or not( x1 or x2 ) ) : Bool + end + } + + let cmp : [Bool] = boolean_list_compare( l1 = l1, l2 = l2 ); + forall( l = cmp ) +} + + +def string_list_eq( l1 : [Str], l2 : [Str] ) -> Bool { + + def string_list_compare( l1 : [Str], l2 : [Str] ) -> [Bool] { + for x1 <- l1, x2 <- l2 do + ( x1 == x2 ) : Bool + end + } + + let cmp : [Bool] = string_list_compare( l1 = l1, l2 = l2 ); + forall( l = cmp ) +} + + + + + + + def output_bool() -> +in Erlang *{ + Out1 = true, + Out2 = false +}* + +let = + output_bool(); + +let output_bool_test : Str = + if( not c1 or d1 ) + then + error "output_bool" : Str + else + "ok" + end; + + + + +def input_bool( A : Bool, B : Bool ) -> +in Erlang *{ + + Out = + if + A and not B -> "ok"; + true -> error( "bad input binding" ) + end +}* + +let = + input_bool( A = true, B = false ); + + + + + +def output_string() -> +in Erlang *{ + Out = "blub" +}* + +let = output_string(); + +let output_string_test : Str = + if( c2 == "blub" ) + then + "ok" + else + error "output_string" : Str + end; + + + + + + + +def input_string( A : Str ) -> +in Erlang *{ + Out = + if + A =:= "blub" -> "ok"; + true -> error( "bad input binding" ) + end +}* + +let = + input_string( A = "blub" ); + + + +def output_boolean_list() -> +in Erlang *{ + Out = [true, false, true] +}* + +let = output_boolean_list(); + +let d3 : [Bool] = [true, false, true : Bool]; + +let output_boolean_list_test : Str = + if boolean_list_eq( l1 = c3, l2 = d3 ) + then + "ok" + else + error "output_boolean_list" : Str + end; + + + + + +def output_string_list() -> +in Erlang *{ + Out = ["a", "b", "c"] +}* + +let = output_string_list(); + +let d4 : [Str] = ["a", "b", "c" : Str]; + +let output_string_list_test : Str = + if string_list_eq( l1 = c4, l2 = d4 ) + then + "ok" + else + error "output_string_list" : Str + end; + + + + +def write_file( Inp : Str ) -> +in Erlang *{ + F = "out.txt", + ok = file:write_file( F, Inp ) +}* + +def read_file( F : File ) -> +in Erlang *{ + {ok, B} = file:read_file( F ), + Out = binary_to_list( B ) +}* + +let c5 : Str = "blub"; + +let = + read_file( F = ( write_file( Inp = c5 )|F ) ); + +let file_test : Str = + if( c5 == d5 ) + then + "ok" + else + error "file_test" : Str + end; + + + + +[output_bool_test, + input_bool_test, + output_string_test, + input_string_test, + output_boolean_list_test, + output_string_list_test, + file_test : Str]; + + diff --git a/samples/Cuneiform/fizzbuzz_matlab.cfl b/samples/Cuneiform/fizzbuzz_matlab.cfl new file mode 100644 index 0000000000..d4e4aafe43 --- /dev/null +++ b/samples/Cuneiform/fizzbuzz_matlab.cfl @@ -0,0 +1,78 @@ +%%==================================================================== +%% Functions +%%==================================================================== + + +def range( first : Str, last : Str ) -> + + +in Matlab *{ + a = str2num( first ); + b = str2num( last ); + m = a:b; + c = num2cell( m ); + number_lst = cellfun( @num2str, c, 'UniformOutput', false ); +}* + + +def is_multiple( number : Str, divisor : Str ) -> + + +in Matlab *{ + a = str2num( number ); + b = str2num( divisor ); + is_multiple = mod( a, b ) == 0; +}* + + +%%==================================================================== +%% Constants +%%==================================================================== + + +let last : Str = 100; + + +%%==================================================================== +%% Workflow +%%==================================================================== + + +let = + range( first = 1, + last = last ); + + +let fizzbuzz_lst : [Str] = + for x <- number_lst do + + let = + is_multiple( number = x, + divisor = 3 ); + + let = + is_multiple( number = x, + divisor = 5 ); + + if ( f and b ) then "FizzBuzz" + else + if f then "Fizz" + else + if b then "Buzz" + else + x + end + end + end + + : Str + + end; + + +%%==================================================================== +%% Query +%%==================================================================== + +fizzbuzz_lst; + diff --git a/samples/Cuneiform/fizzbuzz_octave.cfl b/samples/Cuneiform/fizzbuzz_octave.cfl new file mode 100644 index 0000000000..3a63ced372 --- /dev/null +++ b/samples/Cuneiform/fizzbuzz_octave.cfl @@ -0,0 +1,78 @@ +%%==================================================================== +%% Functions +%%==================================================================== + + +def range( first : Str, last : Str ) -> + + +in Octave *{ + a = str2num( first ); + b = str2num( last ); + m = a:b; + c = num2cell( m ); + number_lst = cellfun( @num2str, c, 'UniformOutput', false ); +}* + + +def is_multiple( number : Str, divisor : Str ) -> + + +in Octave *{ + a = str2num( number ); + b = str2num( divisor ); + is_multiple = mod( a, b ) == 0; +}* + + +%%==================================================================== +%% Constants +%%==================================================================== + + +let last : Str = 100; + + +%%==================================================================== +%% Workflow +%%==================================================================== + + +let = + range( first = 1, + last = last ); + + +let fizzbuzz_lst : [Str] = + for x <- number_lst do + + let = + is_multiple( number = x, + divisor = 3 ); + + let = + is_multiple( number = x, + divisor = 5 ); + + if ( f and b ) then "FizzBuzz" + else + if f then "Fizz" + else + if b then "Buzz" + else + x + end + end + end + + : Str + + end; + + +%%==================================================================== +%% Query +%%==================================================================== + +fizzbuzz_lst; + diff --git a/samples/Cuneiform/fizzbuzz_python.cfl b/samples/Cuneiform/fizzbuzz_python.cfl new file mode 100644 index 0000000000..3fc5f1f1cf --- /dev/null +++ b/samples/Cuneiform/fizzbuzz_python.cfl @@ -0,0 +1,74 @@ + + +%%==================================================================== +%% Functions +%%==================================================================== + + +def range( first : Str, last : Str ) -> + + +in Python *{ + number_lst = [str( x ) for x in range( int( first ), int( last )+1 )] +}* + + +def is_multiple( number : Str, divisor : Str ) -> + + +in Python *{ + is_multiple = int( number ) % int( divisor ) == 0 +}* + + +%%==================================================================== +%% Constants +%%==================================================================== + + +let last : Str = 100; + + +%%==================================================================== +%% Workflow +%%==================================================================== + + +let = + range( first = 1, + last = last ); + + +let fizzbuzz_lst : [Str] = + for x <- number_lst do + + let = + is_multiple( number = x, + divisor = 3 ); + + let = + is_multiple( number = x, + divisor = 5 ); + + if ( f and b ) then "FizzBuzz" + else + if f then "Fizz" + else + if b then "Buzz" + else + x + end + end + end + + : Str + + end; + + +%%==================================================================== +%% Query +%%==================================================================== + +fizzbuzz_lst; + diff --git a/samples/Cuneiform/java_test.cfl b/samples/Cuneiform/java_test.cfl new file mode 100644 index 0000000000..040fe6f7b8 --- /dev/null +++ b/samples/Cuneiform/java_test.cfl @@ -0,0 +1,187 @@ +def forall( l : [Bool] ) -> Bool { + fold acc = true, x <- l do + (acc and x) + end +} + +def boolean_list_eq( l1 : [Bool], l2 : [Bool] ) -> Bool { + + def boolean_list_compare( l1 : [Bool], l2 : [Bool] ) -> [Bool] { + for x1 <- l1, x2 <- l2 do + ( ( x1 and x2 ) or not( x1 or x2 ) ) : Bool + end + } + + let cmp : [Bool] = boolean_list_compare( l1 = l1, l2 = l2 ); + forall( l = cmp ) +} + + +def string_list_eq( l1 : [Str], l2 : [Str] ) -> Bool { + + def string_list_compare( l1 : [Str], l2 : [Str] ) -> [Bool] { + for x1 <- l1, x2 <- l2 do + ( x1 == x2 ) : Bool + end + } + + let cmp : [Bool] = string_list_compare( l1 = l1, l2 = l2 ); + forall( l = cmp ) +} + + + + + + + def output_bool() -> +in Java *{ + boolean out1 = true; + boolean out2 = false; +}* + +let = + output_bool(); + +let output_bool_test : Str = + if( not c1 or d1 ) + then + error "output_bool" : Str + else + "ok" + end; + + + + +def input_bool( a : Bool, b : Bool ) -> +in Java *{ + String out = "ok"; + if( !a || b ) + throw new RuntimeException( "bad input string" ); +}* + +let = + input_bool( a = true, b = false ); + + + + + +def output_string() -> +in Java *{ + String out = "blub"; +}* + +let = output_string(); + +let output_string_test : Str = + if( c2 == "blub" ) + then + "ok" + else + error "output_string" : Str + end; + + + + + + + +def input_string( a : Str ) -> +in Java *{ + String out = "ok"; + if( !( a.equals( "blub" ) ) ) + throw new RuntimeException( "bad input binding" ); +}* + +let = + input_string( a = "blub" ); + + + +def output_boolean_list() -> +in Java *{ + boolean[] out = {true, false, true }; +}* + +let = output_boolean_list(); + +let d3 : [Bool] = [true, false, true : Bool]; + +let output_boolean_list_test : Str = + if boolean_list_eq( l1 = c3, l2 = d3 ) + then + "ok" + else + error "output_boolean_list" : Str + end; + + + + + +def output_string_list() -> +in Java *{ + String[] out = { "a", "b", "c" }; +}* + +let = output_string_list(); + +let d4 : [Str] = ["a", "b", "c" : Str]; + +let output_string_list_test : Str = + if string_list_eq( l1 = c4, l2 = d4 ) + then + "ok" + else + error "output_string_list" : Str + end; + + + + +def write_file( inp : Str ) -> +in Java *{ + + String f = "out.txt"; + try( BufferedWriter w = new BufferedWriter( new FileWriter( new File( f ) ) ) ) { + w.write( inp ); + w.newLine(); + } +}* + +def read_file( f : File ) -> +in Java *{ + String out; + try( BufferedReader r = new BufferedReader( new FileReader( new File( f ) ) ) ) { + out = r.readLine(); + } +}* + +let c5 : Str = "blub"; + +let = + read_file( f = ( write_file( inp = c5 )|f ) ); + +let file_test : Str = + if( c5 == d5 ) + then + "ok" + else + error "file_test" : Str + end; + + + + +[output_bool_test, + input_bool_test, + output_string_test, + input_string_test, + output_boolean_list_test, + output_string_list_test, + file_test : Str]; + + diff --git a/samples/Cuneiform/perl_test.cfl b/samples/Cuneiform/perl_test.cfl new file mode 100644 index 0000000000..844631838b --- /dev/null +++ b/samples/Cuneiform/perl_test.cfl @@ -0,0 +1,194 @@ +def forall( l : [Bool] ) -> Bool { + fold acc = true, x <- l do + (acc and x) + end +} + +def boolean_list_eq( l1 : [Bool], l2 : [Bool] ) -> Bool { + + def boolean_list_compare( l1 : [Bool], l2 : [Bool] ) -> [Bool] { + for x1 <- l1, x2 <- l2 do + ( ( x1 and x2 ) or not( x1 or x2 ) ) : Bool + end + } + + let cmp : [Bool] = boolean_list_compare( l1 = l1, l2 = l2 ); + forall( l = cmp ) +} + + +def string_list_eq( l1 : [Str], l2 : [Str] ) -> Bool { + + def string_list_compare( l1 : [Str], l2 : [Str] ) -> [Bool] { + for x1 <- l1, x2 <- l2 do + ( x1 == x2 ) : Bool + end + } + + let cmp : [Bool] = string_list_compare( l1 = l1, l2 = l2 ); + forall( l = cmp ) +} + + + + + + +def output_bool() -> +in Perl *{ + $out1 = 1; + $out2 = 0; +}* + +let = + output_bool(); + +let output_bool_test : Str = + if( not c1 or d1 ) + then + error "output_bool" : Str + else + "ok" + end; + + + + +def input_bool( a : Bool, b : Bool ) -> +in Perl *{ + if( $a ) { + if( ! $b ) { + $out = "ok"; + } else { + die "Error!"; + } + } else { + die "Error!"; + } +}* + +let = + input_bool( a = true, b = false ); + + + + + +def output_string() -> +in Perl *{ + $out = "blub"; +}* + +let = output_string(); + +let output_string_test : Str = + if( c2 == "blub" ) + then + "ok" + else + error "output_string" : Str + end; + + + + + + + +def input_string( a : Str ) -> +in Perl *{ + if( $a eq "blub" ) { + $out = "ok"; + } else { + die "Error!"; + } +}* + +let = + input_string( a = "blub" ); + + + +def output_boolean_list() -> +in Perl *{ + @out = (1, 0, 1); +}* + +let = output_boolean_list(); + +let d3 : [Bool] = [true, false, true : Bool]; + +let output_boolean_list_test : Str = + if boolean_list_eq( l1 = c3, l2 = d3 ) + then + "ok" + else + error "output_boolean_list" : Str + end; + + + + + +def output_string_list() -> +in Perl *{ + @out = ("a", "b", "c"); +}* + +let = output_string_list(); + +let d4 : [Str] = ["a", "b", "c" : Str]; + +let output_string_list_test : Str = + if string_list_eq( l1 = c4, l2 = d4 ) + then + "ok" + else + error "output_string_list" : Str + end; + + + + +def write_file( inp : Str ) -> +in Perl *{ + $f = "out.txt"; + open( $fh, '>', $f ) or die "Could not open file '$filename' $!"; + print $fh "$inp\n"; + close $fh; +}* + +def read_file( f : File ) -> +in Perl *{ + open( $fh, '<:encoding(UTF-8)', $f ) + or die "Could not open file '$filename $!"; + $out = <$fh>; + chomp $out; + close $fh; +}* + +let c5 : Str = "blub"; + +let = + read_file( f = ( write_file( inp = c5 )|f ) ); + +let file_test : Str = + if( c5 == d5 ) + then + "ok" + else + error "file_test" : Str + end; + + + + +[output_bool_test, + input_bool_test, + output_string_test, + input_string_test, + output_boolean_list_test, + output_string_list_test, + file_test : Str]; + + diff --git a/samples/Cuneiform/python_test.cfl b/samples/Cuneiform/python_test.cfl new file mode 100644 index 0000000000..d172b3305a --- /dev/null +++ b/samples/Cuneiform/python_test.cfl @@ -0,0 +1,187 @@ +def forall( l : [Bool] ) -> Bool { + fold acc = true, x <- l do + (acc and x) + end +} + +def boolean_list_eq( l1 : [Bool], l2 : [Bool] ) -> Bool { + + def boolean_list_compare( l1 : [Bool], l2 : [Bool] ) -> [Bool] { + for x1 <- l1, x2 <- l2 do + ( ( x1 and x2 ) or not( x1 or x2 ) ) : Bool + end + } + + let cmp : [Bool] = boolean_list_compare( l1 = l1, l2 = l2 ); + forall( l = cmp ) +} + + +def string_list_eq( l1 : [Str], l2 : [Str] ) -> Bool { + + def string_list_compare( l1 : [Str], l2 : [Str] ) -> [Bool] { + for x1 <- l1, x2 <- l2 do + ( x1 == x2 ) : Bool + end + } + + let cmp : [Bool] = string_list_compare( l1 = l1, l2 = l2 ); + forall( l = cmp ) +} + + + + + + +def output_bool() -> +in Python *{ + out1=True + out2=False +}* + +let = + output_bool(); + +let output_bool_test : Str = + if( not c1 or d1 ) + then + error "output_bool" : Str + else + "ok" + end; + + + + +def input_bool( a : Bool, b : Bool ) -> +in Python *{ + if a: + if not b: + out='ok' + else: + exit( -1 ) + else: + exit( -1 ) +}* + +let = + input_bool( a = true, b = false ); + + + + + +def output_string() -> +in Python *{ + out = 'blub' +}* + +let = output_string(); + +let output_string_test : Str = + if( c2 == "blub" ) + then + "ok" + else + error "output_string" : Str + end; + + + + + + + +def input_string( a : Str ) -> +in Python *{ + if a == 'blub': + out='ok' + else: + exit( -1 ) +}* + +let = + input_string( a = "blub" ); + + + +def output_boolean_list() -> +in Python *{ + out = [True, False, True] +}* + +let = output_boolean_list(); + +let d3 : [Bool] = [true, false, true : Bool]; + +let output_boolean_list_test : Str = + if boolean_list_eq( l1 = c3, l2 = d3 ) + then + "ok" + else + error "output_boolean_list" : Str + end; + + + + + +def output_string_list() -> +in Python *{ + out = ['a', 'b', 'c'] +}* + +let = output_string_list(); + +let d4 : [Str] = ["a", "b", "c" : Str]; + +let output_string_list_test : Str = + if string_list_eq( l1 = c4, l2 = d4 ) + then + "ok" + else + error "output_string_list" : Str + end; + + + + +def write_file( inp : Str ) -> +in Python *{ + f = 'out.txt' + with open( f, 'w') as the_file: + the_file.write( inp ) +}* + +def read_file( f : File ) -> +in Python *{ + with open( f, 'r' ) as the_file: + out = the_file.readline() +}* + +let c5 : Str = "blub"; + +let = + read_file( f = ( write_file( inp = c5 )|f ) ); + +let file_test : Str = + if( c5 == d5 ) + then + "ok" + else + error "file_test" : Str + end; + + + + +[output_bool_test, + input_bool_test, + output_string_test, + input_string_test, + output_boolean_list_test, + output_string_list_test, + file_test : Str]; + + diff --git a/samples/Cuneiform/r_test.cfl b/samples/Cuneiform/r_test.cfl new file mode 100644 index 0000000000..4f57db55be --- /dev/null +++ b/samples/Cuneiform/r_test.cfl @@ -0,0 +1,191 @@ +def forall( l : [Bool] ) -> Bool { + fold acc = true, x <- l do + (acc and x) + end +} + +def boolean_list_eq( l1 : [Bool], l2 : [Bool] ) -> Bool { + + def boolean_list_compare( l1 : [Bool], l2 : [Bool] ) -> [Bool] { + for x1 <- l1, x2 <- l2 do + ( ( x1 and x2 ) or not( x1 or x2 ) ) : Bool + end + } + + let cmp : [Bool] = boolean_list_compare( l1 = l1, l2 = l2 ); + forall( l = cmp ) +} + + +def string_list_eq( l1 : [Str], l2 : [Str] ) -> Bool { + + def string_list_compare( l1 : [Str], l2 : [Str] ) -> [Bool] { + for x1 <- l1, x2 <- l2 do + ( x1 == x2 ) : Bool + end + } + + let cmp : [Bool] = string_list_compare( l1 = l1, l2 = l2 ); + forall( l = cmp ) +} + + + + + + +def output_bool() -> +in R *{ + out1 = TRUE + out2 = FALSE +}* + +let = + output_bool(); + +let output_bool_test : Str = + if( not c1 or d1 ) + then + error "output_bool" : Str + else + "ok" + end; + + + + +def input_bool( a : Bool, b : Bool ) -> +in R *{ + if( a ) { + if( ! b ) { + out= "ok" + } else { + stop( -1 ) + } + } else { + stop( -1 ) + } +}* + +let = + input_bool( a = true, b = false ); + + + + + +def output_string() -> +in R *{ + out = "blub" +}* + +let = output_string(); + +let output_string_test : Str = + if( c2 == "blub" ) + then + "ok" + else + error "output_string" : Str + end; + + + + + + + +def input_string( a : Str ) -> +in R *{ + if( a == "blub" ) { + out="ok" + } else { + stop( -1 ) + } +}* + +let = + input_string( a = "blub" ); + + + +def output_boolean_list() -> +in R *{ + out = c( TRUE, FALSE, TRUE ) +}* + +let = output_boolean_list(); + +let d3 : [Bool] = [true, false, true : Bool]; + +let output_boolean_list_test : Str = + if boolean_list_eq( l1 = c3, l2 = d3 ) + then + "ok" + else + error "output_boolean_list" : Str + end; + + + + + +def output_string_list() -> +in R *{ + out = c( "a", "b", "c" ) +}* + +let = output_string_list(); + +let d4 : [Str] = ["a", "b", "c" : Str]; + +let output_string_list_test : Str = + if string_list_eq( l1 = c4, l2 = d4 ) + then + "ok" + else + error "output_string_list" : Str + end; + + + + +def write_file( inp : Str ) -> +in R *{ + f = "out.txt" + con = file( f ) + writeLines( inp, con ) + close( con ) +}* + +def read_file( f : File ) -> +in R *{ + con = file( f ) + out = readLines( con ) +}* + +let c5 : Str = "blub"; + +let = + read_file( f = ( write_file( inp = c5 )|f ) ); + +let file_test : Str = + if( c5 == d5 ) + then + "ok" + else + error "file_test" : Str + end; + + + + +[output_bool_test, + input_bool_test, + output_string_test, + input_string_test, + output_boolean_list_test, + output_string_list_test, + file_test : Str]; + + diff --git a/samples/Cuneiform/racket_test.cfl b/samples/Cuneiform/racket_test.cfl new file mode 100644 index 0000000000..4a6de94c8b --- /dev/null +++ b/samples/Cuneiform/racket_test.cfl @@ -0,0 +1,182 @@ +def forall( l : [Bool] ) -> Bool { + fold acc = true, x <- l do + (acc and x) + end +} + +def boolean_list_eq( l1 : [Bool], l2 : [Bool] ) -> Bool { + + def boolean_list_compare( l1 : [Bool], l2 : [Bool] ) -> [Bool] { + for x1 <- l1, x2 <- l2 do + ( ( x1 and x2 ) or not( x1 or x2 ) ) : Bool + end + } + + let cmp : [Bool] = boolean_list_compare( l1 = l1, l2 = l2 ); + forall( l = cmp ) +} + + +def string_list_eq( l1 : [Str], l2 : [Str] ) -> Bool { + + def string_list_compare( l1 : [Str], l2 : [Str] ) -> [Bool] { + for x1 <- l1, x2 <- l2 do + ( x1 == x2 ) : Bool + end + } + + let cmp : [Bool] = string_list_compare( l1 = l1, l2 = l2 ); + forall( l = cmp ) +} + + + + + + + def output_bool() -> +in Racket *{ + (define out1 #t) + (define out2 #f) +}* + +let = + output_bool(); + +let output_bool_test : Str = + if( not c1 or d1 ) + then + error "output_bool" : Str + else + "ok" + end; + + + + +def input_bool( a : Bool, b : Bool ) -> +in Racket *{ + (define out + (if (and a (not b)) "ok" (error "bad input binding"))) +}* + +let = + input_bool( a = true, b = false ); + + + + + +def output_string() -> +in Racket *{ + (define out "blub") +}* + +let = output_string(); + +let output_string_test : Str = + if( c2 == "blub" ) + then + "ok" + else + error "output_string" : Str + end; + + + + + + + +def input_string( a : Str ) -> +in Racket *{ + (define out (if (equal? a "blub") "ok" (error "bad input binding"))) +}* + +let = + input_string( a = "blub" ); + + + +def output_boolean_list() -> +in Racket *{ + (define out '(#t #f #t)) +}* + +let = output_boolean_list(); + +let d3 : [Bool] = [true, false, true : Bool]; + +let output_boolean_list_test : Str = + if boolean_list_eq( l1 = c3, l2 = d3 ) + then + "ok" + else + error "output_boolean_list" : Str + end; + + + + + +def output_string_list() -> +in Racket *{ + (define out '("a" "b" "c")) +}* + +let = output_string_list(); + +let d4 : [Str] = ["a", "b", "c" : Str]; + +let output_string_list_test : Str = + if string_list_eq( l1 = c4, l2 = d4 ) + then + "ok" + else + error "output_string_list" : Str + end; + + + + +def write_file( inp : Str ) -> +in Racket *{ + (define f "out.txt") + (call-with-output-file + f + (lambda (output-port) (writeln inp output-port))) +}* + +def read_file( f : File ) -> +in Racket *{ + (define out + (call-with-input-file + f + (lambda (input-port) (read-line input-port)))) +}* + +let c5 : Str = "blub"; + +let = + read_file( f = ( write_file( inp = c5 )|f ) ); + +let file_test : Str = + if( c5 == d5 ) + then + "ok" + else + error "file_test" : Str + end; + + + + +[output_bool_test, + input_bool_test, + output_string_test, + input_string_test, + output_boolean_list_test, + output_string_list_test, + file_test : Str]; + + diff --git a/samples/Cuneiform/variant-call.cfl.erb b/samples/Cuneiform/variant-call.cfl.erb new file mode 100644 index 0000000000..ef5f789f60 --- /dev/null +++ b/samples/Cuneiform/variant-call.cfl.erb @@ -0,0 +1,234 @@ +% VARIANT-CALL +% +% A variant calling workflow. +% +% Sample data can be obtained from: +% ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/phase3/data/HG02025/sequence_read/ +% +% The HG38 reference genome can be downloaded from +% http://hgdownload.soe.ucsc.edu/goldenPath/hg38/chromosomes/ +% +% An Annovar HG38 database is expected to reside in +% /opt/data/annodb_hg38 +% +% In addition to a Cuneiform interpreter the following tools need to be +% installed to run this analysis: +% - FastQC 0.11.4 +% - Bowtie2 2.2.6 +% - SAMtools 1.2 +% - VarScan 2.3.9 +% - Annovar + +%% ============================================================ +%% Task definitions +%% ============================================================ + +def untar( tar : File ) -> + + +in Bash*{ + tar xf $tar + fileLst=`tar tf $tar` +}* + + +def gunzip( gz : File ) -> + + +in Bash *{ + file=unzipped_${gz%.gz} + gzip -c -d $gz > $file +}* + + +def fastqc( fastq : File ) -> + + +in Bash *{ + fastqc -f fastq --noextract -o ./ $fastq + zip=`ls *.zip` +}* + + +def bowtie2Build( fa : File ) -> + + +in Bash *{ + bowtie2-build $fa bt2idx + idx=idx.tar + tar cf $idx --remove-files bt2idx.* +}* + + +def bowtie2Align( idx : File, fastq1 : File, fastq2 : File ) -> + + +in Bash *{ + tar xf $idx + bam=alignment.bam + bowtie2 -D 5 -R 1 -N 0 -L 22 -i S,0,2.50 --no-unal -x bt2idx \ + -1 $fastq1 -2 $fastq2 -S - | samtools view -b - > $bam + rm bt2idx.* +}* + + +def samtoolsFaidx( fa : File ) -> + + +in Bash *{ + samtools faidx $fa + fai=$fa.fai +}* + + +def samtoolsSort( bam : File ) -> + + +in Bash *{ + sorted=sorted.bam + samtools sort -m 2G $bam -o $sorted +}* + + +def samtoolsMpileup( bam : File, fa : File, fai : File ) -> + + +in Bash *{ + ln -sf $fai $fa.fai + mpileup=mpileup.csv + samtools mpileup -f $fa $bam > $mpileup +}* + + +def samtoolsMerge( bamLst : [File] ) -> + + +{ + + def samtoolsMerge( bamLst : [File] ) -> + + + in Bash *{ + merged=merged.bam + if [ ${#bamLst[@]} -eq "1" ] + then + merged=$bam + else + samtools merge -f $merged ${bamLst[@]} + fi + }* + + + if isnil bamLst + then + error "Merge list must not be empty." : + else + samtoolsMerge( bamLst = bamLst ) + end +} + + +def varscan( mpileup : File ) -> + + +in Bash *{ + vcf=variants.vcf + varscan mpileup2snp $mpileup --output-vcf --p-value 99e-02 > $vcf +}* + + +def annovar( vcfLst : [File], db : Str, buildVsn : Str ) -> + + +in Bash *{ + fun=table.variant_function + exonicFun=table.exonic_variant_function + cat ${vcfLst[@]} | \ + convert2annovar.pl -format vcf4 - | \ + annotate_variation.pl -buildver $buildVsn -geneanno -outfile table - $db +}* + + +%% ============================================================ +%% Input data +%% ============================================================ + +let hg38Tar : File = + 'hg38/hg38.tar'; + +let fastq1LstGz : [File] = + ['kgenomes/SRR359188_1.filt.fastq.gz', + 'kgenomes/SRR359195_1.filt.fastq.gz' : File]; + +let fastq2LstGz : [File] = + ['kgenomes/SRR359188_2.filt.fastq.gz', + 'kgenomes/SRR359195_2.filt.fastq.gz' : File]; + +let db : Str = + "/opt/data/annodb_hg38"; + +let buildVsn : Str = + "hg38"; + + +%% ============================================================ +%% Workflow definition +%% ============================================================ + +let = + untar( tar = hg38Tar ); + +let fastq1Lst : [File] = + for gz <- fastq1LstGz do + ( gunzip( gz = gz )|file ) : File + end; + +let fastq2Lst : [File] = + for gz <- fastq2LstGz do + ( gunzip( gz = gz )|file ) : File + end; + +let qcLst : [File] = + for fastq <- ( fastq1Lst+fastq2Lst ) do + ( fastqc( fastq = fastq )|zip ) : File + end; + +let vcfLst : [File] = + for fa <- faLst do + + let = + bowtie2Build( fa = fa ); + + let = + samtoolsFaidx( fa = fa ); + + let sortedLst : [File] = + for fastq1 <- fastq1Lst, fastq2 <- fastq2Lst do + + let = + bowtie2Align( idx = idx, fastq1 = fastq1, fastq2 = fastq2 ); + + ( samtoolsSort( bam = bam )|sorted ) : File + + end; + + let = + samtoolsMerge( bamLst = sortedLst ); + + let = + samtoolsMpileup( bam = merged, fa = fa, fai = fai ); + + ( varscan( mpileup = mpileup )|vcf ) : File + + end; + +let = + annovar( vcfLst = vcfLst, db = db, buildVsn = buildVsn ); + + +%% ============================================================ +%% Query +%% ============================================================ + +; + From c7b73e26f945ee39a4f2de8044d0f7960c427717 Mon Sep 17 00:00:00 2001 From: Jorgen Brandt Date: Mon, 4 Jun 2018 22:26:44 +0200 Subject: [PATCH 2/5] Remove unused language extensions --- lib/linguist/languages.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 1c0ceb8efb..f29ff2b3bd 100755 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -618,9 +618,7 @@ CSV: Cuneiform: type: programming extensions: - - ".cf" - ".cfl" - - ".cuneiform" interpreters: - "cuneiform" - "cf_client" From 8ac72d46933b97f69ad313e63b48f2968e5d4190 Mon Sep 17 00:00:00 2001 From: Jorgen Brandt Date: Mon, 4 Jun 2018 22:32:08 +0200 Subject: [PATCH 3/5] Delete repeating examples --- samples/Cuneiform/bash_test.cfl | 191 ------------------------- samples/Cuneiform/erlang_test.cfl | 186 ------------------------ samples/Cuneiform/fizzbuzz_matlab.cfl | 78 ----------- samples/Cuneiform/fizzbuzz_octave.cfl | 78 ----------- samples/Cuneiform/java_test.cfl | 187 ------------------------- samples/Cuneiform/perl_test.cfl | 194 -------------------------- samples/Cuneiform/python_test.cfl | 187 ------------------------- samples/Cuneiform/racket_test.cfl | 182 ------------------------ 8 files changed, 1283 deletions(-) delete mode 100644 samples/Cuneiform/bash_test.cfl delete mode 100644 samples/Cuneiform/erlang_test.cfl delete mode 100644 samples/Cuneiform/fizzbuzz_matlab.cfl delete mode 100644 samples/Cuneiform/fizzbuzz_octave.cfl delete mode 100644 samples/Cuneiform/java_test.cfl delete mode 100644 samples/Cuneiform/perl_test.cfl delete mode 100644 samples/Cuneiform/python_test.cfl delete mode 100644 samples/Cuneiform/racket_test.cfl diff --git a/samples/Cuneiform/bash_test.cfl b/samples/Cuneiform/bash_test.cfl deleted file mode 100644 index ada640775a..0000000000 --- a/samples/Cuneiform/bash_test.cfl +++ /dev/null @@ -1,191 +0,0 @@ -def forall( l : [Bool] ) -> Bool { - fold acc = true, x <- l do - (acc and x) - end -} - -def boolean_list_eq( l1 : [Bool], l2 : [Bool] ) -> Bool { - - def boolean_list_compare( l1 : [Bool], l2 : [Bool] ) -> [Bool] { - for x1 <- l1, x2 <- l2 do - ( ( x1 and x2 ) or not( x1 or x2 ) ) : Bool - end - } - - let cmp : [Bool] = boolean_list_compare( l1 = l1, l2 = l2 ); - forall( l = cmp ) -} - - -def string_list_eq( l1 : [Str], l2 : [Str] ) -> Bool { - - def string_list_compare( l1 : [Str], l2 : [Str] ) -> [Bool] { - for x1 <- l1, x2 <- l2 do - ( x1 == x2 ) : Bool - end - } - - let cmp : [Bool] = string_list_compare( l1 = l1, l2 = l2 ); - forall( l = cmp ) -} - - - - - - - def output_bool() -> -in Bash *{ - out1=true - out2=false -}* - -let = - output_bool(); - -let output_bool_test : Str = - if( not c1 or d1 ) - then - error "output_bool" : Str - else - "ok" - end; - - - - -def input_bool( a : Bool, b : Bool ) -> -in Bash *{ - if [ $a == 'true' ] - then - if [ $b == 'false' ] - then - out='ok' - else - exit -1 - fi - else - exit -1 - fi -}* - -let = - input_bool( a = true, b = false ); - - - - - -def output_string() -> -in Bash *{ - out='blub' -}* - -let = output_string(); - -let output_string_test : Str = - if( c2 == "blub" ) - then - "ok" - else - error "output_string" : Str - end; - - - - - - - -def input_string( a : Str ) -> -in Bash *{ - if [ $a == 'blub' ] - then - out='ok' - else - exit -1 - fi -}* - -let = - input_string( a = "blub" ); - - - -def output_boolean_list() -> -in Bash *{ - out=('true' 'false' 'true') -}* - -let = output_boolean_list(); - -let d3 : [Bool] = [true, false, true : Bool]; - -let output_boolean_list_test : Str = - if boolean_list_eq( l1 = c3, l2 = d3 ) - then - "ok" - else - error "output_boolean_list" : Str - end; - - - - - -def output_string_list() -> -in Bash *{ - out=('a' 'b' 'c') -}* - -let = output_string_list(); - -let d4 : [Str] = ["a", "b", "c" : Str]; - -let output_string_list_test : Str = - if string_list_eq( l1 = c4, l2 = d4 ) - then - "ok" - else - error "output_string_list" : Str - end; - - - - -def write_file( inp : Str ) -> -in Bash *{ - file='out.txt' - echo $inp >> $file -}* - -def read_file( file : File ) -> -in Bash *{ - out=`cat $file` -}* - -let c5 : Str = "blub"; - -let = - read_file( file = ( write_file( inp = c5 )|file ) ); - -let file_test : Str = - if( c5 == d5 ) - then - "ok" - else - error "file_test" : Str - end; - - - - -[output_bool_test, - input_bool_test, - output_string_test, - input_string_test, - output_boolean_list_test, - output_string_list_test, - file_test : Str]; - - diff --git a/samples/Cuneiform/erlang_test.cfl b/samples/Cuneiform/erlang_test.cfl deleted file mode 100644 index 6b7385c6c1..0000000000 --- a/samples/Cuneiform/erlang_test.cfl +++ /dev/null @@ -1,186 +0,0 @@ -def forall( l : [Bool] ) -> Bool { - fold acc = true, x <- l do - (acc and x) - end -} - -def boolean_list_eq( l1 : [Bool], l2 : [Bool] ) -> Bool { - - def boolean_list_compare( l1 : [Bool], l2 : [Bool] ) -> [Bool] { - for x1 <- l1, x2 <- l2 do - ( ( x1 and x2 ) or not( x1 or x2 ) ) : Bool - end - } - - let cmp : [Bool] = boolean_list_compare( l1 = l1, l2 = l2 ); - forall( l = cmp ) -} - - -def string_list_eq( l1 : [Str], l2 : [Str] ) -> Bool { - - def string_list_compare( l1 : [Str], l2 : [Str] ) -> [Bool] { - for x1 <- l1, x2 <- l2 do - ( x1 == x2 ) : Bool - end - } - - let cmp : [Bool] = string_list_compare( l1 = l1, l2 = l2 ); - forall( l = cmp ) -} - - - - - - - def output_bool() -> -in Erlang *{ - Out1 = true, - Out2 = false -}* - -let = - output_bool(); - -let output_bool_test : Str = - if( not c1 or d1 ) - then - error "output_bool" : Str - else - "ok" - end; - - - - -def input_bool( A : Bool, B : Bool ) -> -in Erlang *{ - - Out = - if - A and not B -> "ok"; - true -> error( "bad input binding" ) - end -}* - -let = - input_bool( A = true, B = false ); - - - - - -def output_string() -> -in Erlang *{ - Out = "blub" -}* - -let = output_string(); - -let output_string_test : Str = - if( c2 == "blub" ) - then - "ok" - else - error "output_string" : Str - end; - - - - - - - -def input_string( A : Str ) -> -in Erlang *{ - Out = - if - A =:= "blub" -> "ok"; - true -> error( "bad input binding" ) - end -}* - -let = - input_string( A = "blub" ); - - - -def output_boolean_list() -> -in Erlang *{ - Out = [true, false, true] -}* - -let = output_boolean_list(); - -let d3 : [Bool] = [true, false, true : Bool]; - -let output_boolean_list_test : Str = - if boolean_list_eq( l1 = c3, l2 = d3 ) - then - "ok" - else - error "output_boolean_list" : Str - end; - - - - - -def output_string_list() -> -in Erlang *{ - Out = ["a", "b", "c"] -}* - -let = output_string_list(); - -let d4 : [Str] = ["a", "b", "c" : Str]; - -let output_string_list_test : Str = - if string_list_eq( l1 = c4, l2 = d4 ) - then - "ok" - else - error "output_string_list" : Str - end; - - - - -def write_file( Inp : Str ) -> -in Erlang *{ - F = "out.txt", - ok = file:write_file( F, Inp ) -}* - -def read_file( F : File ) -> -in Erlang *{ - {ok, B} = file:read_file( F ), - Out = binary_to_list( B ) -}* - -let c5 : Str = "blub"; - -let = - read_file( F = ( write_file( Inp = c5 )|F ) ); - -let file_test : Str = - if( c5 == d5 ) - then - "ok" - else - error "file_test" : Str - end; - - - - -[output_bool_test, - input_bool_test, - output_string_test, - input_string_test, - output_boolean_list_test, - output_string_list_test, - file_test : Str]; - - diff --git a/samples/Cuneiform/fizzbuzz_matlab.cfl b/samples/Cuneiform/fizzbuzz_matlab.cfl deleted file mode 100644 index d4e4aafe43..0000000000 --- a/samples/Cuneiform/fizzbuzz_matlab.cfl +++ /dev/null @@ -1,78 +0,0 @@ -%%==================================================================== -%% Functions -%%==================================================================== - - -def range( first : Str, last : Str ) -> - - -in Matlab *{ - a = str2num( first ); - b = str2num( last ); - m = a:b; - c = num2cell( m ); - number_lst = cellfun( @num2str, c, 'UniformOutput', false ); -}* - - -def is_multiple( number : Str, divisor : Str ) -> - - -in Matlab *{ - a = str2num( number ); - b = str2num( divisor ); - is_multiple = mod( a, b ) == 0; -}* - - -%%==================================================================== -%% Constants -%%==================================================================== - - -let last : Str = 100; - - -%%==================================================================== -%% Workflow -%%==================================================================== - - -let = - range( first = 1, - last = last ); - - -let fizzbuzz_lst : [Str] = - for x <- number_lst do - - let = - is_multiple( number = x, - divisor = 3 ); - - let = - is_multiple( number = x, - divisor = 5 ); - - if ( f and b ) then "FizzBuzz" - else - if f then "Fizz" - else - if b then "Buzz" - else - x - end - end - end - - : Str - - end; - - -%%==================================================================== -%% Query -%%==================================================================== - -fizzbuzz_lst; - diff --git a/samples/Cuneiform/fizzbuzz_octave.cfl b/samples/Cuneiform/fizzbuzz_octave.cfl deleted file mode 100644 index 3a63ced372..0000000000 --- a/samples/Cuneiform/fizzbuzz_octave.cfl +++ /dev/null @@ -1,78 +0,0 @@ -%%==================================================================== -%% Functions -%%==================================================================== - - -def range( first : Str, last : Str ) -> - - -in Octave *{ - a = str2num( first ); - b = str2num( last ); - m = a:b; - c = num2cell( m ); - number_lst = cellfun( @num2str, c, 'UniformOutput', false ); -}* - - -def is_multiple( number : Str, divisor : Str ) -> - - -in Octave *{ - a = str2num( number ); - b = str2num( divisor ); - is_multiple = mod( a, b ) == 0; -}* - - -%%==================================================================== -%% Constants -%%==================================================================== - - -let last : Str = 100; - - -%%==================================================================== -%% Workflow -%%==================================================================== - - -let = - range( first = 1, - last = last ); - - -let fizzbuzz_lst : [Str] = - for x <- number_lst do - - let = - is_multiple( number = x, - divisor = 3 ); - - let = - is_multiple( number = x, - divisor = 5 ); - - if ( f and b ) then "FizzBuzz" - else - if f then "Fizz" - else - if b then "Buzz" - else - x - end - end - end - - : Str - - end; - - -%%==================================================================== -%% Query -%%==================================================================== - -fizzbuzz_lst; - diff --git a/samples/Cuneiform/java_test.cfl b/samples/Cuneiform/java_test.cfl deleted file mode 100644 index 040fe6f7b8..0000000000 --- a/samples/Cuneiform/java_test.cfl +++ /dev/null @@ -1,187 +0,0 @@ -def forall( l : [Bool] ) -> Bool { - fold acc = true, x <- l do - (acc and x) - end -} - -def boolean_list_eq( l1 : [Bool], l2 : [Bool] ) -> Bool { - - def boolean_list_compare( l1 : [Bool], l2 : [Bool] ) -> [Bool] { - for x1 <- l1, x2 <- l2 do - ( ( x1 and x2 ) or not( x1 or x2 ) ) : Bool - end - } - - let cmp : [Bool] = boolean_list_compare( l1 = l1, l2 = l2 ); - forall( l = cmp ) -} - - -def string_list_eq( l1 : [Str], l2 : [Str] ) -> Bool { - - def string_list_compare( l1 : [Str], l2 : [Str] ) -> [Bool] { - for x1 <- l1, x2 <- l2 do - ( x1 == x2 ) : Bool - end - } - - let cmp : [Bool] = string_list_compare( l1 = l1, l2 = l2 ); - forall( l = cmp ) -} - - - - - - - def output_bool() -> -in Java *{ - boolean out1 = true; - boolean out2 = false; -}* - -let = - output_bool(); - -let output_bool_test : Str = - if( not c1 or d1 ) - then - error "output_bool" : Str - else - "ok" - end; - - - - -def input_bool( a : Bool, b : Bool ) -> -in Java *{ - String out = "ok"; - if( !a || b ) - throw new RuntimeException( "bad input string" ); -}* - -let = - input_bool( a = true, b = false ); - - - - - -def output_string() -> -in Java *{ - String out = "blub"; -}* - -let = output_string(); - -let output_string_test : Str = - if( c2 == "blub" ) - then - "ok" - else - error "output_string" : Str - end; - - - - - - - -def input_string( a : Str ) -> -in Java *{ - String out = "ok"; - if( !( a.equals( "blub" ) ) ) - throw new RuntimeException( "bad input binding" ); -}* - -let = - input_string( a = "blub" ); - - - -def output_boolean_list() -> -in Java *{ - boolean[] out = {true, false, true }; -}* - -let = output_boolean_list(); - -let d3 : [Bool] = [true, false, true : Bool]; - -let output_boolean_list_test : Str = - if boolean_list_eq( l1 = c3, l2 = d3 ) - then - "ok" - else - error "output_boolean_list" : Str - end; - - - - - -def output_string_list() -> -in Java *{ - String[] out = { "a", "b", "c" }; -}* - -let = output_string_list(); - -let d4 : [Str] = ["a", "b", "c" : Str]; - -let output_string_list_test : Str = - if string_list_eq( l1 = c4, l2 = d4 ) - then - "ok" - else - error "output_string_list" : Str - end; - - - - -def write_file( inp : Str ) -> -in Java *{ - - String f = "out.txt"; - try( BufferedWriter w = new BufferedWriter( new FileWriter( new File( f ) ) ) ) { - w.write( inp ); - w.newLine(); - } -}* - -def read_file( f : File ) -> -in Java *{ - String out; - try( BufferedReader r = new BufferedReader( new FileReader( new File( f ) ) ) ) { - out = r.readLine(); - } -}* - -let c5 : Str = "blub"; - -let = - read_file( f = ( write_file( inp = c5 )|f ) ); - -let file_test : Str = - if( c5 == d5 ) - then - "ok" - else - error "file_test" : Str - end; - - - - -[output_bool_test, - input_bool_test, - output_string_test, - input_string_test, - output_boolean_list_test, - output_string_list_test, - file_test : Str]; - - diff --git a/samples/Cuneiform/perl_test.cfl b/samples/Cuneiform/perl_test.cfl deleted file mode 100644 index 844631838b..0000000000 --- a/samples/Cuneiform/perl_test.cfl +++ /dev/null @@ -1,194 +0,0 @@ -def forall( l : [Bool] ) -> Bool { - fold acc = true, x <- l do - (acc and x) - end -} - -def boolean_list_eq( l1 : [Bool], l2 : [Bool] ) -> Bool { - - def boolean_list_compare( l1 : [Bool], l2 : [Bool] ) -> [Bool] { - for x1 <- l1, x2 <- l2 do - ( ( x1 and x2 ) or not( x1 or x2 ) ) : Bool - end - } - - let cmp : [Bool] = boolean_list_compare( l1 = l1, l2 = l2 ); - forall( l = cmp ) -} - - -def string_list_eq( l1 : [Str], l2 : [Str] ) -> Bool { - - def string_list_compare( l1 : [Str], l2 : [Str] ) -> [Bool] { - for x1 <- l1, x2 <- l2 do - ( x1 == x2 ) : Bool - end - } - - let cmp : [Bool] = string_list_compare( l1 = l1, l2 = l2 ); - forall( l = cmp ) -} - - - - - - -def output_bool() -> -in Perl *{ - $out1 = 1; - $out2 = 0; -}* - -let = - output_bool(); - -let output_bool_test : Str = - if( not c1 or d1 ) - then - error "output_bool" : Str - else - "ok" - end; - - - - -def input_bool( a : Bool, b : Bool ) -> -in Perl *{ - if( $a ) { - if( ! $b ) { - $out = "ok"; - } else { - die "Error!"; - } - } else { - die "Error!"; - } -}* - -let = - input_bool( a = true, b = false ); - - - - - -def output_string() -> -in Perl *{ - $out = "blub"; -}* - -let = output_string(); - -let output_string_test : Str = - if( c2 == "blub" ) - then - "ok" - else - error "output_string" : Str - end; - - - - - - - -def input_string( a : Str ) -> -in Perl *{ - if( $a eq "blub" ) { - $out = "ok"; - } else { - die "Error!"; - } -}* - -let = - input_string( a = "blub" ); - - - -def output_boolean_list() -> -in Perl *{ - @out = (1, 0, 1); -}* - -let = output_boolean_list(); - -let d3 : [Bool] = [true, false, true : Bool]; - -let output_boolean_list_test : Str = - if boolean_list_eq( l1 = c3, l2 = d3 ) - then - "ok" - else - error "output_boolean_list" : Str - end; - - - - - -def output_string_list() -> -in Perl *{ - @out = ("a", "b", "c"); -}* - -let = output_string_list(); - -let d4 : [Str] = ["a", "b", "c" : Str]; - -let output_string_list_test : Str = - if string_list_eq( l1 = c4, l2 = d4 ) - then - "ok" - else - error "output_string_list" : Str - end; - - - - -def write_file( inp : Str ) -> -in Perl *{ - $f = "out.txt"; - open( $fh, '>', $f ) or die "Could not open file '$filename' $!"; - print $fh "$inp\n"; - close $fh; -}* - -def read_file( f : File ) -> -in Perl *{ - open( $fh, '<:encoding(UTF-8)', $f ) - or die "Could not open file '$filename $!"; - $out = <$fh>; - chomp $out; - close $fh; -}* - -let c5 : Str = "blub"; - -let = - read_file( f = ( write_file( inp = c5 )|f ) ); - -let file_test : Str = - if( c5 == d5 ) - then - "ok" - else - error "file_test" : Str - end; - - - - -[output_bool_test, - input_bool_test, - output_string_test, - input_string_test, - output_boolean_list_test, - output_string_list_test, - file_test : Str]; - - diff --git a/samples/Cuneiform/python_test.cfl b/samples/Cuneiform/python_test.cfl deleted file mode 100644 index d172b3305a..0000000000 --- a/samples/Cuneiform/python_test.cfl +++ /dev/null @@ -1,187 +0,0 @@ -def forall( l : [Bool] ) -> Bool { - fold acc = true, x <- l do - (acc and x) - end -} - -def boolean_list_eq( l1 : [Bool], l2 : [Bool] ) -> Bool { - - def boolean_list_compare( l1 : [Bool], l2 : [Bool] ) -> [Bool] { - for x1 <- l1, x2 <- l2 do - ( ( x1 and x2 ) or not( x1 or x2 ) ) : Bool - end - } - - let cmp : [Bool] = boolean_list_compare( l1 = l1, l2 = l2 ); - forall( l = cmp ) -} - - -def string_list_eq( l1 : [Str], l2 : [Str] ) -> Bool { - - def string_list_compare( l1 : [Str], l2 : [Str] ) -> [Bool] { - for x1 <- l1, x2 <- l2 do - ( x1 == x2 ) : Bool - end - } - - let cmp : [Bool] = string_list_compare( l1 = l1, l2 = l2 ); - forall( l = cmp ) -} - - - - - - -def output_bool() -> -in Python *{ - out1=True - out2=False -}* - -let = - output_bool(); - -let output_bool_test : Str = - if( not c1 or d1 ) - then - error "output_bool" : Str - else - "ok" - end; - - - - -def input_bool( a : Bool, b : Bool ) -> -in Python *{ - if a: - if not b: - out='ok' - else: - exit( -1 ) - else: - exit( -1 ) -}* - -let = - input_bool( a = true, b = false ); - - - - - -def output_string() -> -in Python *{ - out = 'blub' -}* - -let = output_string(); - -let output_string_test : Str = - if( c2 == "blub" ) - then - "ok" - else - error "output_string" : Str - end; - - - - - - - -def input_string( a : Str ) -> -in Python *{ - if a == 'blub': - out='ok' - else: - exit( -1 ) -}* - -let = - input_string( a = "blub" ); - - - -def output_boolean_list() -> -in Python *{ - out = [True, False, True] -}* - -let = output_boolean_list(); - -let d3 : [Bool] = [true, false, true : Bool]; - -let output_boolean_list_test : Str = - if boolean_list_eq( l1 = c3, l2 = d3 ) - then - "ok" - else - error "output_boolean_list" : Str - end; - - - - - -def output_string_list() -> -in Python *{ - out = ['a', 'b', 'c'] -}* - -let = output_string_list(); - -let d4 : [Str] = ["a", "b", "c" : Str]; - -let output_string_list_test : Str = - if string_list_eq( l1 = c4, l2 = d4 ) - then - "ok" - else - error "output_string_list" : Str - end; - - - - -def write_file( inp : Str ) -> -in Python *{ - f = 'out.txt' - with open( f, 'w') as the_file: - the_file.write( inp ) -}* - -def read_file( f : File ) -> -in Python *{ - with open( f, 'r' ) as the_file: - out = the_file.readline() -}* - -let c5 : Str = "blub"; - -let = - read_file( f = ( write_file( inp = c5 )|f ) ); - -let file_test : Str = - if( c5 == d5 ) - then - "ok" - else - error "file_test" : Str - end; - - - - -[output_bool_test, - input_bool_test, - output_string_test, - input_string_test, - output_boolean_list_test, - output_string_list_test, - file_test : Str]; - - diff --git a/samples/Cuneiform/racket_test.cfl b/samples/Cuneiform/racket_test.cfl deleted file mode 100644 index 4a6de94c8b..0000000000 --- a/samples/Cuneiform/racket_test.cfl +++ /dev/null @@ -1,182 +0,0 @@ -def forall( l : [Bool] ) -> Bool { - fold acc = true, x <- l do - (acc and x) - end -} - -def boolean_list_eq( l1 : [Bool], l2 : [Bool] ) -> Bool { - - def boolean_list_compare( l1 : [Bool], l2 : [Bool] ) -> [Bool] { - for x1 <- l1, x2 <- l2 do - ( ( x1 and x2 ) or not( x1 or x2 ) ) : Bool - end - } - - let cmp : [Bool] = boolean_list_compare( l1 = l1, l2 = l2 ); - forall( l = cmp ) -} - - -def string_list_eq( l1 : [Str], l2 : [Str] ) -> Bool { - - def string_list_compare( l1 : [Str], l2 : [Str] ) -> [Bool] { - for x1 <- l1, x2 <- l2 do - ( x1 == x2 ) : Bool - end - } - - let cmp : [Bool] = string_list_compare( l1 = l1, l2 = l2 ); - forall( l = cmp ) -} - - - - - - - def output_bool() -> -in Racket *{ - (define out1 #t) - (define out2 #f) -}* - -let = - output_bool(); - -let output_bool_test : Str = - if( not c1 or d1 ) - then - error "output_bool" : Str - else - "ok" - end; - - - - -def input_bool( a : Bool, b : Bool ) -> -in Racket *{ - (define out - (if (and a (not b)) "ok" (error "bad input binding"))) -}* - -let = - input_bool( a = true, b = false ); - - - - - -def output_string() -> -in Racket *{ - (define out "blub") -}* - -let = output_string(); - -let output_string_test : Str = - if( c2 == "blub" ) - then - "ok" - else - error "output_string" : Str - end; - - - - - - - -def input_string( a : Str ) -> -in Racket *{ - (define out (if (equal? a "blub") "ok" (error "bad input binding"))) -}* - -let = - input_string( a = "blub" ); - - - -def output_boolean_list() -> -in Racket *{ - (define out '(#t #f #t)) -}* - -let = output_boolean_list(); - -let d3 : [Bool] = [true, false, true : Bool]; - -let output_boolean_list_test : Str = - if boolean_list_eq( l1 = c3, l2 = d3 ) - then - "ok" - else - error "output_boolean_list" : Str - end; - - - - - -def output_string_list() -> -in Racket *{ - (define out '("a" "b" "c")) -}* - -let = output_string_list(); - -let d4 : [Str] = ["a", "b", "c" : Str]; - -let output_string_list_test : Str = - if string_list_eq( l1 = c4, l2 = d4 ) - then - "ok" - else - error "output_string_list" : Str - end; - - - - -def write_file( inp : Str ) -> -in Racket *{ - (define f "out.txt") - (call-with-output-file - f - (lambda (output-port) (writeln inp output-port))) -}* - -def read_file( f : File ) -> -in Racket *{ - (define out - (call-with-input-file - f - (lambda (input-port) (read-line input-port)))) -}* - -let c5 : Str = "blub"; - -let = - read_file( f = ( write_file( inp = c5 )|f ) ); - -let file_test : Str = - if( c5 == d5 ) - then - "ok" - else - error "file_test" : Str - end; - - - - -[output_bool_test, - input_bool_test, - output_string_test, - input_string_test, - output_boolean_list_test, - output_string_list_test, - file_test : Str]; - - From 9536af3c8bc39d76fcb449e8b6761529236f84bb Mon Sep 17 00:00:00 2001 From: Jorgen Brandt Date: Mon, 4 Jun 2018 22:56:03 +0200 Subject: [PATCH 4/5] Improve on tests --- lib/linguist/languages.yml | 21 ++++++++++--------- ...{variant-call.cfl.erb => variant-call.cfl} | 0 2 files changed, 11 insertions(+), 10 deletions(-) rename samples/Cuneiform/{variant-call.cfl.erb => variant-call.cfl} (100%) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index f29ff2b3bd..636e61399f 100755 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -615,16 +615,6 @@ CSV: extensions: - ".csv" language_id: 51 -Cuneiform: - type: programming - extensions: - - ".cfl" - interpreters: - - "cuneiform" - - "cf_client" - color: "#2772b0" - tm_scope: none - language_id: 2699 CWeb: type: programming extensions: @@ -946,6 +936,17 @@ Cuda: codemirror_mime_type: text/x-c++src color: "#3A4E3A" language_id: 77 +Cuneiform: + type: programming + ace_mode: text + extensions: + - ".cfl" + interpreters: + - "cuneiform" + - "cf_client" + color: "#501616" + tm_scope: none + language_id: 2699 Cycript: type: programming extensions: diff --git a/samples/Cuneiform/variant-call.cfl.erb b/samples/Cuneiform/variant-call.cfl similarity index 100% rename from samples/Cuneiform/variant-call.cfl.erb rename to samples/Cuneiform/variant-call.cfl From 7271975a789b08774f2d72003b0223e0881d6424 Mon Sep 17 00:00:00 2001 From: Jorgen Brandt Date: Mon, 4 Jun 2018 23:30:57 +0200 Subject: [PATCH 5/5] Automatically assign lang id, all tests but two pass --- lib/linguist/languages.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 636e61399f..85821387d5 100755 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -942,11 +942,11 @@ Cuneiform: extensions: - ".cfl" interpreters: - - "cuneiform" - - "cf_client" + - cuneiform + - cf_client color: "#501616" tm_scope: none - language_id: 2699 + language_id: 159983766 Cycript: type: programming extensions: