|
sdr 0.7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.cscott.sdr.calls.CallDB
public class CallDB
CallDB holds all the calls and concepts we know about. It is a singleton class; its static constructor loads all the call definitions from files and other classes.
Field Summary | |
---|---|
Collection<Call> |
allCalls
|
static CallDB |
INSTANCE
|
Method Summary | |
---|---|
Call |
lookup(String name)
Lookup a call in the database. |
Apply |
parse(Program program,
String s)
Parse a natural-language string of calls. |
void |
reload()
Reload call definitions from resource files and classes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final CallDB INSTANCE
public final Collection<Call> allCalls
Method Detail |
---|
public Call lookup(String name)
IllegalArgumentException
- if the call name is
unknown.js> db = CallDB.INSTANCE net.cscott.sdr.calls.CallDB@1d66e22 js> db.lookup("square thru") square thru[basic]
js> try { > CallDB.INSTANCE.lookup("foobar bat") > } catch (e) { > print(e.javaException) > } java.lang.IllegalArgumentException: Unknown call: foobar bat
public void reload()
public Apply parse(Program program, String s)
js> db = CallDB.INSTANCE net.cscott.sdr.calls.CallDB@1d66e22 js> db.parse(Program.BASIC, "double pass thru") (Apply 'double pass thru) js> db.parse(Program.BASIC, "square thru three and a half") (Apply (Expr square thru '3 1/2))
js> db = CallDB.INSTANCE ; undefined js> db.parse(Program.BASIC, "square thru 3 1/2") (Apply (Expr square thru '3 1/2))
js> db = CallDB.INSTANCE ; undefined js> db.parse(Program.BASIC, "do one half of a trade") (Apply (Expr _fractional '1/2 'trade)) js> db.parse(Program.PLUS, "do one half of a trade and roll") (Apply (Expr and roll (Expr _fractional '1/2 'trade))) js> db.parse(Program.PLUS, "trade twice and roll") (Apply (Expr and roll (Expr _fractional '2 'trade))) js> db.parse(Program.PLUS, "trade and roll twice") (Apply (Expr _fractional '2 (Expr and roll 'trade)))
js> db = CallDB.INSTANCE ; undefined js> db.parse(Program.PLUS, "circulate; trade; u turn back") (Apply (Expr and 'circulate 'trade 'u turn back))
js> db = CallDB.INSTANCE ; undefined js> db.parse(Program.PLUS, "do one half of a trade and roll") (Apply (Expr and roll (Expr _fractional '1/2 'trade))) js> db.parse(Program.PLUS, "do one half of a ( trade and roll )") (Apply (Expr _fractional '1/2 (Expr and roll 'trade)))
js> db = CallDB.INSTANCE ; undefined js> try { > db.parse(Program.C4, "@trade") > } catch (e) { > print(e.javaException) > } net.cscott.sdr.calls.BadCallException: Not on list: @trade js> try { > db.parse(Program.C4, "foobar bat") > } catch (e) { > print(e.javaException) > } net.cscott.sdr.calls.BadCallException: Not on list: foobar bat js> try { > db.parse(Program.MAINSTREAM, "trade and roll") > } catch (e) { > print(e.javaException) > } net.cscott.sdr.calls.BadCallException: Not on list: trade and roll
|
sdr 0.7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |