fail-access-prove-statictype1.crd

b=45
a="test case"
b=a

------------

fail-access-prove-statictype2.crd

a=2
a="2"

------------

fail-assign.crd

x=
------------

fail-empty-call.crd

PLAY()
------------

fail-function-assign-play.crd

PLAY(b)={
b=4
return b
}

d=3
PLAY(d)
------------

fail-nested-scope.crd

PLAY()={
	x=false
	if x {
		b = 1
	}

	c = b
}

------------

fail-outofbounds-collection.crd

a = [3,4]
b = a[2]

------------

goFish.crd

PLAY()={
	deck = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "J", "Q", "K"]
	
	hand = []
	loop=[1:7]
	for j:loop{
		card = deck.pop()
		hand.append(card)
	}
	
	guessed = false
	while not guessed{
		guess = INPUT(string)
		idx = 0

		while (not guessed and (idx < 7)){
			if hand[idx] == guess{
				guessed = true
			}
			idx++
		}
			
		if not guessed{
			OUTPUT("Go Fish!")
		}
	}
	
	OUTPUT("You win!")
}		

------------

goldfish.crd

x()={
a = [3,"hello"]
b = a[0]
c = a[1]
}

------------

guppie.crd

PLAY()={
    deck = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "J", "Q", "K"]
    a=1
    deck[a]
}

------------

test-access-collection-function.crd

PLAY()={
	b=[1,2,3,4]
	b.shuffle()
	b.popLast()
}

------------

test-access-collection.crd

x()={
a = [3,"hello"]
b = a[0]
c = a[1]
}

------------

test-access-enum.crd

x=|a,b,c|
y=|d,e|
m=x.a
n=y.d

------------

test-assign-boolean.crd

a=true
b=false
------------

test-assign-collection.crd

a = [2, false, 2.3, "hello world"]

------------

test-assign-collectionbounds.crd

a=[1:10]

------------

test-assign-enum.crd

x=|a,b|
y=|a,c,e|

------------

test-assign-float.crd

a = 2.2
b = a

------------

test-assign-identifier.crd

b=2
a=b
------------

test-assign-int.crd

a=3

------------

test-assign-string.crd

a="testing 123"
b="escape\""
c="new line\n"
d="tab\t"
e="backslash\\"
f="all\\\n\t\""

------------

test-binop-and.crd

PLAY()={x=true and false}
------------

test-binop-divide-float-float.crd

PLAY() = {x=35.1/6.2}
------------

test-binop-divide-float-int.crd

PLAY() = {x=35.1/6}
------------

test-binop-divide-int-float.crd

PLAY() = {x=35/6.2}
------------

test-binop-divide-int-int.crd

PLAY() = {x=35/6}
------------

test-binop-geq-float-float.crd

PLAY()={b=3.0 >= 3.0}
------------

test-binop-geq-float-int.crd

PLAY()={b=3.0 >= 3}
------------

test-binop-geq-int-float.crd

PLAY()={b=3 >= 3.0}
------------

test-binop-geq-int-int.crd

PLAY()={b=3 >= 4}
------------

test-binop-gt-float-float.crd

PLAY()={b=43.2>31.3}
------------

test-binop-gt-float-int.crd

PLAY()={b=43.2>31}
------------

test-binop-gt-int-float.crd

PLAY()={b=40>321.3}
------------

test-binop-gt-int-int.crd

PLAY()={b=40>3}
------------

test-binop-leq-float-float.crd

PLAY()={b=4.4<=3.2}
------------

test-binop-leq-float-int.crd

PLAY()={b=4.1<=3}
------------

test-binop-leq-int-float.crd

PLAY()={b=4<=3.2}
------------

test-binop-leq-int-int.crd

PLAY()={b=4<=3}
------------

test-binop-lt-float-float.crd

PLAY()={b=5.4<12.1}
------------

test-binop-lt-float-int.crd

PLAY()={b=5.4<12}
------------

test-binop-lt-int-float.crd

PLAY()={b=5<12.2}
------------

test-binop-lt-int-int.crd

PLAY()={b=5<12}
------------

test-binop-minus-float-float.crd

PLAY() = {x=35.1-6.2}
------------

test-binop-minus-float-int.crd

PLAY() = {x=5.2-6}
------------

test-binop-minus-int-float.crd

PLAY() = {x=14-5.2}
------------

test-binop-minus-int-int.crd

PLAY() = {x=14-5}
------------

test-binop-mod-int-int.crd

PLAY()={x=50%4}
------------

test-binop-neq-collections.crd

a=[5,4]
b=[5,4]
c=[4,5]
d=	a!=b
e= 	b!=c
f=	a!=a
------------

test-binop-neq-false.crd

PLAY()={b= true != true}
------------

test-binop-neq-true.crd

PLAY()={b= true != false}
------------

test-binop-or.crd

PLAY()={x=true or false}
------------

test-binop-plus-float-float.crd

