Merge: doc: fixed some typos and other misc. corrections
[nit.git] / src / parser / parser_work.nit
index a344fc7..217a09a 100644 (file)
@@ -40,7 +40,7 @@ class Parser
 
        init
        do
-               build_reduce_table
+               self.reduce_table = once build_reduce_table
        end
 
        # Do a transition in the automata
@@ -155,7 +155,7 @@ class Parser
        end
 
        private var reduce_table: Array[ReduceAction] is noinit
-       private fun build_reduce_table is abstract
+       private fun build_reduce_table: Array[ReduceAction] is abstract
 end
 
 redef class Prod
@@ -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