Branch: Tag:

1997-01-19

1997-01-19 09:08:03 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

Module system implemented

Rev: lib/master.pike:1.20
Rev: src/ChangeLog:1.53
Rev: src/Makefile.in:1.4
Rev: src/builtin_functions.c:1.21
Rev: src/interpret.h:1.7
Rev: src/language.yacc:1.18
Rev: src/las.c:1.12
Rev: src/las.h:1.4
Rev: src/lex.c:1.12
Rev: src/object.c:1.11
Rev: src/program.c:1.13
Rev: src/program.h:1.7
Rev: src/version.c:1.3

95:   %token F_GAUGE   %token F_IDENTIFIER   %token F_IF + %token F_IMPORT   %token F_INHERIT   %token F_INLINE   %token F_INT_ID
155:   /* This is the grammar definition of Pike. */      #include "global.h" - RCSID("$Id: language.yacc,v 1.17 1997/01/16 05:00:44 hubbe Exp $"); + RCSID("$Id: language.yacc,v 1.18 1997/01/19 09:08:00 hubbe Exp $");   #ifdef HAVE_MEMORY_H   #include <memory.h>   #endif
303:   %type <n> idents   %type <n> lambda   %type <n> local_name_list + %type <n> low_idents   %type <n> lvalue   %type <n> lvalue_list   %type <n> m_expr_list
359:    | idents    {    push_string(make_shared_string("")); -  if(!$1) +  resolv_constant($1); +  if(sp[-1].type != T_PROGRAM)    { -  push_int(0); -  }else{ -  switch($1->token) -  { -  case F_CONSTANT: -  if($1->u.sval.type == T_PROGRAM) -  { -  push_svalue(& $1->u.sval); -  }else{ +     yyerror("Illegal program identifier"); -  +  pop_stack();    push_int(0);    } -  break; -  -  case F_IDENTIFIER: -  { -  struct identifier *i; -  setup_fake_program(); -  i=ID_FROM_INT(& fake_program, $1->u.number); -  -  if(IDENTIFIER_IS_CONSTANT(i->flags)) -  { -  push_svalue(PROG_FROM_INT(&fake_program, $1->u.number)->constants + -  i->func.offset); -  }else{ -  yyerror("Illegal program identifier"); -  push_int(0); -  } -  break; -  } -  } +     free_node($1);    } -  } +     ;      inheritance: modifiers F_INHERIT program_ref optional_rename_inherit ';'
411:    }    ;    + import: modifiers F_IMPORT idents ';' +  { +  resolv_constant($3); +  free_node($3); +  use_module(sp-1); +  sp--; +  } +  ; +    constant_name: F_IDENTIFIER '=' expr0    {    int tmp;
555:    }    | modifiers type_or_error name_list ';' {}    | inheritance {} +  | import {}    | constant {}    | class { free_node($1); }    | error
1147:    }    ;    - idents: F_IDENTIFIER + idents: low_idents +  | idents '.' F_IDENTIFIER    { -  +  $$=index_node($1, $3); +  free_node($1); +  free_string($3); +  } +  ; +  + low_idents: F_IDENTIFIER +  {    int i;    struct efun *f;    if((i=islocal($1))>=0)
1156:    $$=mklocalnode(i);    }else if((i=isidentifier($1))>=0){    $$=mkidentifiernode(i); +  }else if(find_module_identifier($1)){ +  $$=mkconstantsvaluenode(sp-1); +  pop_stack();    }else if((f=lookup_efun($1))){    $$=mkconstantsvaluenode(&f->function);    }else{
1171:    if(throw_value.type == T_STRING)    {    my_yyerror("%s",throw_value.u.string->str); +  } +  else if(IS_ZERO(sp-1) && sp[-1].subtype==1) +  { +  my_yyerror("'%s' undefined.", $1->str);    }else{    $$=mkconstantsvaluenode(sp-1); -  pop_stack(); +     } -  +  pop_stack();    }else{    my_yyerror("'%s' undefined.", $1->str);    }