Parsing numbers with multiple digits in Prolog

后端 未结 3 884
北荒
北荒 2021-01-11 14:41

I have the following simple expression parser:

expr(+(T,E))-->term(T),\"+\",expr(E).
expr(T)-->term(T).

term(*(F,T))-->factor(F),\"*\",term(T).
ter         


        
3条回答
  •  抹茶落季
    2021-01-11 15:36

    nat(0). 
    nat(N):-nat(N-1).
    

    But you use a syntax that I don't know (see my comment above).

提交回复
热议问题