<<

Compile and Runtime Errors in

Jayashree. G1, Suseela. S2, Arisha. S3, Vinitha. K4 1,3Third year students, 2,4Assistant professors, Dept. of CSE

Periyar Maniammai Institute of Science and Technology, Vallam, Thanjavur, Tamil Nadu, India.

ABSTRACT

I. INTRODUCTION Compiler and its error are the two fundamentals which bridges the gap Mostly computer professionals won’t write between a programmer and the machine any compiler. Instead, a compiler to work well on C. In this paper, we translates (or compiles) a program written have shown about compiler and its in a high-level that error messages. We have also discussed is suitable for human programmers into the about many recovery mechanisms in a low-level machine language that is compiler. As programming languages required by computers. So simply, acts like an interface between a compiler is a program that is designed to programmer and the machine, it should convert human readable higher-level not be subjected to any error. If it programming language into machine supposed to possess error, then the code language, or . When these will not attain efficiency, meaning and programs are converted from one form to quality. So some means of gap has to be another the compiler may face some error. bridged between the machine and to the Compilation error refers to a stage where a user. This is where a compiler comes in. compiler fails to perform compilation Here the task of a compiler is to compile either due to errors in the code or, due to the program or instruction which is errors in the compiler itself. An error written in a particular source language message often helps programmers to and convert it into a target language via debug source code. Different types of various phases available in the compiler. errors are analysed and reported to the Meanwhile, the tasks of error handling user. The main requirement for the process are to detect each error, report compiler is to stop and report a message, it to the user, and possibly make some and cease compilation. There are some repair to allow processing to continue. common recovery methods: Finally, the purpose of this paper is to provide an entire knowledge about the 1. Panic mode recovery: Basically, it Compiler and its error briefly. prevents the parser from developing infinite loops while recovering error and Keywords: ; Errors; Target this is the easiest way of error recovery. language. The parser discards the input symbol one at a time until one of the designated (like end, semicolon) set of synchronizing

© 2020, IRJET Volume: 01 Issue: 02 | ww.irjweb.com October 2020 Page 110-117 tokens is found. This is enough when the statement is rare. presence of multiple errors in same For example: Consider the erroneous expression- (1 + + 7) + 4. Panic mode recovery method will skip ahead to next integer and then continues. Source Code 2. E->int|E+E|(E)|error int|(error)

3. Phrase level recovery: Error correction is a tedious process in this strategy. But, it performs local correction on the input to Lexical Analyzer repair the error.

Example: Performs local correction by Syntax Analyzer inserting a semicolon. 4. Error productions: There are some Semantic Analyzer common errors known to the compiler designers that may occur in the code. Symbol Error Intermediate Augmented grammars can also be used, as Table Handler productions that generate erroneous Code Generator constructs when these errors are encountered. Machine Example: write 2x instead of 2*x. Independent Code Optimiser

5. Global correction: The objective of global correction is to make as few Code Generator changes as possible while converting an incorrect input string to a valid string. This strategy costs more to implement. Machine Dependent Code Optimiser Example: When an erroneous input statement A is fed, it creates a parse tree for some closest error-free statement B. Target

Code

Figure 1. Phases of Compiler

Each phase in a compiler (Figure 1) may face error are shown below:

Lexical analyzer: Tokens are spelled wrongly.

Syntax analyzer: Missing parenthesis, comma etc.

© 2020, IRJET Volume: 01 Issue: 02 | ww.irjweb.com October 2020 Page 110-117

Intermediate code generator: 1. Lexical: It is a sequence of characters Mismatched operands for an operator. that does not match the pattern of any Code Optimizer: When the statement is token not reachable. Example: Misspellings of identifiers, Code Generator: Unreachable statements. keywords or operators are included in this category. Next in Section II. various types of errors are revised. Then in section III, analysis of 2. Syntactical: Wrong syntax usage will error is discussed. In section IV, Many real cause this kind of error to occur. During time applications of compiler technology this error will occur. have been revised; summarization of this Example: Omitting the required paper is being portrayed in section V. semicolon, using an undeclared variable. Finally the last section VI. of this paper includes references from which this paper 3. Semantical: If the meaning of any is being written. natural language is gets mismatched then this error may occur. II. TYPES OF ERROR Example: Incompatible value assignment This paper portraits a clear view about the or type mismatches between operator and architecture of types of error in a C operand. Compiler via error handling mechanism. It is a process which is used to determine 4. Logical: infinite loop, code not each error, report it to the user and then the reachable. process make some recover strategy and implement them to handle error. Major Example: Division by zero. types of error: run-time and error: Due to invalid input data or adverse input III. ERROR ANALYSIS parameters, the error which takes place Error: Unable during the execution of a program is run to open include time error. So the executed code does not file. produce the desired result. This problem Example: The lack of sufficient memory occurs due to to run an application or a memory conflict wrong with another program and logical error. configuration in Turbo C++ An error that occurs during compile time is directories. called compile time error and it happens before the execution of the program. Example: Syntax error or missing file reference that prevents the program from successfully compiling. Compile-time errors:

© 2020, IRJET Volume: 01 Issue: 02 | ww.irjweb.com October 2020 Page 110-117

Error: Illegal Error: Too few character. parameters in call to ‘ ’. This error occurs If very few when there is an parameters are invalid or created unexpected regardless of the token that declared doesn't belong at variable then this position in this error occurs. the code. Error: Unterminated Error: string or Declaration is character not allowed constant. here.

