We will define some
intelligent rules to handle all these conditions and return the crust and the size.
Time for Action: Writing Complex Grammars
1. Create a new grammar file called size_grammar.xml.
2. Let's start with pieces. Let's first write the grammar rule for size. The
following code shows this grammar.
- twelvereturn ("Medium")
- mediumreturn ("Medium")
- fourteenreturn ("Large")
- largereturn ("Large")
3. Let us add another rule for the crusts now.
- deepreturn ("Deep")
- thinreturn ("Thin")
4. It's now time to write our main rule, which will call these two rules. Make
sure to make it the root rule in the
tag.
assign(size $return)
- inch
Chapter 9
[ 175 ]
- and
assign(crust $return)
- crust
]]>
5.
Pages:
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235