HI everyone,
Sorry for the delayed reply; I've been super busy. I am close to getting it working, but I am running into some Problems. I am including the grammar for this project:
gui ::=
Window STRING '(' NUMBER ',' NUMBER ')' layout widgets End '.'
layout ::=
Layout layout_type ':'
layout_type ::=
Flow |
Grid '(' NUMBER ',' NUMBER [',' NUMBER ',' NUMBER] ')'
widgets ::=
widget widgets |
widget
widget ::=
Button STRING ';' |
Group radio_buttons End ';' |
Label STRING ';' |
Panel layout widgets End ';' |
Textfield NUMBER ';'
radio_buttons ::=
radio_button radio_buttons |
radio_button
radio_button ::=
Radio STRING ';'
In the above grammar, the red symbols are nonterminals, the blue symbols are tokens and the black punctuation symbols are BNF metasymbols. Among the tokens those in title case are keywords. The character literals are punctuation tokens.
Below is an explanation of the meaning of some of the symbols in the above productions that should help you understand the actions that are to be performed when each of the productions is parsed:
• In the window production the string is name that is to appear in the top border of the window and the two numbers are the width and height of the window
• In the production for layout_type that define the grid layout, the first two numbers represent the number of rows and columns, and the optional next two the horizontal and vertical gaps
• In the production for widget that defines a button, the string is the name of the button
• In the production for widget that defines a label, the string is text that is to be placed in the label
• In the production for widget that defines a text field, the number is the width of the text field
• In the production for radio_button, the string is the label of the button
This is the code provided by the professor
And this is the parser I built:
Sorry for the length of the file, I just want to give everyone a feel of what I have and the scope of the project. Right now, one problem I know I am having is that my Parser is not properly handling nested Panels.
Placing the below text into a text file:
Window "Testing" (600, 500) Layout Flow:
Button "Test1";
Textfield 20;
Label "Something";
Group
Radio "A";
Radio "B";
Radio "C";
Radio "D";
Radio "E";
Radio "F";
End;
Panel Layout Grid(4, 3, 5, 5):
Button "7";
Button "8";
Button "9";
Button "4";
Button "5";
Button "6";
Button "1";
Button "2";
Button "3";
Label "";
Button "0";
End;
Panel Layout Flow:
Group
Radio "z";
Radio "x";
Radio "y";
Radio "v";
End;
Panel Layout Grid(3, 3):
Button "X";
Button "O";
Button "X";
Button "O";
Button "X";
Button "O";
Button "X";
Button "O";
Button "X";
End;
End;
End.
Should produce the following image:
Instead it produces this:
Any suggestions on what might be the source of the problem?
Thanks!