parser: node locations are not nullable
[nit.git] / src / parser / parser_nodes.nit
index 81a7a57..36c5ceb 100644 (file)
@@ -23,7 +23,10 @@ import mmloader
 
 # Root of the AST hierarchy
 abstract class ANode
-       readable var _location: nullable Location
+       var _location: nullable Location
+       # Location is set during AST building. Once built, location cannon be null
+       # However, manual instanciated nodes may need mode care
+       fun location: Location do return _location.as(not null)
 end
 
 # Ancestor of all tokens
@@ -34,7 +37,7 @@ end
 # Ancestor of all productions
 abstract class Prod
 special ANode
-       fun location=(loc: nullable Location) do _location = loc
+       fun location=(l: Location) do _location = l
 end
 class TEol
 special Token
@@ -189,6 +192,9 @@ end
 class TKwisset
 special Token
 end
+class TKwlabel
+special Token
+end
 class TOpar
 special Token
 end
@@ -294,7 +300,7 @@ end
 class TEndString
 special Token
 end
-class EOF 
+class EOF
 special Token
 private init noinit do end
 end
@@ -392,7 +398,7 @@ special Prod
     readable writable var _n_kwspecial: TKwspecial
     readable writable var _n_type: AType
 end
-class APropdef special Prod 
+class APropdef special Prod
     readable writable var _n_doc: nullable ADoc = null
 end
 class AAttrPropdef
@@ -553,6 +559,11 @@ special Prod
     readable writable var _n_id: TClassid
     readable writable var _n_types: List[AType] = new List[AType]
 end
+class ALabel
+special Prod
+    readable writable var _n_kwlabel: TKwlabel
+    readable writable var _n_id: TId
+end
 class AExpr special Prod end
 class ABlockExpr
 special AExpr
@@ -571,8 +582,13 @@ special AExpr
     readable writable var _n_kwreturn: TKwreturn
     readable writable var _n_expr: nullable AExpr = null
 end
+class ALabelable
+special Prod
+    readable writable var _n_label: nullable ALabel = null
+end
 class ABreakExpr
 special AExpr
+special ALabelable
     readable writable var _n_kwbreak: TKwbreak
     readable writable var _n_expr: nullable AExpr = null
 end
@@ -582,11 +598,13 @@ special AExpr
 end
 class AContinueExpr
 special AExpr
+special ALabelable
     readable writable var _n_kwcontinue: TKwcontinue
     readable writable var _n_expr: nullable AExpr = null
 end
 class ADoExpr
 special AExpr
+special ALabelable
     readable writable var _n_kwdo: TKwdo
     readable writable var _n_block: nullable AExpr = null
 end
@@ -608,6 +626,7 @@ special AExpr
 end
 class AWhileExpr
 special AExpr
+special ALabelable
     readable writable var _n_kwwhile:  TKwwhile
     readable writable var _n_expr: AExpr
     readable writable var _n_kwdo: TKwdo
@@ -615,6 +634,7 @@ special AExpr
 end
 class AForExpr
 special AExpr
+special ALabelable
     readable writable var _n_kwfor: TKwfor
     readable writable var _n_id: TId
     readable writable var _n_expr: AExpr
@@ -744,20 +764,20 @@ special ASendExpr
 end
 class AAttrReassignExpr
 special AExpr
-special AAttrFormExpr 
-special AReassignFormExpr 
+special AAttrFormExpr
+special AReassignFormExpr
 end
 class ACallExpr
 special ACallFormExpr
 end
 class ACallAssignExpr
 special ACallFormExpr
-special AAssignFormExpr 
+special AAssignFormExpr
 end
 class ACallReassignExpr
 special AExpr
 special ACallFormExpr
-special AReassignFormExpr 
+special AReassignFormExpr
 end
 class ASuperExpr
 special AExpr
@@ -779,7 +799,7 @@ special ABraFormExpr
 end
 class ABraAssignExpr
 special ABraFormExpr
-special AAssignFormExpr 
+special AAssignFormExpr
 end
 class AVarFormExpr
 special AExpr
@@ -787,7 +807,7 @@ special AExpr
 end
 class ABraReassignExpr
 special ABraFormExpr
-special AReassignFormExpr 
+special AReassignFormExpr
 end
 class AClosureCallExpr
 special AExpr
@@ -800,11 +820,11 @@ special AVarFormExpr
 end
 class AVarAssignExpr
 special AVarFormExpr
-special AAssignFormExpr 
+special AAssignFormExpr
 end
 class AVarReassignExpr
 special AVarFormExpr
-special AReassignFormExpr 
+special AReassignFormExpr
 end
 class ARangeExpr
 special AExpr
@@ -909,7 +929,7 @@ special AAssignOp
     readable writable var _n_minuseq: TMinuseq
 end
 class AClosureDef
-special Prod
+special ALabelable
     readable writable var _n_kwwith: TKwwith
     readable writable var _n_id: List[TId] = new List[TId]
     readable writable var _n_kwdo: TKwdo