Recent questions tagged lexical-analysis

1 vote
5 answers
1
The output of lexical analyzer is: A set of regular expressions Strings of character Syntax tree Set of tokens
0 votes
5 answers
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
5 answers
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
0 votes
0 answers
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
0 votes
0 answers
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?
0 votes
0 answers
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?
3 votes
1 answer
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
2 answers
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 ;
2 votes
4 answers
9
How many tokens in this a>>=1; and a! , Will >>= and a! be treated as a single token ?
3 votes
2 answers
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
4 votes
2 answers
11
I am getting 30 Answer given is 29
2 votes
5 answers
12
What it the number of tokens in the following line? printf("%d numbers.", &x);
1 vote
2 answers
13
How will the compiler detect whether "if" is a keyword or an identifier? Please tell me the concept behind this.
6 votes
1 answer
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
5 votes
4 answers
15
1 vote
1 answer
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); }
6 votes
5 answers
17
0 votes
0 answers
18
3 votes
0 answers
19
0 votes
0 answers
20
1 vote
2 answers
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.
30 votes
7 answers
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$
10 votes
5 answers
23
int main() { int 1a, b; Printf("\nGate 2018"); Printf("%d",x); } How many types of error are there in this code?
6 votes
1 answer
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
2 votes
2 answers
25
What are different set of characters which are taken as single token in lexical analysis in compiler design? For eg. Charaters under double quotes are taken as single token, post-increment and pre-increment is taken as single token etc.
1 vote
1 answer
26
in c programming which of the following is not used as a token seprator during lexical analysis? a)white space b)comment c)semicolon d)none of these token seprator means??
6 votes
5 answers
27
if there is miss spelling in some keyword in a program then this misspelled keyword will be treated as lexical errors or it will be treated as a new identifier and accepted as a token ?? ex - whiel (1) ; here while is misspelled as whiel