Hi guys I have the makings of a parser for a Theorem Prover. I have a module which previously tokenises the string so im inputting: [{bracket,open},{prop,a},{logicOp,'and'},{prop,b},{bracket,close}] to a parser which has an calls an inner function. here is the 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 the code on terminal like so and get 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}],
[])