Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cuneiform programming language #4157

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though it's a different language, you can use Ruby's grammar for Cuneiform highlighting. The results look decent enough.

If that isn't good enough, just give me the formal language specification, and I'll write a grammar for you. 😉

language_id: 2699
CWeb:
type: programming
extensions:
Expand Down
39 changes: 39 additions & 0 deletions samples/Cuneiform/ackermann.cfl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@


def inc( x : Str ) -> Str {

def inc( x : Str ) -> <y : Str> in Python *{
y = int( x )+1
}*

( inc( x = x )|y )
}

def dec( x : Str ) -> Str {

def dec( x : Str ) -> <y : 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 );
191 changes: 191 additions & 0 deletions samples/Cuneiform/bash_test.cfl
Original file line number Diff line number Diff line change
@@ -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() -> <out1 : Bool, out2 : Bool>
in Bash *{
out1=true
out2=false
}*

let <out1 = c1 : Bool, out2 = d1 : Bool> =
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 ) -> <out : Str>
in Bash *{
if [ $a == 'true' ]
then
if [ $b == 'false' ]
then
out='ok'
else
exit -1
fi
else
exit -1
fi
}*

let <out = input_bool_test : Str> =
input_bool( a = true, b = false );





def output_string() -> <out : Str>
in Bash *{
out='blub'
}*

let <out = c2 : Str> = output_string();

let output_string_test : Str =
if( c2 == "blub" )
then
"ok"
else
error "output_string" : Str
end;







def input_string( a : Str ) -> <out : Str>
in Bash *{
if [ $a == 'blub' ]
then
out='ok'
else
exit -1
fi
}*

let <out = input_string_test : Str> =
input_string( a = "blub" );



def output_boolean_list() -> <out : [Bool]>
in Bash *{
out=('true' 'false' 'true')
}*

let <out = c3 : [Bool]> = 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() -> <out : [Str]>
in Bash *{
out=('a' 'b' 'c')
}*

let <out = c4 : [Str]> = 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 ) -> <file : File>
in Bash *{
file='out.txt'
echo $inp >> $file
}*

def read_file( file : File ) -> <out : Str>
in Bash *{
out=`cat $file`
}*

let c5 : Str = "blub";

let <out = d5 : Str> =
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];


Loading