anchor.diff:  %%% -*- erlang-indent-level: 2 -*-
   %%%
  -%%%   Copyright 2014 Mikael Pettersson
  +%%%   Copyright 2014-2015 Mikael Pettersson
   %%%
   %%%   Licensed under the Apache License, Version 2.0 (the "License");
   %%%   you may not use this file except in compliance with the License.
  
positive.code: %%% Notes:
  %%% - LETREC is implemented via finite unfolding of a local
  %%%   non-recursive environment fragment
  
  -module(es_eval).
  
  
negative.code: 
  dynamic_eval(Sexpr) ->
    case es_gloenv:lookup('eval', 'var') of
      {value, Val} -> do_apply(Val, [Sexpr])
    end.
  
  primitive_eval(Sexpr) ->
    interpret(parse_toplevel(Sexpr), env_empty()).
  
  %% Parser from S-expressions to ASTs
  
  parse_toplevel(Sexpr) ->
    parse(Sexpr, env_empty(), true).
  
  parse(Sexpr, Env) ->
    parse(Sexpr, Env, false).
  
  parse(Sexpr, Env, IsToplevel) ->
    case Sexpr of
      [Hd | Tl] ->
        parse_form(Hd, Tl, Env, IsToplevel);
      Symbol when is_atom(Symbol) ->
        parse_atom(Symbol, Env);
      _ ->
        case is_self_evaluating(Sexpr) of
  	true ->
  	  {'ES:QUOTE', Sexpr};
  	false ->
  	  erlang:throw({invalid_expression, Sexpr})
        end
    end.
  
  