-/* This file is part of NIT ( http://www.nitlanguage.org ).
- *
- * Copyright 2008 Jean Privat <jean@pryen.org>
- * Based on algorithms developped for ( http://www.sablecc.org/ ).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+$ // This file is part of NIT ( http://www.nitlanguage.org ).
+$ //
+$ // Copyright 2008 Jean Privat <jean@pryen.org>
+$ // Based on algorithms developped for ( http://www.sablecc.org/ ).
+$ //
+$ // Licensed under the Apache License, Version 2.0 (the "License");
+$ // you may not use this file except in compliance with the License.
+$ // You may obtain a copy of the License at
+$ //
+$ // http://www.apache.org/licenses/LICENSE-2.0
+$ //
+$ // Unless required by applicable law or agreed to in writing, software
+$ // distributed under the License is distributed on an "AS IS" BASIS,
+$ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+$ // See the License for the specific language governing permissions and
+$ // limitations under the License.
$ template make_abs_prods()
$ set baseprod = {//prod/@ename}
$ foreach {//prod}
-class @ename special Prod end
+class @ename super Prod end
$ end
$ foreach {//alt}
class @ename
-special ${../@ename}
+ super ${../@ename}
$ foreach {elem}
$ if @is_list
- readable writable var _n_@name: List[@etype] = new List[@etype]
+ readable var _n_@name: List[@etype] = new List[@etype]
$ else
$ if @modifier
- readable writable var _n_@name: nullable @etype = null
+ readable var _n_@name: nullable @etype = null
$ else
- readable writable var _n_@name: @etype
+ readable var _n_@name: @etype
$ end
$ end
$ end
$ end
class Start
-special Prod
- readable writable var _n_base: nullable $baseprod
- readable writable var _n_eof: EOF
+ super Prod
+ readable var _n_base: nullable $baseprod
+ readable var _n_eof: EOF
end
$ end template
$ set baseprod = {//prod/@ename}
$ foreach {//alt}
redef class @ename
-$ foreach {elem}
-$ if @is_list
-$ else
- redef fun n_@name=(n)
- do
- _n_@name = n
-$ if @modifier
- if n != null then
- n.parent = self
- end
-$ else
- n.parent = self
-$ end
- end
-$ end
-$ end
-
private init empty_init do end
$ if {count(elem)!=0}
init init_${translate(@ename,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")} (
$ foreach {elem}
$ if {@is_list}
- n_@{name}: Collection[Object] [-sep ','-] # Should be Collection[@etype]
+ n_@{name}: Collection[Object][-sep ','-] # Should be Collection[@etype]
$ else
- n_@{name}: nullable @etype [-sep ','-]
+ n_@{name}: nullable @etype[-sep ','-]
$ end
$ end
)
$ foreach {elem}
$ if @is_list
for n in _n_@{name} do
- v.visit(n)
- end
-$ else
-$ if @modifier
- if _n_@{name} != null then
- v.visit(_n_@{name}.as(not null))
- end
-$ else
- v.visit(_n_@{name})
-$ end
-$ end
-$ end foreach
- end
-
- redef fun visit_all_reverse(v: Visitor)
- do
-$ foreach {elem}
-$ if @is_list
- do
- var i = _n_@{name}.length
- while i >= 0 do
- v.visit(_n_@{name}[i])
- i = i - 1
+ v.enter_visit(n)
end
- end
$ else
$ if @modifier
if _n_@{name} != null then
- v.visit(_n_@{name}.as(not null))
+ v.enter_visit(_n_@{name}.as(not null))
end
$ else
- v.visit(_n_@{name})
+ v.enter_visit(_n_@{name})
$ end
$ end
$ end foreach
redef fun visit_all(v: Visitor)
do
if _n_base != null then
- v.visit(_n_base.as(not null))
- end
- end
-
- redef fun visit_all_reverse(v: Visitor)
- do
- if _n_base != null then
- v.visit(_n_base.as(not null))
+ v.enter_visit(_n_base.as(not null))
end
+ v.enter_visit(_n_eof)
end
end
$ end template