parsing - Erlang ** exception error: no function clause matching -


hi guys have makings of parser theorem prover. have module tokenises string im inputting: [{bracket,open},{prop,a},{logicop,'and'},{prop,b},{bracket,close}] parser has calls inner function. here code:

parse([])-> []; parse(fulllist) ->     parseclauses(fulllist,[],[]).   parseclauses([{bracket, open}| restoflist], stacklist, parsedlist) ->     parseclauses(restoflist,              stacklist ++ [{bracket, open}],                  parsedlist);  parseclauses([{prop, any},{logicop, any}| restoflist], stacklist, parsedlist) ->     parseclauses(restoflist,               stacklist ++ [{logicop, any},{prop, any}],                  parsedlist);  parseclauses([{bracket, close}, {logicop, any}| restoflist],stacklist,parsedlist) ->     parseclauses(restoflist,               stacklist ++ [{bracket, close}],                  [{logicop, any}] ++ parsedlist);  parseclauses([{bracket, close}|restoflist], stacklist, parsedlist) ->     parseclauses(restoflist,                     stacklist++[{bracket, close}],                         parsedlist);  parseclauses([], stack, parsed) ->  parsed ++ stack. 

run code on terminal , error:

tokeniser:parse([{bracket,open},     {prop,a},     {logicop,'and'},     {prop,b},     {bracket,close}]). ** exception error: no function clause matching tokeniser:parseclauses([{prop,a},{logicop,'and'},{prop,b},{bracket,close}],                                        [{bracket,open}],                                        []) 

from error message, can tell function being called this:

tokeniser:parseclauses([{prop,a},{logicop,'and'},{prop,b},{bracket,close}],                                        [{bracket,open}],                                        []) 

this almost matches clause:

parseclauses([{prop, any},{logicop, any}| restoflist], stacklist, parsedlist) -> 

but since any used twice in argument list, clause matches when 2 values same. in call, different: a , 'and'.

you change 2 occurences of any else, e.g. prop , logicop, , clause accept 2 different values.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -