1: doctype public "-//IDN etl.sf.net//ETL//Grammar 0.2.1";
2: /// This grammar defines asynchronous extensions for EJ language.
3: /// These extensions are inspired by E programming language
4: /// (see http://www.erights.org for more details).
5: ///
6: /// This grammar demonstrate how to plug into existing grammar.
7: /// This situation is different from reuse of existing modules.
8: grammar net.sf.etl.samples.ej.AsyncEJ {
9: include "EJ.g.etl";
10: namespace ej = "http://etl.sf.net/2006/samples/ej/0.1";
11: namespace aej = "http://etl.sf.net/2006/samples/ej/AsyncEJ/0.1";
12: context abstract ClassifierContent {
13: };
14: context InterfaceContents {
15: /// on statement. It expands to for oneway messages
16: /// send$name(<parameters>). For other messages it expands
17: /// to send$name(Resolver<RT> r, <parameters>)
18: statement EventualMethodStatement {
19: ^ aej:EventualMethodStatement {
20: % on {
21: ref(TemplateParameters) ?;
22: modifiers wrapper ej:Modifier.value {
23: @ publicModifier = modifier public;
24: @ abstractModifier = modifier abstract;
25: @ onewayModifier = modifier oneway;
26: };
27: ref(MethodSignatureFragment);
28: };
29: };
30: };
31: };
32: context ClassContents {
33: /// This statement declares that class supports specific
34: /// asynchronous interface.
35: statement SupportsStatement {
36: ^ ej:SupportsStatement {
37: % supports {
38: @ supportedInterfaces += list, {
39: expression(TypeExpressions);
40: };
41: };
42: };
43: };
44: /// on statement. It expands to for oneway messages
45: /// send$name(<parameters>). For other messages it expands
46: /// to send$name(Resolver<RT> r, <parameters>). The statement
47: /// also causes appearance of inner message class that is used
48: /// to dispatch values.
49: statement EventualMethodStatement {
50: ^ aej:EventualMethodStatement {
51: % on {
52: ref(TemplateParameters) ?;
53: modifiers wrapper ej:Modifier.value {
54: @ visibilityModifier = modifier public;
55: @ visibilityModifier = modifier protected;
56: @ visibilityModifier = modifier private;
57: @ staticModifier = modifier static;
58: @ strictfpModifier = modifier strictfp;
59: @ abstractModifier = modifier abstract;
60: @ finalModifier = modifier final;
61: @ synchronizedModifier = modifier synchronized;
62: @ onewayModifier = modifier oneway;
63: };
64: ref(MethodSignatureFragment);
65: };
66: @ body = ref(MethodBlockFragment) ?;
67: };
68: };
69: };
70: context Expressions {
71: /// E-like eventual send
72: op EventualSendOp(yfx, 100, <-) {
73: ^ aej:EventualSendOp {
74: @ target = left;
75: @ message = right;
76: };
77: };
78: /// E-like when/catch/finally operator
79: op composite WhenOp(f) {
80: ^ aej:WhenOp {
81: % when {
82: %({
83: % var {
84: @ parameter = ref(ParameterFragment);
85: % = {
86: @ value = expression;
87: };
88: } | {
89: @ value = expression;
90: };
91: } %);
92: @ body = ref(MethodBlockFragment);
93: };
94: {
95: % catch {
96: @ catchPart += ^ ej:CatchPart {
97: @ specification = %({
98: ref(ParameterFragment);
99: } %);
100: @ body = ref(MethodBlockFragment);
101: };
102: } *;
103: % finally {
104: @ finallyPart = ref(MethodBlockFragment);
105: } ?;
106: };
107: };
108: };
109: };
110: context TypeExpressions {
111: /// vow type
112: op composite VowType(f) {
113: ^ aej:PrimitiveType {
114: @ name = token(vow);
115: };
116: };
117: };
118: /// Redeclare context as default
119: context default TopLevel {
120: };
121: };