Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

/prog/BOL 2012

Name: Anonymous 2012-01-22 12:03

identity is of type for all types A, A to A.
define function identity of x:
   return x.
end.

constant is of type for all types A and B, A to B to A.
define function constant of x of y:
   return x.
end.

define factorial of type int to int of n:
   if n equals 0, then: return 1.
   else: return n times factorial of (n minus 1).
end.

Name: Anonymous 2012-01-26 23:23


function_body : statement_list
              ;

statement_list : statement.
               | statement_list statement.
               ;

statement : expression
          | return expression
          | 'if' expression ',' 'then' ':' statement_list 'else:' statement_list 'endif'
          ;

----------
FOIC can be used to avoid the endif above, but I don't know how to express FOIC in gramas.
---------


expression_list_ : expression
                 | expression_ ',' expression
                 ;

expression_list : expression
                | expression_list_ 'and' expression

function_call : identifier 'of' expression_list

term : identifier
     | constant
     | function_call
     ;

expression : term
           | term binary_operation term
           | expression binary_operation term
           ;

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List