Commits

Anonymous committed 3085a1d

Package separator switched to ':'; extracted qualified_class_name; renamed is_class_name to is_class_name_elt

  • Participants
  • Parent commits 3d9e0a7
  • Branches packages

Comments (0)

Files changed (1)

File Compiler/Front/parse.sa

 	 res.kind := res.ref;
 	 match(class_tok);
       end;
-			class_name ::= "";
       if check(ident_tok) then
-			loop
-			   class_name := class_name + ident.str;
-			   if ~is_class_name(ident) then
-			      exp_error("class name")
-			   end;
-			   while!( check( dcolon_tok ));
-			   class_name := class_name + "::";
-			   fetch;
-			   #OUT + "next: " + ident.str + "\n";
-			end;
-
---         if ~is_class_name(ident) then
---            exp_error("class name")
---         end
+        res.name := qualified_class_name;
       else exp_error("concrete class name");
          if next = type_name_tok then fetch end
       end;
       --res.name := ident;
-			#OUT + "_class_name: " + class_name + "\n";
-			res.name := #IDENT(class_name);
       if check(lbrace_tok) then
          loop until!(next /= ident_tok);
 	    if void(res.params) then res.params:=param_dec
       return res
    end;
 
-   is_class_name (x: IDENT): BOOL is
+   qualified_class_name : IDENT is
+   -- Gets class name with any prefixed packages
+     class_name ::= "";
+     loop
+       class_name := class_name + ident.str;
+       if ~is_class_name_elt(ident) then
+         exp_error("class name")
+       end;
+       while!( check( colon_tok ));
+       class_name := class_name + ":";
+       fetch;
+       #OUT + "next: " + ident.str + "\n";
+     end;
+   end;
+
+   is_class_name_elt (x: IDENT): BOOL is
+   -- True if class name element (class name itself or package name)
       return scanner.is_class_name(x.str)
    end;
 
       enter("parameter declaration");
       res ::= #AS_PARAM_DEC; res.source := source_loc;
       match(ident_tok); res.name := ident;
-      if ~is_class_name(res.name) then 
+      if ~is_class_name_elt(res.name) then 
          exp_error("class name") end;
       if check(is_lt_tok) then res.type_constraint := type_spec end;
       exit;
       res ::= #AS_TYPE_SPEC; res.source := source_loc;
       if check(SAME_tok) then res.kind := AS_TYPE_SPEC::same
       elsif (next = type_name_tok) or (next = ident_tok) then
-         if (next = ident_tok) and ~is_class_name(ident) then
+         if (next = ident_tok) and ~is_class_name_elt(ident) then
             error("class name must be all upper_case") end;
          res.kind := AS_TYPE_SPEC::ord;
          res.name := ident; fetch;
    -- rout_or_iter_name => ident | [ident] '!'
    --
       res: IDENT;
+			#OUT + "ident: " + ident.str + "\n";
       if next = ident_tok then res := ident; fetch;
          if next = iter_bang_tok then fetch;
             res := append_bang(res)
    --
       res: AS_CALL_EXPR;
       enter("call expressions");
+			#OUT + "tp: " + tp.name.str + "\n";
       res := #AS_CALL_EXPR; res.source := source_loc; res.ob := ob; res.tp := tp;
       res.name := rout_or_iter_name;
+			#OUT + "rout_or_iter_name: " + res.name.str + "\n";
       if check(lparen_tok) then 
 	  -- always allow once? Check later? (Boris)
 	  t ::= mode_expr_list(underscore_args, res.name.is_iter); 
       typecase x when AS_CALL_EXPR then
          if void(x.ob) then
             if void(x.tp) then
-               if is_class_name(x.name) then
+               if is_class_name_elt(x.name) then
                   tp ::= #AS_TYPE_SPEC; tp.source := x.source;
                   tp.kind := AS_TYPE_SPEC::ord;
                   tp.is_hot := false;
       if check(dot_tok) then -- expr0 '.'
          res := call_expr(res, void, underscore_args)
       elsif check(dcolon_tok) then -- type_spec '::'
-         res := call_expr(void, type_of(res), underscore_args)
+				#OUT + "call expr with dcolon\n";
+				-- TODO: extract full class name (with package)
+         res := call_expr(void, type_of(res), underscore_args);
       elsif check(iter_bang_tok) then -- part of call_expr: ident '!'
          c := #AS_CALL_EXPR; c.source := source_loc;
          c.name := append_bang(ident_of(res));
          fetch; res := #AS_SELF_EXPR; res.source := source_loc
       when ident_tok then
          call_exp ::= #AS_CALL_EXPR; call_exp.source := source_loc;
-         if is_class_name(ident) then call_exp.tp := type_spec;
+         if is_class_name_elt(ident) then call_exp.tp := type_spec;
 	    -- DPS changed from this
             --if (call_exp.tp.kind = AS_TYPE_SPEC::ord) and void(call_exp.tp.params) then -- maybe ordinary call
             --   call_exp.name := call_exp.tp.name;