I'm trying to match some sentences (e.g. 001 [0,0,1], (1+(1/0)) ['(',1,+,'(',1,/,0,')',')'], and so on.
I've made myself following small DCG.
g3 --> s3.
s3 --> e3.
e3 --> eAdd.
e3 --> eMin.
e3 --> eMul.
e3 --> eDiv.
e3 --> n3.
eAdd --> ['('],e3,['+'],e3,[')'].
eMin --> ['('],e3,['-'],e3,[')'].
eMul --> ['('],e3,['*'],e3,[')'].
eDiv --> ['('],e3,['/'],e3,[')'].
n3 --> d3.
n3 --> n3,d3.
d3 --> [0].
d3 --> [1].
Now my problem is, it won't match with sentences using -,* or / but it works for recursive sentences using only +.
E.g:
phrase(g3,['(',1,'+','(',1,'+',1,')',')']).
Will work, but
phrase(g3,['(',1,'+','(',1,'/',1,')',')']).
Won't work.
Any help would be appreciated, thanks!