Hi, I'm having a major problem with an algorithm for Java. I am building a program that recursively parses a simple programming language that follows obvious production grammars. My main issue is nesting. For instance, the pattern might be something like this:
Create Jpanel1:{
Create JButton1
Create JPanel2:{
Create JButton2
Create JButton3
}
Create JTextField1
Create JPanel3:{
Create JPanel4:{
Create JButton4
}
}
}
By now you've probably got an idea of what I'm talking about. In order to add JButton1 to JPanel1 I have to teach JButton1 who it's parent is (JPanel1 of course). You'll also notice that JButton1 is a terminal node and that the recursion comes from the existence of these other JPanel nodes that then lead to some terminal node. In any case, every one of these guy's must know who it's immediate parent is so it can be added to it's parent with the GUI's add(element) method.