grammer: accept redef and visibility in front of annotation
authorJean Privat <jean@pryen.org>
Mon, 14 Jul 2014 14:25:12 +0000 (10:25 -0400)
committerJean Privat <jean@pryen.org>
Wed, 16 Jul 2014 20:56:49 +0000 (16:56 -0400)
~~~
var foo is public bar
fun baz is
   # doc
   redef private foobar
end
~~~

Signed-off-by: Jean Privat <jean@pryen.org>

src/parser/nit.sablecc3xx
src/parser/parser_nodes.nit

index 41de805..52516c7 100644 (file)
@@ -603,9 +603,9 @@ annotations_o~nopar {-> annotations?}
        ;
 
 one_annotation~nopar {-> annotation}
-       = {alone} atid annotations_o~nopar {-> New annotation(atid, Null, [], Null, annotations_o~nopar.annotations)}
+       = {alone} redef visibility atid annotations_o~nopar {-> New annotation(Null, redef.kwredef, visibility, atid, Null, [], Null, annotations_o~nopar.annotations)}
 // !nopar to unambiguise 'new T@foo(bar)' between 'new T@(foo(bar))' and 'new (T@foo)(bar)'
-!nopar | {args} atid opar no at_args [n2]:no cpar annotations_o~nopar {-> New annotation(atid, opar, [at_args.at_arg], cpar, annotations_o~nopar.annotations)}
+!nopar | {args} redef visibility atid opar no at_args [n2]:no cpar annotations_o~nopar {-> New annotation(Null, redef.kwredef, visibility, atid, opar, [at_args.at_arg], cpar, annotations_o~nopar.annotations)}
        ;
 
 many_annotations {-> annotations}
@@ -616,13 +616,21 @@ annotation_list {-> annotation*}
        = {many} one_annotation annotations_tail* {-> [one_annotation.annotation, annotations_tail.annotation] }
        ;
 
-line_annotations~forclass {-> annotations}
-       = line_annotation~forclass+ {-> New annotations(Null, Null, [line_annotation~forclass.annotation], Null) }
+line_annotations {-> annotations}
+       = line_annotation+ {-> New annotations(Null, Null, [line_annotation.annotation], Null) }
        ;
-line_annotation~forclass {-> annotation}
-       = [doc]:no atid~forclass annotations? n1 {-> New annotation(atid~forclass.atid, Null, [], Null, annotations)}
-       | {args} [doc]:no atid~forclass opar no at_args cpar annotations? n1 {-> New annotation(atid~forclass.atid, opar, [at_args.at_arg], cpar, annotations)}
-       | {nopar} [doc]:no atid~forclass at_args_nopar n1 {-> New annotation(atid~forclass.atid, Null, [at_args_nopar.at_arg], Null, Null)}
+line_annotation {-> annotation}
+       = [doc]:no redef visibility atid annotations? n1 {-> New annotation(doc.doc, redef.kwredef, visibility, atid.atid, Null, [], Null, annotations)}
+       | {args} [doc]:no redef visibility atid opar no at_args cpar annotations? n1 {-> New annotation(doc.doc, redef.kwredef, visibility, atid.atid, opar, [at_args.at_arg], cpar, annotations)}
+       | {nopar} [doc]:no redef visibility atid at_args_nopar n1 {-> New annotation(doc.doc, redef.kwredef, visibility, atid.atid, Null, [at_args_nopar.at_arg], Null, Null)}
+       ;
+line_annotations_forclass {-> annotations}
+       = line_annotation_forclass+ {-> New annotations(Null, Null, [line_annotation_forclass.annotation], Null) }
+       ;
+line_annotation_forclass {-> annotation}
+       = [doc]:no atid_forclass annotations? n1 {-> New annotation(doc.doc, Null, Null, atid_forclass.atid, Null, [], Null, annotations)}
+       | {args} [doc]:no atid_forclass opar no at_args cpar annotations? n1 {-> New annotation(doc.doc, Null, Null, atid_forclass.atid, opar, [at_args.at_arg], cpar, annotations)}
+       | {nopar} [doc]:no atid_forclass at_args_nopar n1 {-> New annotation(doc.doc, Null, Null, atid_forclass.atid, Null, [at_args_nopar.at_arg], Null, Null)}
        ;
 
 annotations_tail {-> annotation}
@@ -901,7 +909,7 @@ doc = comment+;
 
 annotations = at? opar? [items]:annotation* cpar?;
 
-annotation = atid opar? [args]:at_arg* cpar? annotations?;
+annotation = doc? kwredef? visibility? atid opar? [args]:at_arg* cpar? annotations?;
 
 at_arg
        = {type} type
index 435a809..8a6bf20 100644 (file)
@@ -2408,6 +2408,15 @@ class AAnnotations
 end
 class AAnnotation
        super Prod
+       var _n_doc: nullable ADoc = null
+       fun n_doc: nullable ADoc do return _n_doc
+       fun n_doc=(n_doc: nullable ADoc) do _n_doc = n_doc
+       var _n_kwredef: nullable TKwredef = null
+       fun n_kwredef: nullable TKwredef do return _n_kwredef
+       fun n_kwredef=(n_kwredef: nullable TKwredef) do _n_kwredef = n_kwredef
+       var _n_visibility: nullable AVisibility
+       fun n_visibility: nullable AVisibility do return _n_visibility
+       fun n_visibility=(n_visibility: nullable AVisibility) do _n_visibility = n_visibility
        var _n_atid: AAtid
        fun n_atid: AAtid do return _n_atid
        fun n_atid=(n_atid: AAtid) do _n_atid = n_atid