term

sometimes we want to use term by REFERRING it it by an id.

this language lets you double numbers. and we referred to the "number" term by its id.

TRANSLATED:



we REGISTER a term on the Term class like this. in this case, "number" is the id we use. but we could write ANYTHING.

Term.number = new NumberTerm()

now we make a class that gets a term by its id.

class TermTerm extends Term {
	constructor(id) {
		return Term[id]
	}
}

then we can use the number term by reference in our list.

const listTerm = new ListTerm([
	new StringTerm("double"),
	new MaybeTerm(new GapTerm()),
	new TermTerm("number"),
])

back to the dream