Working on the parser for my interpreter, and with a lot of help I've come up with this idea on how to do it:
1. Split the source string into 2 parts with String.split(); get an array parts[] with two elements at [0] and [1].
2. If parts.length==1 then call directive.execute(); else if parts.length>1, String input=parts.[1]; call directive.execute(input)
The String input gets sent on to the appropriate class for tokenizing and handling. Now all the classes should be using directive.execute(input) except for one class (EndStatement), where input will be null and it only calls directive.execute(). I know I'm supposed to override or overload the method declared in my interface to do that, but I'm not sure how and reading up on the subject hasn't really helped me get my head around it either. Could someone help get me on track? Thanks!
Code for interface method and example classes
Code for parsing loop
1. Split the source string into 2 parts with String.split(); get an array parts[] with two elements at [0] and [1].
2. If parts.length==1 then call directive.execute(); else if parts.length>1, String input=parts.[1]; call directive.execute(input)
The String input gets sent on to the appropriate class for tokenizing and handling. Now all the classes should be using directive.execute(input) except for one class (EndStatement), where input will be null and it only calls directive.execute(). I know I'm supposed to override or overload the method declared in my interface to do that, but I'm not sure how and reading up on the subject hasn't really helped me get my head around it either. Could someone help get me on track? Thanks!
Code for interface method and example classes
Code for parsing loop