1 % ------------------------------------------------------------------------------ 2 % File: dotspeak_r.pro 3 % Type: Prolog source 4 % Line: Recognizer for the Dotspeak language 5 % Date: 2020 6 % ------------------------------------------------------------------------------ 7 % ------------------------------------------------------------------------------ 8 % libraries 9 10 11 :- consult('io.pro'). 12 % -------------------------------------------------------------------------- 13 % DCG for the Dotspeak language 14 15 16 sentence --> command,[.]. 17 sentence --> question,[?]. 18 19 20 question --> existentialquestion. 21 question --> countquestion. 22 question --> contentquestion. 23 24 25 command --> displaycommand. 26 command --> addcommand. 27 command --> deletecommand. 28 command --> movecommand. 29 command --> [stop]. 30 31 32 existentialquestion --> [is],[there],nsdot. 33 existentialquestion --> [is],[there],nsdot,[on],[the],[table]. 34 existentialquestion --> [is],[there],nsdot,[not],[on],[the],[table]. 35 existentialquestion --> [is],[there],csdot. 36 existentialquestion --> [is],[there],csdot,[on],[the],[table]. 37 existentialquestion --> [is],[there],csdot,[not],[on],[the],[table]. 38 existentialquestion --> [is],[there],csdot,[to],[the],[left],[of],csdot. 39 existentialquestion --> [is],[there],csdot,[to],[the],[right],[of],csdot. 40 41 42 countquestion --> countdots,[in],[column],columnid. 43 countquestion --> countdots,[in],[the],[world]. 44 countquestion --> countdots,[on],[the],[table]. 45 countquestion --> countdots,[off],[the],[table]. 46 countquestion --> countcolordots,[in],[column],columnid. 47 countquestion --> countcolordots,[in],[the],[world]. 48 countquestion --> countspaces,[in],[column],columnid. 49 countquestion --> countspaces,[in],[the],[world]. 50 51 52 contentquestion --> [is],[column],columnid,[empty]. 53 contentquestion --> [is],[column],columnid,[full]. 54 contentquestion --> [is],[the],[world],[empty]. 55 contentquestion --> [is],[the],[world],[full]. 56 57 58 displaycommand --> [list],[the],[dots]. 59 displaycommand --> [list],[the],color,[dots]. 60 displaycommand --> [list],[the],[dots],[in],[column],columnid. 61 displaycommand --> [list],[the],[dots],[on],[the],[table]. 62 displaycommand --> [list],[the],[dots],[off],[the],[table]. 63 64 65 addcommand --> [add],nsdot. 66 addcommand --> [add],csdot. 67 addcommand --> [add],nsdot,[to],[column],columnid. 68 addcommand --> [add],csdot,[to],[column],columnid. 69 addcommand --> [fill],[column],columnid. 70 addcommand --> [fill],[the],[world]. 71 addcommand --> [sprinkle],xdigit,[dots],[onto],[the],[world]. 72 73 74 deletecommand --> [remove],nsdot. 75 deletecommand --> [remove],nsdot,[from],[column],columnid. 76 deletecommand --> [clear],[the],[world]. 77 78 79 movecommand --> [move],nsdot,[from],[column],columnid,[to],[column],columnid. 80 81 82 countdots --> [how],[many],[dots]. 83 84 85 countcolordots --> [how],[many],color,[dots]. 86 87 88 countspaces --> [how],[many],[spaces],[available]. 89 90 91 nsdot --> [a],[dot]. 92 93 94 csdot --> detcolor,[dot]. 95 96 97 detcolor --> [an],[orange]. 98 detcolor --> [a],nonorange. 99 100 101 nonorange --> [blue]. 102 nonorange --> [yellow]. 103 nonorange --> [red]. 104 nonorange --> [green]. 105 nonorange --> [purple]. 106 107 108 color --> [orange]. 109 color --> [blue]. 110 color --> [yellow]. 111 color --> [red]. 112 color --> [green]. 113 color --> [purple]. 114 115 116 xdigit --> [two]. 117 xdigit --> [2]. 118 xdigit --> [three]. 119 xdigit --> [3]. 120 xdigit --> [four]. 121 xdigit --> [4]. 122 xdigit --> [five]. 123 xdigit --> [5]. 124 xdigit --> [six]. 125 xdigit --> [6]. 126 xdigit --> [seven]. 127 xdigit --> [7]. 128 xdigit --> [eight]. 129 xdigit --> [8]. 130 xdigit --> [nine]. 131 xdigit --> [9]. 132 133 134 columnid --> [one]. 135 columnid --> [1]. 136 columnid --> [two]. 137 columnid --> [2]. 138 columnid --> [three]. 139 columnid --> [3]. 140 columnid --> [four]. 141 columnid --> [4]. 142 columnid --> [five]. 143 columnid --> [5]. 144 columnid --> [six]. 145 columnid --> [6]. 146 columnid --> [seven]. 147 columnid --> [7]. 148 columnid --> [eight]. 149 columnid --> [8]. 150 151 152 % -------------------------------------------------------------------------- 153 % Recognizer -- and interface to the DCG! 154 recognizer :- 155 read_sentence(S), 156 sentence(S,[]), 157 recognizer. 158 recognizer :- 159 write('Error ...'),nl, 160 recognizer.