console-based, non GUI
I need to match brackets ( [,{,and ('s ) in a string bordered by quotation marks. I tokenized the stream into a simgle string minus the quation marks and used a stack implemented by a linked list to check for matching brackets. Now I need to use recursion to do the same thing. the problem is, the input file has two lines:
"[abc(a) {bak} ]"
"jus{go(sd[sn] ) ah }"
the first line is to be checked by the stack, the second is to be checked by recursion. I have almost everything done for the stack part (minus the final test where i check if the stack is empty) but I have no clue how to test a second line using a totally different method!
All this code has to be in the same file called ParenthesisMatch.java which makes it even harded, IMO.
here's how it works:
[ [ ( ) ] ] would return "good"
[ [ ( ] ) ] would return "bad" because of nesting
[ [ ] would return "bad" because too many opening (same wiht closing)
here's my code if anyone has any idea how I can add recursion to do another line in the input file:
I need to match brackets ( [,{,and ('s ) in a string bordered by quotation marks. I tokenized the stream into a simgle string minus the quation marks and used a stack implemented by a linked list to check for matching brackets. Now I need to use recursion to do the same thing. the problem is, the input file has two lines:
"[abc(a) {bak} ]"
"jus{go(sd[sn] ) ah }"
the first line is to be checked by the stack, the second is to be checked by recursion. I have almost everything done for the stack part (minus the final test where i check if the stack is empty) but I have no clue how to test a second line using a totally different method!
All this code has to be in the same file called ParenthesisMatch.java which makes it even harded, IMO.
here's how it works:
[ [ ( ) ] ] would return "good"
[ [ ( ] ) ] would return "bad" because of nesting
[ [ ] would return "bad" because too many opening (same wiht closing)
here's my code if anyone has any idea how I can add recursion to do another line in the input file: