1: doctype public "-//IDN etl.sf.net//ETL//Grammar 0.2.1";
     2: grammar calculator.CalculatorLambda {
     3:     include "calculator-lambda-basic-0_2_1.g.etl";
     4:     namespace t = "http://etl.sf.net/samples/calculator/vars";
     5:     namespace v = "http://etl.sf.net/samples/calculator/vars";
     6:     namespace default l = "http://etl.sf.net/samples/calculator/lambda";
     7:     context abstract LetRecDefs {
     8:         def LetRecFunctionDef {
     9:             ^ v:LetRecPart {
    10:                 % to;
    11:                 @ name = ref(NameDef);
    12:                 @ value = ^l:Lambda {
    13:                     % (;
    14:                     ref(ParameterList);
    15:                     % ) % =>;
    16:                     @ value = ref(ExpressionDef);
    17:                 };
    18:             };
    19:         };        
    20:     };
    21:     context default Expressions {
    22:         include LetRecDefs;
    23:         import letRecContent = LetRecContent;
    24:         
    25:         op composite LambdaNoArgs(fy, 1950) {
    26:             ^ l:Lambda {
    27:                 % \>;
    28:                 @ value = right;
    29:             };
    30:         };        
    31:         def SequenceDef {
    32:             ^ l:LambdaSequence {
    33:                 @statements += block;
    34:             };
    35:         };
    36:         statement BlockParameters {
    37:             % ?;
    38:             ref(ParameterList);
    39:         };
    40:         statement Function {
    41:             ^v:LetRec {
    42:                 @ definitions += ref(LetRecFunctionDef);
    43:             };
    44:         };
    45:         op composite InfixOperatorAppy(yfx, 1150) {
    46:             ^ l:Apply {
    47:                 @ arguments += left;
    48:                 % #;
    49:                 @ function = expression(precedence = 99);
    50:                 @ arguments += right;
    51:             };
    52:         };        
    53:         op composite PrefixOperatorAppy(fy, 1150) {
    54:             ^ l:Apply {
    55:                 % #;
    56:                 @ function = expression(precedence = 99);
    57:                 @ arguments += right;
    58:             };
    59:         };
    60:         op composite ApplyBlock(xf, 1175) {
    61:             ^ l:Apply {
    62:                 @ function = left;
    63:                 @ arguments += ref(SequenceDef);
    64:             };
    65:         };
    66:         op composite Lazy(f, 1950) {
    67:             ^ l:Apply {
    68:                 @ function = token(&) wrapper t:Name.literal;
    69:                 @ arguments += ^ l:Lambda { 
    70:                     @value = expression(precedence=1949); 
    71:                 };
    72:             };
    73:         };
    74:         op Dereference(fy, 100, *) {
    75:             @ value = right;
    76:         };
    77:         op composite NotEqualDeref(xfx, 1300) {
    78:             ^ l:Apply {
    79:                 @ arguments += left;
    80:                 @ function = token(!*=) wrapper t:Name.literal;
    81:                 @ arguments += right;
    82:             };
    83:         };
    84:         op composite EqualDeref(xfx, 1300) {
    85:             ^ l:Apply {
    86:                 @ arguments += left;
    87:                 @ function = token(=*=) wrapper t:Name.literal;
    88:                 @ arguments += right;
    89:             };
    90:         };
    91:     };
    92:     context LetRecContent {
    93:         statement FunctionPart {
    94:             ref(LetRecFunctionDef);
    95:         };
    96:     };
    97: };