// Path: src/main/java/tech/pinto/Pinto.java
// public static class Expression implements TableFunction {
// 		
// 	private final boolean isSubExpression;
// 	private ArrayList<TableFunction>  functions = new ArrayList<>();
// 	private	Optional<Indexer> indexer = null;
// 	private	Optional<TerminalFunction> terminalFunction = Optional.empty();
// 	private Set<String> dependencies = new HashSet<>();
// 	private StringBuilder text = new StringBuilder();
// 	private	Optional<String> nameLiteral = Optional.empty();
// 		
// 	public Expression(boolean isSubExpression) {
// 		this.isSubExpression = isSubExpression;
// 	}
// 
// 	public Table evaluate(Pinto pinto) {
// 		if(!terminalFunction.isPresent()) {
// 			throw new PintoSyntaxException("Need terminal to evaluate expression.");
// 		}
// 		return terminalFunction.get().apply(pinto, this);
// 	}
// 
// 	@Override
// 	public void accept(Pinto pinto, Table table) {
// 		try {
// 			this.indexer.orElse(new Indexer(true)).accept(pinto, table);
// 			for(int i = 0; i < functions.size(); i++) {
// 				functions.get(i).accept(pinto, table);
// 			}
// 			table.collapseFunction();
// 		} catch(RuntimeException e) {
// 			throw new PintoSyntaxException("Error in expression: \"" + getText().trim() + "\": " + e.getLocalizedMessage() + "\n",e);
// 		}
// 	}
// 		
// 	public void addIndexer(Indexer indexer) {
// 		if(this.indexer == null) {
// 			indexer.setIndexForExpression();
// 			this.indexer = Optional.of(indexer);
// 		} else {
// 			functions.add(indexer);
// 		}
// 	}
// 
// 	public void addFunction(Column<?> col) {
// 		addFunction((StackFunction) (p, s) -> s.addFirst(col));
// 	}
// 
// 	public void addFunction(TableFunction function) {
// 		if(this.indexer == null) {
// 			this.indexer = Optional.empty();
// 		}
// 		functions.add(function);
// 	}
// 
// 	public void setTerminal(TerminalFunction function) {
// 		if(isSubExpression) {
// 			throw new PintoSyntaxException("Sub-expressions cannot include terminal functions");
// 		}
// 		this.terminalFunction = Optional.of(function);
// 	}
// 
// 	public ArrayList<TableFunction> getFunctions() {
// 		return functions;
// 	}
// 		
// 	public boolean isExpressionStart() {
// 		return functions.size() == 0;
// 	}
// 
// 	public boolean isNullary() {
// 		return (!indexer.isPresent()) || indexer.get().isNone();
// 	}
// 
// 	public Set<String> getDependencies() {
// 		return dependencies;
// 	}
// 
// 	public String getText() {
// 		return text.toString();
// 	}
// 
// 	public void addText(String expression) {
// 		this.text.append(" ").append(expression);
// 	}
// 
// 	public Optional<String> getNameLiteral() {
// 		return nameLiteral;
// 	}
// 
// 	public void setNameLiteral(String nameLiteral) {
// 		this.nameLiteral = Optional.of(nameLiteral);
// 	}
// 		
// 	public boolean hasTerminal() {
// 		return terminalFunction.isPresent();
// 	}
// 
// }
// 
// Path: src/main/java/tech/pinto/Pinto.java
// @FunctionalInterface
// public static interface TableFunction extends BiConsumer<Pinto,Table> {}


