B*M 发帖数: 1340 | 1 Write a code to indent a block of code (something which is done by IDEs such as visual studio) .I was given a few programming constructs such as if else , for construct and a funciton block. Special cases to handle : nested if
glassdoor上看到的,
这题好像不大清楚,设定不同,难易差别也挺大,
哪位大侠见过这题,给说说,多谢! | m********l 发帖数: 4394 | 2 Epic asks that?
It's a basic compiler problem, solved by using a stack.
When a token matches a keyword, you push the keyword to the stack and
indent the following codes. Same thing with ending keyword, you pop the
stack and move the code back.
I don't think you can write a complete program within limited time. (e.g.
the parser, etc.)
such as visual studio) .I was given a few programming constructs such as
if else , for construct and a funciton block. Special cases to handle :
nested if
【在 B*M 的大作中提到】 : Write a code to indent a block of code (something which is done by IDEs such as visual studio) .I was given a few programming constructs such as if else , for construct and a funciton block. Special cases to handle : nested if : glassdoor上看到的, : 这题好像不大清楚,设定不同,难易差别也挺大, : 哪位大侠见过这题,给说说,多谢!
| B*M 发帖数: 1340 | 3 多谢回复,
我也觉得这题当真要搞的话很繁琐,
解析token就不容易,
【在 m********l 的大作中提到】 : Epic asks that? : It's a basic compiler problem, solved by using a stack. : When a token matches a keyword, you push the keyword to the stack and : indent the following codes. Same thing with ending keyword, you pop the : stack and move the code back. : I don't think you can write a complete program within limited time. (e.g. : the parser, etc.) : : such as visual studio) .I was given a few programming constructs such as : if else , for construct and a funciton block. Special cases to handle :
|
|