Professional Documents
Culture Documents
Explain lex and yacc tools:Lex: - scanner that can identify those tokens
Yacc: - parser.yacc takes a concise description of a grammar and produces a C
routine that can parse that grammar.
12. Give the structure of the lex program:Definition section- any intitial c program code
%%
Rules section- pattern and action separated by white space
%%
User subroutines section-concsit of any legal code.
13. The lexer produced by lex in a c routine is called yylex()
14. Explain yytext:- contains the text that matched the pattern.
15. The yacc produced by parser is called yyparse().
16. Why we have to include y.tab.h in lex?
Y.tab.h contains token definitions eg:- #define letter 258.
17. Explain the structure of a yacc program?
Defn section- declarations of the tokens used in the grammar
%%
The rules section-pattern action
%%
Users subroutines section
18. Explain yyleng?
Yyleng-contains the length of the string our lexer recognizes.
19. Define action?
The C code associated with a lex pattern or a yacc rule. When the pattern
or rule matches an input sequence, the action code is executed.
20. Define Pattern?
In a lex lexer, a regular expression that the lexer matches against the input.
21. What is an Alphabet?
A set of distinct symbols .For example, the ASCII character set is a
collection of 128 different symbols. In a lex specification, the alphabet is the
native character set of the computer, unless you use %T to define a custom
alphabet.
22. Define ASCII?
American Standard Code for Information Interchange, a collection of 128
symbols representing the common symbols found in the American alphabet:
lower and upper case letters, digits and punctuation, plus additional characters
for formatting and control of data communication links.