import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.stream.Collectors;
import javax.inject.Inject;
import com.google.common.base.Joiner;
import jline.console.completer.Completer;
import tech.pinto.Pinto.Expression;
import tech.pinto.Pinto.TableFunction;

	}
	
	public synchronized boolean contains(String name) {
		return names.containsKey(name);
	}

	public synchronized String define(Pinto pinto, Expression expression, boolean onlyIfUndefined) {
		String name = expression.getNameLiteral()
				.orElseThrow(() -> new PintoSyntaxException("A name literal is required to define a name."));
		if(names.containsKey(name)) {
			if(onlyIfUndefined) {
				return name;
			}
			if(names.get(name).isBuiltIn()) {
				throw new IllegalArgumentException("Cannot redefine built-in name " + name + ".");
			}
			clearCache(name);
			for(String dependencyCode : getDependsOn(name)) {
				dependencyGraph.remove(join(name, "dependsOn", dependencyCode));
				dependencyGraph.remove(join(dependencyCode, "dependedOnBy", name));
			}
		}
		for(String dependencyName : expression.getDependencies()) {
			dependencyGraph.add(join(name, "dependsOn", dependencyName));
			dependencyGraph.add(join(dependencyName, "dependedOnBy", name));
		}
		if(expression.isNullary()) {
			names.put(name, Name.nameBuilder(name,Cache.cacheNullaryFunction(name, expression))
					.defined().description(expression.getText()).build());
		} else {

// Path: src/main/java/tech/pinto/Pinto.java
// public static class Expression implements TableFunction {
// 		
// 	private final boolean isSubExpression;
// 	private ArrayList<TableFunction>  functions = new ArrayList<>();
// 	private	Optional<Indexer> indexer = null;
// 	private	Optional<TerminalFunction> terminalFunction = Optional.empty();
// 	private Set<String> dependencies = new HashSet<>();
// 	private StringBuilder text = new StringBuilder();
// 	private	Optional<String> nameLiteral = Optional.empty();
// 		
// 	public Expression(boolean isSubExpression) {
// 		this.isSubExpression = isSubExpression;
// 	}
// 
// 	public Table evaluate(Pinto pinto) {
// 		if(!terminalFunction.isPresent()) {
// 			throw new PintoSyntaxException("Need terminal to evaluate expression.");
// 		}
// 		return terminalFunction.get().apply(pinto, this);
// 	}
// 
// 	@Override
// 	public void accept(Pinto pinto, Table table) {
// 		try {
// 			this.indexer.orElse(new Indexer(true)).accept(pinto, table);
// 			for(int i = 0; i < functions.size(); i++) {
// 				functions.get(i).accept(pinto, table);
// 			}
// 			table.collapseFunction();
// 		} catch(RuntimeException e) {
// 			throw new PintoSyntaxException("Error in expression: \"" + getText().trim() + "\": " + e.getLocalizedMessage() + "\n",e);
// 		}
// 	}
// 		
// 	public void addIndexer(Indexer indexer) {
// 		if(this.indexer == null) {
// 			indexer.setIndexForExpression();
// 			this.indexer = Optional.of(indexer);
// 		} else {
// 			functions.add(indexer);
// 		}
// 	}
// 
// 	public void addFunction(Column<?> col) {
// 		addFunction((StackFunction) (p, s) -> s.addFirst(col));
// 	}
// 
// 	public void addFunction(TableFunction function) {
// 		if(this.indexer == null) {
// 			this.indexer = Optional.empty();
// 		}
// 		functions.add(function);
// 	}
// 
// 	public void setTerminal(TerminalFunction function) {
// 		if(isSubExpression) {
// 			throw new PintoSyntaxException("Sub-expressions cannot include terminal functions");
// 		}
// 		this.terminalFunction = Optional.of(function);
// 	}
// 
// 	public ArrayList<TableFunction> getFunctions() {
// 		return functions;
// 	}
// 		
// 	public boolean isExpressionStart() {
// 		return functions.size() == 0;
// 	}
// 
// 	public boolean isNullary() {
// 		return (!indexer.isPresent()) || indexer.get().isNone();
// 	}
// 
// 	public Set<String> getDependencies() {
// 		return dependencies;
// 	}
// 
// 	public String getText() {
// 		return text.toString();
// 	}
// 
// 	public void addText(String expression) {
// 		this.text.append(" ").append(expression);
// 	}
// 
// 	public Optional<String> getNameLiteral() {
// 		return nameLiteral;
// 	}
// 
// 	public void setNameLiteral(String nameLiteral) {
// 		this.nameLiteral = Optional.of(nameLiteral);
// 	}
// 		
// 	public boolean hasTerminal() {
// 		return terminalFunction.isPresent();
// 	}
// 
// }
// 
// Path: src/main/java/tech/pinto/Pinto.java
// @FunctionalInterface
// public static interface TableFunction extends BiConsumer<Pinto,Table> {}


// Path: src/main/java/tech/pinto/Namespace.java
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.stream.Collectors;
import javax.inject.Inject;
import com.google.common.base.Joiner;
import jline.console.completer.Completer;
import tech.pinto.Pinto.Expression;
import tech.pinto.Pinto.TableFunction;

	}
	
	public synchronized boolean contains(String name) {
		return names.containsKey(name);
	}

	public synchronized String define(Pinto pinto, Expression expression, boolean onlyIfUndefined) {
		String name = expression.getNameLiteral()
				.orElseThrow(() -> new PintoSyntaxException("A name literal is required to define a name."));
		if(names.containsKey(name)) {
			if(onlyIfUndefined) {
				return name;
			}
			if(names.get(name).isBuiltIn()) {
				throw new IllegalArgumentException("Cannot redefine built-in name " + name + ".");
			}
			clearCache(name);
			for(String dependencyCode : getDependsOn(name)) {
				dependencyGraph.remove(join(name, "dependsOn", dependencyCode));
				dependencyGraph.remove(join(dependencyCode, "dependedOnBy", name));
			}
		}
		for(String dependencyName : expression.getDependencies()) {
			dependencyGraph.add(join(name, "dependsOn", dependencyName));
			dependencyGraph.add(join(dependencyName, "dependedOnBy", name));
		}
		if(expression.isNullary()) {
			names.put(name, Name.nameBuilder(name,Cache.cacheNullaryFunction(name, expression))
					.defined().description(expression.getText()).build());
		} else {

			names.put(name, Name.nameBuilder(name, (TableFunction) (p,t) -> expression.accept(p, t))
