src/doc: introduce option --no-render in HTML phase.
[nit.git] / src / parser / parser_work.nit
index a344fc7..a5bef33 100644 (file)
@@ -298,3 +298,19 @@ private abstract class ReduceAction
        end
        var goto: Int
 end
+
+redef class AExpr
+
+       # Get `self` as a single identifier.
+       # Return null if not a single identifier.
+       fun as_id: nullable String
+       do
+               if self isa AMethidExpr then
+                       return self.collect_text
+               end
+               if not self isa ACallExpr then return null
+               if not self.n_expr isa AImplicitSelfExpr then return null
+               if not self.n_args.n_exprs.is_empty then return null
+               return self.n_qid.n_id.text
+       end
+end