MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

COMPILER DESIGN

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
The output of scanner is
A
a stream of lexemes
B
a stream of tokens
C
an annotated parse tree
D
a three address code
Explanation: 

Detailed explanation-1: -The tokens() method of Java Scanner class is used to get a stream of delimiter-separated tokens from the Scanner object which are in using. This method might block waiting for more input.

Detailed explanation-2: -public Scanner(InputStream source) Constructs a new Scanner that produces values scanned from the specified input stream. Bytes from the stream are converted into characters using the underlying platform’s default charset. Example: The method input on this constructor is InputStream.

Detailed explanation-3: -A scanner is a language processor component that transforms an input program, P, from a sequence of characters into a sequence of tokens. If illegal tokens are encountered, an exception is thrown. There are programs such as Lex that can generate scanners from regular expressions.

There is 1 question to complete.