1: doctype public "-//IDN etl.sf.net//ETL//Grammar 0.2.1";
     2: /// The statement below is a special blank statement to ensure that it is ignored.
     3: ;
     4: /// This is almost minimal grammar that supports HelloWorld.ej.etl
     5: /// But there are still some features to remove.
     6: grammar net.sf.etl.tests.data.MinimalEJ {
     7: 	namespace default ej = "http://etl.sf.net/2006/samples/ej/0.1";
     8: 	
     9: 	/// A common context that defines documentation and attributes
    10: 	context Common {
    11: 		/// Simple documentation 
    12: 		documentation Documentation {
    13: 			@ documentation += doclines wrapper ej:DocumentationLine.text;
    14: 		};
    15: 
    16: 		/// Simple attributes definition
    17: 		attributes Attributes {
    18: 			@ attributeSets += {
    19: 				^ ej:AttributeSet {
    20: 					% @ % [ {
    21: 						@ attributes += list , {
    22: 							expression(Expression,precedence=100);
    23: 						};
    24: 					} % ];
    25: 				};
    26: 			}+;
    27: 		};
    28: 
    29: 		def IdentifierDef {
    30: 			^ ej:Identifier {
    31: 				@ value = identifier;
    32: 			};
    33: 		};
    34: 	};
    35: 	
    36: 	context abstract Classifiers {
    37: 		include Common;
    38: 
    39: 		statement ClassStatement {
    40: 			% class;
    41: 			modifiers wrapper ej:Modifier.value {
    42: 				@ visibilityModifier = modifier public;
    43: 			};
    44: 			@ name = ref(IdentifierDef);
    45: 			@ contents += block(ClassContents);
    46: 		};
    47: 	};
    48: 	
    49: 	/// Top level context that contains package and class definitions
    50: 	context default TopLevel {
    51: 		include Classifiers wrapper ej:TopLevelClassifier.classifier;
    52: 		
    53: 		statement PackageStatement {
    54: 			% package;
    55: 			@ name = expression(PackageNameExpression);
    56: 		};
    57: 		
    58: 		
    59: 		statement BlankTopLevel {
    60: 		};
    61: 	};
    62: 
    63: 	
    64: 	context PackageNameExpression {
    65: 		include Common;
    66: 				
    67: 		op composite Identifier(f) {
    68: 			ref(IdentifierDef);
    69: 		};
    70: 		
    71: 		op AccessOp(yfx, 100, . ) {
    72: 			@ accessed = left;
    73: 			@ feature = right;
    74: 		};
    75: 	};
    76: 
    77: 	
    78: 	context TypeExpression {
    79: 		include PackageNameExpression;
    80: 		
    81: 		op composite VoidType(f) {
    82: 			^ ej:PrimitiveType {
    83: 				@ name = token(void);
    84: 			};
    85: 		};
    86: 		
    87: 		op composite ArrayType(f) {
    88: 			^ ej:PrimitiveType {
    89: 				@ name = token(array);
    90: 			};
    91: 		};
    92: 		
    93: 		op composite ApplySquareOp(yf, 100) {
    94: 			@ functor = left;
    95: 			@ args += % [ {
    96: 				list , {
    97: 					expression;
    98: 				};
    99: 			} % ];
   100: 		};
   101: 		
   102: 	};
   103: 	
   104: 	context Expression {
   105: 		include TypeExpression;
   106: 
   107: 		op composite StringLiteral(f) {
   108: 			@ value = string(quote='\"');
   109: 		};
   110: 
   111: 		op composite ApplyRoundOp(yf, 100) {
   112: 			@ functor = left;
   113: 			@ args += % ( {
   114: 				list , {
   115: 					expression;
   116: 				};
   117: 			} %);
   118: 		};
   119: 	};
   120: 	
   121: 	context Code {
   122: 		statement ExpressionStatement {
   123: 			@ expression = expression(Expression);
   124: 		};
   125: 		statement BlankCode {
   126: 		};
   127: 	};
   128: 	
   129: 	context ClassContents {
   130: 		include Common;
   131: 		
   132: 		statement MethodStatement {
   133: 			% to;
   134: 			modifiers wrapper ej:Modifier.value {
   135: 				@ visibilityModifier = modifier public;
   136: 				@ staticModifier = modifier static;
   137: 			};
   138: 			@ returnType = expression(TypeExpression);
   139: 			@ name = ref(IdentifierDef);
   140: 			@ parameters += % ( {
   141: 				list , {
   142: 					^ ej:Parameter {
   143: 						@ classifier = expression(TypeExpression);
   144: 						@ name = ref(IdentifierDef);
   145: 					};
   146: 				}?;
   147: 			} % );
   148: 			@ body = ref(MethodBlock);
   149: 		};
   150: 		
   151: 		def MethodBlock {
   152: 			^ ej:MethodBlock {
   153: 				@ content += block(Code);
   154: 			};
   155: 		};
   156: 		
   157: 		statement BlankClassContent {
   158: 		};
   159: 	};
   160: };