* * Checks to see whether a Prolog predicate meets the restrictions for append.pl * on 372.s18/a9: Only append and length can be used. [E1,E2,...EN] is allowed * but the cons notation, [H|T], is not allowed. * * Assumes predicates are on one line. Handles blanks by stripping them as a first * step. * * Written Sunday, 04/29/18 * ldu = (span(&lcase &ucase &digits '_') | null) atom = any(&lcase) ldu variable = any(&ucase '_') ldu term = variable | atom | span(&digits) | '[' (*terms | null) ']' terms = term | *terms (',' term) pred = ('append' | 'length') '(' terms ')' preds = pred | *preds (',' pred) head = atom '(' terms ')' rule = head ':-' preds '.' loop line = input :f(end) stripblanks line ' ' = :s(stripblanks) eq(size(line),0) :s(loop) line pos(0) rule rpos(0) :f(error) output = "OK: " line :(loop) error output = "***** Error: " line :(loop) end