Determine the current I0 in the steadystate AC circuit shown
Solution
The scanner performs lexical analysis of a precise program (in our case, the straightforward program). It reads the computer program as a sequence of characters and acknowledges \"larger\" matter units known as tokens. for instance, if the supply programs contains the characters
VAR ics142: INTEGER; // variable declaration
the scanner would manufacture the tokens
VAR ID(ics142) COLON ID(INTEGER) punctuation
to be processed in later phases of the compiler. Note that the scanner discards white house and comments between the tokens, i.e. they\'re \"filtered\" and not passed on to later phases. samples of nontokens ar tabs, line feeds, carriage returns, etc.
How to use FLEX?
FLEX (Fast LEXical instrument generator) may be a tool for generating scanners. In office of writing a scanner from scratch, you merely ought to establish the vocabulary of a precise language (e.g. Simple), write a specification of patterns mistreatment regular expressions (e.g. DIGIT [0-9]), and FLEX can construct a scanner for you. FLEX is mostly utilized in the way represented here:
First, FLEX reads a specification of a scanner either from associate degree computer file *.lex, or from commonplace input, and it generates as output a C supply file lex.yy.c. Then, lex.yy.c is compiled associate degreed connected with the \"-lfl\" library to provide an workable a.out. Finally, a.out analyzes its input stream and transforms it into a sequence of tokens.
