!This module is a stripped down version of the standard walker for
!all compilers built with this system. The implementor of a new
!language uses this file as is. All language dependant stuff goes into
!custwalk. To get an interpeter instead of a compiler, the implementor
!simply links in another walker (also standard).

import custwalk
export Object_id_for, Runcall, Walk, Walk_list

func Walk(T) -> Entity
  if T(1) in {Runcall, Walk_list}
    return T(1)(tl(T))
  else
    return eval(T(1), tl(T))
  end

func Runcall(lst) -> Entity
  return lst(1) + as_string(Walk_list(rest(lst)))

func Walk_list(lst) -> list of Entity
  return [all Walk(i) for i in lst]

func Object_id_for(cn, iv) -> Entity
  return `new_'+cn+`(\`'+iv+`\')'

func as_string(lst) -> String
  return `()' when lst = []
  result := `('
  for e in all_but_last(lst)
    result +:= mkstr(e)+`, '
  loop
  result +:= mkstr(last(lst))+`)'

