The first few steps
The first few steps of compilation like lexical, syntax and semantic analysis can be understood by drawing analogies to the human way of comprehending a natural language.
The first step in understanding a natural language will be to recognize characters, i.e. the upper and lower case alphabets, punctuation marks, alphabets, digits, white spaces etc. Similarly the compiler has to recognize the characters used in a programming language.
The next step will be to recognize the words which come from a dictionary. Similarly the programming language have a dictionary as well as rules to construct words (numbers, identifiers etc).
. The first step is recognizing/knowing alphabets of a language. For example
- English text consists of lower and upper case alphabets, digits, punctuations and white spaces
- Written programs consist of characters from the ASCII characters set (normally 9-13, 32-126)
. The next step to understand the sentence is recognizing words (lexical analysis)
- English language words can be found in dictionaries
- Programming languages have a dictionary (keywords etc.) and rules for constructing words (identifiers, numbers etc.)
|