Question: private void parseImages ( Scene scene, Token imageToken ) throws LexicalError, SyntaxError, IOException { int height, width, offset, radius, sides; verifyNextToken ( Token . COLOR
private void parseImagesScene scene, Token imageToken throws LexicalError, SyntaxError, IOException
int height, width, offset, radius, sides;
verifyNextTokenTokenCOLOR;
int colors getNumberList; Getting RGB values
Color color new Colorcolors colors colors;
verifyNextTokenTokenAT;
int location getNumberList; Getting X and Y coordinates
Point point new Pointlocation location;
if imageToken Token.RIGHTTRIANGLE
verifyNextTokenTokenHEIGHT;
verifyNextTokenTokenNUMBER;
height lexer.getNumber;
verifyNextTokenTokenWIDTH;
verifyNextTokenTokenNUMBER;
width lexer.getNumber;
RightTriangle triangle new RightTrianglecolor point, height, width;
scene.addImagetriangle;
else if imageToken Token.RECTANGLE
verifyNextTokenTokenHEIGHT;
verifyNextTokenTokenNUMBER;
height lexer.getNumber;
verifyNextTokenTokenWIDTH;
verifyNextTokenTokenNUMBER;
width lexer.getNumber;
Rectangle rectangle new Rectanglecolor point, height, width;
scene.addImagerectangle;
else if imageToken Token.PARALLELOGRAM
verifyNextTokenTokenHEIGHT;
verifyNextTokenTokenNUMBER;
height lexer.getNumber;
verifyNextTokenTokenWIDTH;
verifyNextTokenTokenNUMBER;
width lexer.getNumber;
verifyNextTokenTokenOFFSET;
verifyNextTokenTokenNUMBER;
offset lexer.getNumber;
Parallelogram parallelogram new Parallelogramcolor point, height, width, offset;
scene.addImageparallelogram;
else if imageToken Token.REGULARPOLYGON
verifyNextTokenTokenSIDES;
verifyNextTokenTokenNUMBER;
sides lexer.getNumber;
verifyNextTokenTokenRADIUS;
verifyNextTokenTokenNUMBER;
radius lexer.getNumber;
RegularPolygon polygon new RegularPolygoncolor sides, point, radius;
scene.addImagepolygon;
else if imageToken Token.ISOSCELES
verifyNextTokenTokenHEIGHT;
verifyNextTokenTokenNUMBER;
height lexer.getNumber;
verifyNextTokenTokenWIDTH;
verifyNextTokenTokenNUMBER;
width lexer.getNumber;
IsoscelesTriangle isosceles new IsoscelesTrianglecolor point, height, width;
scene.addImageisosceles;
else if imageToken Token.TEXT
Fix: Ensure STRING is correctly handled
verifyNextTokenTokenSTRING; Expecting a STRING token
String text lexer.getLexeme; Get the text from the lexer
if text null text.isEmpty
throw new SyntaxErrorlexergetLineNo "Expected a valid text string, but found none.";
Text textImage new Textnew Color new Point text;
scene.addImagetextImage;
else
throw new SyntaxErrorlexergetLineNo "Unexpected image name imageToken;
Verify the semicolon and continue parsing the next image
verifyNextTokenTokenSEMICOLON;
token lexer.getNextToken;
if token Token.END
parseImagesscene token;
Scene Polygons
RightTriangle Color at Height Width ;
Rectangle Color at Height Width ;
Isosceles Color at Height Width ;
Parallelogram Color at Height Width Offset ;
RegularPolygon Color at Sides Radius ;
Text Color at Hello World";
End;
I keep getting an error for line it is expecting a string not EOF but there is a string there could you help me
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
