# Recent questions tagged lexical-analysis

1 vote
1
The output of lexical analyzer is: A set of regular expressions Strings of character Syntax tree Set of tokens
2
In a compiler, keywords of a language are recognized during parsing of the program the code generation the lexical analysis of the program dataflow analysis
1 vote
3
Consider the following statements related to compiler construction: Lexical Analysis is specified by context-free grammars and implemented by pushdown automata. Syntax Analysis is specified by regular expressions and implemented by finite-state machine. Which of the above statement(s) is/are correct? Only I Only II Both I and II Neither I nor II
4
Consult the language reference manuals to determine the sets of characters that form the input alphabet (excluding those that may only appear in character strings or comments), the lexical form of numerical constants, and the lexical form of identifiers, for each of the following languages: C C++ C# Fortran Java Lisp SQL
5
Tagged languages like HTML or XML are different from conventional programming languages in that the punctuation (tags) are either very numerous (as in HTML) or a user-definable set (as in XML). Further, tags can often have parameters. Suggest how to divide the ... you liked that one. <P> into appropriate lexemes. Which lexemes should get associated lexical values,and what should those values be?
6
Divide the following C + + program: float limitedSquare(x) float x { /* returns x-squared, but never more than 100 */ return (x<=-10.0 || x>=10.0)?100:x*x; } into appropriate lexemes, using the discussion of Section $3.1.2$ as a guide. Which lexemes should get associated lexical values? What should those values be?
7
The above diagram is Transition Diagrams for identifiers. As we can see that the identifier is said to be accepted if it starts with a letter and ends with a valid delimiter, which includes blank symbol, arithmetic, logical operator, left parenthesis, right parenthesis, +, ... ends with a delimiter and + is a valid delimiter and the error in declaration will not be detected at this stage...
1 vote
8
which one of the following string can definitely said to be a token without looking at the next input: +(++,+=) return(return a) *(*=) =(==) ++ , ( ) ‘ ; option e is: plusplus, comma, bracket open, bracket close, single quote ;
9
How many tokens in this a>>=1; and a! , Will >>= and a! be treated as a single token ?
10
In the Lexical Analysis, regular expression can be used to model A) the structures of lexemes with fixed length identifier excluded B) the structure of tokens C) the structure of tokens but not lexemes D) the structure of lexemes with variable length identifier included
11
I am getting 30 Answer given is 29
12
What it the number of tokens in the following line? printf("%d numbers.", &x);
1 vote
13
How will the compiler detect whether "if" is a keyword or an identifier? Please tell me the concept behind this.
14
Consider the following code $x = (y + 5) + (^*z) * 10 - x /3$ Which of the following correctly identified by lexical analysis after scanning the above code? 5 Identifiers 3 literals 4 Identifiers 6 literals
15
1 vote
16
Find no of tokens in below program. #include<stdio.h> main() { int I; int *pi = &I; //parent pointer scanf("%d",pi); printf("%d\n", I+5); }
17
18
19
20
1 vote
21
consider this c code: wheil(1){ printf("hi"); } will this code fragment gives lexical error or not. If not then who is responsible for this error.
22
A lexical analyzer uses the following patterns to recognize three tokens $T_1$, $T_2$, and $T_3$ over the alphabet $\{a, b, c\}$. $T_1$: $a?(b \mid c)^*a$ $T_2$: $b?(a \mid c)^*b$ $T_3$: $c?(b \mid a)^*c$ Note that x?' ... prefix. If the string $bbaacabc$ is processed by the analyzer, which one of the following is the sequence of tokens it outputs? $T_1T_2T_3$ $T_1T_1T_3$ $T_2T_1T_3$ $T_3T_3$
23
int main() { int 1a, b; Printf("\nGate 2018"); Printf("%d",x); } How many types of error are there in this code?
24
Is this line a/*b successfully generating the token's or it give lexical error ? if it is given the lexical error then why so ? I think it will give lexical error because we don't find */ here