The compiler This kind of found no error occur when terminating the declaration is quote after the done after the beginning of a call to clrscr() is string or made. character Error: constant. Undefined Error: symbol. Statement The link-editor missing. searches the If any semicolon internal symbol is missed at the table for any end of the line symbol then the error references that prevails. have not been bound to symbol definitions. Error: No file name ending. The file name in a #include state ment was missing the correct closing quote or angle bracket.

© 2020, IRJET Volume: 01 Issue: 02 | ww.irjweb.com October 2020 Page 110-117

Error: Error: Declaration Character terminated constant must be incorrectly. one or two characters long. When the main function is Inside the called an apostrophes, additional none of the semicolon paves character is the way for an available. error to occur. Error: Void Error: functions may Declaration not return a syntax error. value. When a function At the end of has arguments, it variable receives any declaration, a data from the semicolon is calling function missed . but it returns no Error: values. Expression syntax.

If an error Error: occurs in a Compound syntax statement containing missing. tokens or If the statements characters, then are not enclosed it is syntax error. with the braces then the compound Error: statement Function call missing error missing. occurs.

If the function is not been properly called then the function call is missed.

© 2020, IRJET Volume: 01 Issue: 02 | ww.irjweb.com October 2020 Page 110-117

Error: Warning: ‘ ’ Unknown pre- is assigned a processor value that is directive: never used. ‘iclude’. It is not an error, The compiler is just #include directiv advising you e cannot insert that you have a the contents of variable the specified file declared into the current and assigned to file. a value, apparently.

Error: Illegal initialization. Warning: All objects with Code has no static storage effect. duration must be Code that has no initialized before effect is execution of typically the main() starts. So result of a a value which is coding error and not known at can cause translation time unexpected cannot be used behaviour. for initialization Warning: of static Non portable variables. pointer Error: Type conversion. mismatch in re declaration of ‘’ The value in the . pointer variable In this code, the is automatically function converted as definition is not address of the in match with pointer. function declaration. Thus raises an error “Type mismatch in function re- declaration”.

© 2020, IRJET Volume: 01 Issue: 02 | ww.irjweb.com October 2020 Page 110-117

Linker It delivers optimized computer Error: architecture. Undefined symbol ‘ ’ in This implements new software module productivity tools. POINTER.C The code Lexical analyser techniques are compiles fine, used in ordinary text editors, but that some pattern recognition programs etc. function or that is Most of the techniques used in needed cannot compiler design are implemented in Natural Language Processing be found. (NLP) systems. Error: Value required.

This error occurs V. CONCLUSION when the statements Finally the purpose of this paper is to written in the give a clear basic idea about the program are not compiler, compiler error and error meaningful to types along with its recovery the compiler. mechanisms. In this, Compiler plays a major part which acts as an interface in Warning: converting one language into another Possibly language. It also includes classification incorrect of errors which makes the new assignment. programmers to understand the concept When the well .This again depicts the recovery compiler mechanisms to prevent the occurrence encounters an of error .Also this compiler technology assignment has other important uses as well. It operator as the works better for implementing high - main operator of level programming, Optimizing and a conditional designing of computer architectures, expression (part Software productivity tools like type of an if, while, and bounce checking .Meanwhile, or do-while widely it is known for program statement). translations .Thus the main motive of this paper is to give a basic knowledge IV. APPLICATIONS OF COMPILER about the compiler and its error TECHNOLOGY. mechanisms to recover the error that

has been occurred while coding . Compiler is used to convert a particular language into a target VI. REFERENCES language. So this implements high level programming language. [1]. H. C. A. V. Jatin Chhabra, "Research paper on Compiler Design," International Journal of Innovative

© 2020, IRJET Volume: 01 Issue: 02 | ww.irjweb.com October 2020 Page 110-117

Research in Technology, vol. 5, no. January 2019, pp. 1-2, 2014.

[2]. M. Rouse, "SearchSoftwareQuality," 2007. [Online]. Available: https://searchsoftwarequality.techtarget .co m/definition/errorhandling. [Accessed 08 January 2019]. [3]. P. Agrawal, "geeksforgeeks," [Online]. Available: https://www.geeksforgeeks.org/errorha ndling-compiler-design/. [Accessed 08 January 2019]. [4]. K. C. Louden, Compiler Construction: Principles and Practice, 1997. [5]. Aho, Alfred V. and Johnson, Stephen C. [1976]. Optimal code generation for expression trees. Journal of the ACM, 23(3):488501. [6]. Ross, D. T. [1967]. The AED free storage package. Communications of the ACM, 10(8):481492 [7]. Azevedo A Issenin I, Cornea R, Gupta R, Dutt N, Veidenbaum A, Nicolau A dynamic voltage scheduling using program Design automation and test in Europe 2005. [8].https://www.includehelp.com/c/too- few-arguments-to-function-c-language- error.aspx [9]. Aho, Alfred V., Hop croft, J. E., and Ullman, Jeffrey D. [1974]. The Design and Analysis of Computer Algorithms.Addision Wesley, Reading, MA. [10]. William M. WaiteDepartment of Electrical EngineeringUniversity of ColoradoBoulder, Colorado 80309USAemail: [email protected]

© 2020, IRJET Volume: 01 Issue: 02 | ww.irjweb.com October 2020 Page 110-117