GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Compiler Design

Raj is a newbie to the programming and while learning the programming language he came to know the following rules: • Each program must start with '{' and end with '}'. • Each program must contain only one main function. Main function must start with '<' and end with '>'. • A program may or may not contain user defined function(s). There is no limitation on the number of user defined functions in the program. User defined function must start with '(' and end with ')'. • Loops are allowed only inside the functions (this function can be either main function or user defined function(s)). Every loop must start with '{' and end with '}'. • User defined function(s) are not allowed to be defined inside main function or other user defined function(s). • Nested loops are allowed. • Instructions can be anywhere inside the program. • Number of instructions inside any user defined function must not be more than 100. If any of the above conditions is not satisfied, then the program will generate compilation errors. Today Raj has written a few programs, but he is not sure about the correctness of the programs. Your task is to help him to find out whether his program will compile without any errors or not. Input Format: First line starts with T, number of test cases. Each test case will contain a single line L, where L is a program written by Raj. Output Format: Print "No Compilation Errors" if there are no compilation errors, else print "Compilation Errors". Constraints: 1<=T<=100 L is a text and can be composed of any of the characters {, }, (, ), <, >and P, where P will represents the instruction. L, comprised of characters mentioned above should be single spaced delimited. Number of characters in the text, |L| < = 10000 Input 3 { <> ( P ) } { < { } > ( { } ) ) { ( { } ) } Output No Compilation Errors Compilation Errors Compilation Errors

asked Aug 3, 2015 by anonymous
...