PLAY() = {x=35.1+6.2}
------------

test-binop-plus-float-int.crd

PLAY() = {x=5.2+6}
------------

test-binop-plus-int-float.crd

PLAY() = {x=4+5.2}
------------

test-binop-plus-int-int.crd

PLAY() = {x=4+5}
------------

test-binop-plus-string-string.crd

PLAY() = {z="hello " + "world"}
------------

test-binop-times-float-float.crd

PLAY() = {x=3.1*6.2}
------------

test-binop-times-float-int.crd

PLAY() = {x=5.2*6}
------------

test-binop-times-int-float.crd

PLAY() = {x=3*5.2}
------------

test-binop-times-int-int.crd

PLAY() = {x=3*5}
------------

test-cast-bool-bool.crd

PLAY()={b=CAST(true,bool)}

------------

test-cast-bool-float-valid.crd

PLAY()={b=CAST(true,float)}

------------

test-cast-bool-int-valid.crd

PLAY()={b=CAST(true,int)}
------------

test-cast-bool-string-valid.crd

PLAY()={
	b=CAST(true,string)
	c=CAST(false,string)
}

------------

test-cast-float-bool-valid.crd

PLAY()={b=CAST(5.4,bool)}
------------

test-cast-float-float.crd

PLAY()={b=CAST(5.4,float)}
------------

test-cast-float-int-valid.crd

PLAY()={b=CAST(5.4,int)}
------------

test-cast-int-bool-valid.crd

PLAY()={
	b=CAST(5,bool)
	c=CAST(0,bool)
}

------------

test-cast-int-float-valid.crd

PLAY()={b=CAST(5,float)}
------------

test-cast-int-int.crd

PLAY()={b=CAST(5,int)}
------------

test-cast-int-string-valid.crd

PLAY()={b=CAST(5,string)}
------------

test-cast-string-bool-valid.crd

PLAY()={b=CAST("true",bool)}
------------

test-cast-string-float-valid.crd

PLAY()={b=CAST("5.4",float)}
------------

test-cast-string-int-valid.crd

PLAY()={b=CAST("10",int)}
------------

test-cast-string-string.crd

PLAY()={b=CAST("rainbow",string)}
------------

test-collection-nest.crd

PLAY()={
b=[1,"a",["hello",2],4.3]
c=4
d=[]}

------------

test-comment-backslash.crd

a=\
// fooble
4
b=3
------------

test-comment-backslashes.crd

a=\
// fooble
4
//funsies
b=3
------------

test-comment.crd

a=4
// fooble
b=3
------------

test-decrement.crd

PLAY()={
	b=5
	c=5--
	d=b--
	e=5.3
	f=5.3--
	g=e--
}

------------

test-empty-function.crd

PLAY()={}
------------

test-function-body-several-stmts.crd

PLAY() = {
	b=5
	c=6
	d=7
}
------------

test-function-call-arg-constant.crd

PLAY(b)={
    b=4
    return b
}

c=PLAY(3)

------------

test-function-call-global.crd

PLAY()={}
a()={return 5}
c=a()
------------

test-function-call-play.crd

PLAY(b)={
b=4
return b
}

d=3
c=PLAY(d)

------------

test-function-call.crd

PLAY()={OUTPUT(5)}

a()={return 5}

b()={c=a()}
------------

test-function-empty-body.crd

PLAY()={a=5}

b()={}
------------

test-function-if.crd

PLAY(b)={
    if b>4 {
        c=4
    }
    else {
        c=6
    }
    
    return c
}

------------

test-function-local-body.crd

PLAY() ={
	d="testing 123 \n"
	e=true
	f=	7
}

------------

test-function-localvar.crd

PLAY()={b=3}
------------

test-function-multiple-args.crd

PLAY()={}

a(b, c)={
	b=5
    c=3
}

------------

test-function-one-arg.crd

PLAY(b) = {}

------------

test-function-reassign-arg.crd

a(b, c) ={
	b=5					
	c=5.6
}

------------

test-function-return-arg.crd

PLAY()={}

a(b, c) ={
	b=5					
	c=5.6
	return b
}

------------

test-function-return-float.crd

PLAY()={
	return 4.3
}
------------

test-function-return-id-int.crd

PLAY() = {
	d=7
	return d
}

------------

test-function-return-id-string.crd

PLAY()={
	d="foo"
	return d
}
------------

test-function-return-int.crd

PLAY() = {
	d=7
	return 7
}

------------

test-function-return-string.crd

PLAY()={
	return "foo"
}
------------

test-function-stmt-eval-order.crd

PLAY(b, c) ={
	b=5					
	c=b + 0.6
	return c
}

------------

test-functions-type-unclear.crd

PLAY(b) = {
	f = b+1
}

------------

test-increment-float.crd

PLAY()={
	b=5.7
	c=5.7++
  d=b++
}

------------

test-increment-int.crd

PLAY()={
	b=5
	c=5++
  d=b++
}

------------

test-increment2.crd

