PROLOG - DCG parsing

Posted by user2895589 on Stack Overflow See other posts from Stack Overflow or by user2895589
Published on 2013-10-19T04:32:31Z Indexed on 2013/10/19 9:54 UTC
Read the original article Hit count: 190

Filed under:

Hello I am new Prolog and DGC.I want to write a DCG to parse time expressions like 10.20 am or 12 oclock. how can I check 10.20 am is valid expression or not for Olcock I wrote some code.

oclock --> digit1,phrase1.

digit1 --> [T],{digit1(T)}.
digit1(1).
digit1(2).
digit1(3).
digit1(4).
digit1(5).
digit1(6).
digit1(7).
digit1(8).
digit1(9).
digit1(10).
digit1(11).
digit1(12).

phrase1 --> [P],{phrase1(P)}.
phrase1(Oclock).

i ma checking by query

oclock([1,oclock],[]).

can someone help me on this.

© Stack Overflow or respective owner

Related posts about prolog