I'm working on a grammar for the names of scientific quatities. Toy example:
weight of iron
weight of copper
weight of tin
density of iron
density of copper
etc
Simple grammar:
start = measure _ "of" _ metal
measure = "weight"/"density"
metal = "iron"/"copper"/"tin"
_ = " "
But what I want to do is to store the metals in a simple database, as an array of object literals, e.g.
var metals = [{name:"iron",colour:"grey"},{name:"copper", colour:"brown"},......]
and have this (a) in the initializer section, or (b) in the rest of my code (preferable, since I'll be using the metals database for other purposes).
How do I adapt the 'metal' rule to handle this? I presume I need a "predicate", but can't see how to formulate it.
Thanks,
Robert