PLAY()={}

a(b, c)={
    b=5
    b++
    c=3
}

d=7
------------

test-input.crd

PLAY()={
	x = INPUT(int)
	y = INPUT(float)
	z = INPUT(string)
	w = INPUT(bool)
}

------------

test-invert-bool.crd

PLAY()={b=not true}
------------

test-invert-id.crd

PLAY()={
    d=true
    b= not d
    return b
}
------------

test-linebreak-several.crd

a=\
\
\
\
\
3
b\
=4
------------

test-linebreak.crd

a=\
3
b=4
------------

test-local-global-scope.crd

d="1234"
PLAY() = {
	e=d
	d="new 123 \n"
	e=d
}

f=d
------------

test-multiple-assignments.crd

PLAY()={
a=3
b=5
c=7
d=9
e=11
}

f=6
------------

test-multiple-functions.crd

PLAY()={b=6}

c()={d=12}

e()={f=18}
------------

test-multiple-separators.crd

a   =       3
b = 4
c	=			"testing 123 \n"
d	=true
e=     		5.6
f=7

------------

test-negate-id.crd

PLAY()={}

a(b)={
d= -3.3
b= -d
return b
}
------------

test-negation-minus.crd

PLAY()={x=5 - - 2}
------------

test-negation.crd

PLAY()={x=not true}
------------

test-output.crd

PLAY()={
	x=1
	y="hello world"
	OUTPUT(x)
	OUTPUT(y)
}

------------

test-spaces.crd

a   =       3
b = 4

------------

test-stmt-for.crd

PLAY()={
  y=[1:10]
	for x:y{
		sum = 1
	}
	
	for player:players{
	  OUTPUT("test")
	}

} 

------------

test-stmt-if-else-if.crd

PLAY()={
	if x {
		b = 1
	}
	elseif y{
		b=2
	}
	else {
		b=3
	}
}

------------

test-stmt-if-else-nested.crd

PLAY()={
	x=1
	y=1
	if x {
		b = 1
	}
	elseif y{
		if z{
			b=2
		}
		else{
			b=3
		}
	}
	else {
		b=4
	}
}

------------

test-stmt-if-else.crd

PLAY()={
	x=true
	if x {
		b = 1
	}
	else{
		b=2
	}
}

------------

test-stmt-if.crd

PLAY()={
	x=false
	if x {
		b = 1
	}
}

------------

test-stmt-rule.crd

PLAY()={
    rules (flag1=1, flag2=false) {true {x=4} false {y=5}}
}

------------

test-stmt-while.crd

PLAY()={
	valid = true
	while not valid {
		OUTPUT("hello")
		valid=false
	}
}

------------

test-struct.crd

PLAY()={
  num=20
  b={name:"namestring",age:20,number:num}
}

------------

test-struct2.crd

PLAY()={
  num=20
  b={name:"namestring",age:20,number:num}
  c=b.name
}

------------

test-tabs.crd

a	=			3
b	=4

------------

war.crd

rank=|two, three, four, five, six, seven, eight, nine, ten, jack, queen, king, ace|
suit=|hearts, clubs, diamonds, spades|

HIGHEST = 0
NEXT = 1
WAR_CARDS = 3

PLAY()={
    deck = cartesian(rank, suit)	//Standard library func
    players = []                    //Empty collection
    OUTPUT("How many players?")     //Cardigan's print stmt
    numPlayers = INPUT(int)         //Specify input type   
    for id:[1:numPlayers]{
		players.append({playerNumber:id, hand:[]})
	}    // Add players   
	deck.shuffle()            		// built in function
	deck.deal(players)    			// standard library
	winner = {}                		// define winning conditions
	while !winner {           	 	// while conditions have not been met
    	result = round(players)
    	players[result.winner].hand.append(result.cards)
    	if players[result.winner].hand.length == deck.length {
        	winner = players[result.winner]
    	}
    }
    OUPUT(CAST(winner.id, string) + " is the winner!")
}

round(players)={
    roundCards = [ ]
    for player:players {
        roundCards.append(player.hand.pop())
    }
    roundCards.sort(value)
	result = {}
    rules (highCard=roundCards[HIGHEST].value, next=NEXT){
        highCard.value > roundCards[next].value {
        	result.winner = highCard.id
        }
        highCard.value == roundCards[next].value {
        	participants = []
        	participants.push(players[highCard.id])
        	while roundCards[next].value == highCard {
        		participants.push(players[roundCards[next].id])
        	}
        	warResults = war(participants)
        	roundCards.append(warResults.cards)
        	result.winner = warResults.winner	
        }
    }
    result.cards = roundCards
    return result
}
 
war(participants) = {
	OUTPUT("War!")
	spoils = []
	for participant:participants{
		spoils.append(participant.hand.pop(WAR_CARDS))
	}
	result = round(participants)
    spoils.append(result.cards)
    return {winner: result.winner, cards: spoils}
}        
        
------------
