Am 06.02.2011 12:10, schrieb Plastic:
For clarity: ABC#### is the format of the flight number. eg: AAL2123,
CAL2260, FDX1001, etc... Sometimes, there are three digit flights like
BAA418, etc...
I like the way you have the parser call a function to isolate each
component. I have until this point been thinking in terms of... (pseudo-code
alert!)
IF " c " INSTR(cmd$) then it's a clearance
and
is rightmost character x?Set expedited flag. if not,
a$ = (right 3 characters of cmd$) (eg: "030" or " 10") (*note to self - this
won't work for single digit altitudes - doh!*)
check it makes a number
is it a 3-digit number? (including 020 or 000) - it's a heading
otherwise, it's an altitude.
The other way I thought of doing it was parsing a character at a time and
using the spaces as "EOFs" for each field.
I am aware the decision tree for this "language" is straightforward.
However, to me, it's not "trivial" if only because I haven't coded at this
level in many years and this is truly stretching my mental muscles - which
is why I am doing this ;)
Dave,
anything using "INSTR" is probably a bad idea before actually having
separated the command line into tokens - It ignores the position of the
command and generates a lot of false positives - If you had a "C" in the
flight#, for example, you'd understand "Climb".....
About the 'language': Is this really a real life example? The
distinction between climbing and turning only done by the number of
digits in the value? Sounds a bit too much ambiguity for a high-security
approach to me. If the operator misses a single digit, he'd let the
plane turn instead of climb, with possibly fatal (lethal) results.
This also results in the fact that the decision tree for this language
is rather _not_ straightforward. Before having seen the #of digits in
the value, the language doesn't decide whether to climb or turn. (CS
theory would say "It's not a simple LR parser")
Cheers,
Tobias
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm