/* * vocabulary test */ #include "tads.h" #include "t3.h" #include "dict.h" dictionary G_dict; dictionary property noun, adjective, plural; class Item: object ; class Book: Item noun = 'book' 'booklet' 'volume' plural = 'books' 'booklets' 'volumes' sdesc = "book" adjective = 'musty' ; class LightItem: Item noun = 'light' ; modify Book noun = 'tome' replace plural = 'tomes' ; redBook: Book adjective = 'red' sdesc = "red_book" ; lightSwitch: SwitchItem, LightItem sdesc = "light_switch" ; main(args) { "noun 'book': <>\n"; "noun 'booklet': <>\n"; "plural 'books': <>\n"; "noun 'tome': <>\n"; "plural 'tomes': <>\n"; "adjective 'red': <>\n"; "adjective 'musty': <>\n"; "\b"; "redBook.noun: <>\n"; "blueBook.noun: <>\n"; "blueBook.plural: <>\n"; "redBook.adjective: <>\n"; "blueBook.adjective: <>\n"; "blueBook.plural: <>\n"; "\b"; "noun 'switch': <>\n"; "noun 'light': <>\n"; "lightSwitch.noun: <>\n"; "lightSwitch.adjective: <>\n"; "\b"; "Iterating over each dictionary entry...\n"; G_dict.forEachWord({ obj, str, prop: "\t<>: <> <>\n"}); } sayList(lst) { if (lst == nil) { "nil"; } else { "["; for (local i = 1, local len = lst.length() ; i <= len ; i += 2) { if (i > 1) ", "; lst[i].sdesc; } "]"; } } sayStrList(lst) { if (lst == nil) { "nil"; } else { "["; for (local i = 1, local len = lst.length() ; i <= len ; ++i) { if (i > 1) ", "; tadsSay(lst[i]); } "]"; } }