Rename Val -> Sym

This commit is contained in:
greg 2019-08-30 19:10:16 -07:00
parent 61182a847f
commit 0540df4024
2 changed files with 6 additions and 6 deletions

View File

@ -132,7 +132,7 @@ impl Expr {
match self {
ConditionalTargetSigilValue => replacement.clone(),
Unit | Lit(_) | Func(_) | Val(_) | Constructor { .. } |
Unit | Lit(_) | Func(_) | Sym(_) | Constructor { .. } |
CaseMatch { .. } | UnimplementedSigilValue | ReductionError(_) => self,
Tuple(exprs) => Tuple(exprs.into_iter().map(|e| e.replace_conditional_target_sigil(replacement)).collect()),
Call { f, args } => {
@ -212,7 +212,7 @@ impl<'a> State<'a> {
Node::Expr(expr) => match expr {
literal @ Lit(_) => Ok(Node::Expr(literal)),
Call { box f, args } => self.call_expression(f, args),
Val(v) => self.value(v),
Sym(v) => self.handle_sym(v),
Constructor { arity, ref name, tag, .. } if arity == 0 => Ok(Node::PrimObject { name: name.clone(), tag, items: vec![] }),
constructor @ Constructor { .. } => Ok(Node::Expr(constructor)),
func @ Func(_) => Ok(Node::Expr(func)),
@ -371,7 +371,7 @@ impl<'a> State<'a> {
fn assign_expression(&mut self, val: Expr, expr: Expr) -> EvalResult<Node> {
let name = match val {
Expr::Val(name) => name,
Expr::Sym(name) => name,
_ => return Err(format!("Trying to assign to a non-value")),
};
@ -459,7 +459,7 @@ impl<'a> State<'a> {
}
//TODO if I don't need to lookup by name here...
fn value(&mut self, name: Rc<String>) -> EvalResult<Node> {
fn handle_sym(&mut self, name: Rc<String>) -> EvalResult<Node> {
use self::ValueEntry::*;
use self::Func::*;
//TODO add a layer of indirection here to talk to the symbol table first, and only then look up

View File

@ -43,7 +43,7 @@ pub enum Expr {
Lit(Lit),
Tuple(Vec<Expr>),
Func(Func),
Val(Rc<String>),
Sym(Rc<String>),
Constructor {
type_name: Rc<String>,
name: Rc<String>,
@ -160,7 +160,7 @@ impl Expression {
tag: index.clone(),
arity: type_args.len(),
},
_ => Expr::Val(name.clone()),
_ => Expr::Sym(name.clone()),
},
Call { f, arguments } => reduce_call_expression(f, arguments, symbol_table),
TupleLiteral(exprs) => Expr::Tuple(exprs.iter().map(|e| e.node().reduce(symbol_table)).collect()),