Advertisement
logicmoo

Untitled

Jul 24th, 2015
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. % BNF description include operator <term>+ TO mark zero OR more replacements.
  3. % This DCG extension TO overcome this.
  4. oneOrMore(W, [R|Rs], A, C) :- call(W, R, A, B),  (
  5.                                                          oneOrMore(W, Rs, B, C)
  6.                                                          ;
  7.                                                          (Rs = [] , C = B)
  8.                                                      ).
  9. % BNF operator <term>*
  10. zeroOrMore(W, R)                --> oneOrMore(W, R).
  11. zeroOrMore(_, [])               --> [].
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement