gdritter repos documents / 5671092
aquan changes Getty Ritter 8 years ago
1 changed file(s) with 12 addition(s) and 10 deletion(s). Collapse all Expand all
1616 {- The ::= operator is for the common case that we want to select from a
1717 - whole bunch of literal characters or words. It is referred to as the
1818 - 'literal assignment operator'. -}
19 vowel ::= a e i o u
20 consonant ::= p t k w h m n l
19 vowel = $(a e i o u)
20 consonant = $(p t k w h m n l)
2121
2222 {- The := operator sets the value on the left to be
23 syll = vowel | consonant vowel
24 | vowel "'" | consonant vowel "'"
25 word = syll syll (6 @ syll)
23 syll = vowel | consonant vowel | vowel "'" | consonant vowel "'"
24 word = syll syll (rep.6.syll)
2625
2726
2827 {- Fixing a value -}
4544
4645 pronoun.Male = "he"
4746 pronoun.Female = "she"
47 pronoun.NB = "they"
48
4849 person.Male = "man"
4950 person.Female = "woman"
51 person.NB = "person"
5052
51 fixed gender = Male | Female
52 hair ::= long short
53 hair_color ::= brown black blonde red white
54 eye_color ::= blue black brown green
55 mood ::= happy sad angry
53 fixed gender = Male | Female | NB
54 hair = $(long short)
55 hair_color = $(brown black blonde red white)
56 eye_color = $(blue black brown green)
57 mood = $(happy sad angry)
5658
5759 puts "This {person.gender} has {hair}, {hair_color} hair and "
5860 "{eye_color} eyes; {pronoun.gender} appears to be "