6. Input 1 * The usual hello world program, but without * #include because the preprocessor * is optional (see part 2). 2 3 4 * */ 7 8 int main() 9 { return printf("Hello, world!\n"); 10 11 } 6.2 Output for mycc -1 hello.c

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

Use C language ro read from file like hello.c and comile them into the format, the token number can find from image two

Image 1. 

6.1
Input
1 /*
* The usual hello world program, but without
* #include <stdio.h> because the preprocessor
* is optional (see part 2).
2
3
4
5
6
*/
8 int main()
9 {
return printf ( "Hello, world!\n");
11 }
10
6.2
Output for mycc -1 hello.c
4
File hello.c Line
8 Token 301 Text int
8 Token 306 Text main
40 Тext (
File hello.c Line
File hello.c Line
File hello.c Line
File hello.c Line
File hello.c Line
File hello.c Line
File hello.c Line
File hello.c Line
File hello.c Line
File hello.c Line
File hello.c Line
8 Token
8 Token
41 Тext )
9 Token 123 Text {
10 Token 410 Text return
10 Token 306 Text printf
40 Тext (
10 Token
10 Token 305 Text "Hello, world!\n"
41 Тext )
10 Token
10 Token
59 Text ;
11 Token 125 Теxt }
Transcribed Image Text:6.1 Input 1 /* * The usual hello world program, but without * #include <stdio.h> because the preprocessor * is optional (see part 2). 2 3 4 5 6 */ 8 int main() 9 { return printf ( "Hello, world!\n"); 11 } 10 6.2 Output for mycc -1 hello.c 4 File hello.c Line 8 Token 301 Text int 8 Token 306 Text main 40 Тext ( File hello.c Line File hello.c Line File hello.c Line File hello.c Line File hello.c Line File hello.c Line File hello.c Line File hello.c Line File hello.c Line File hello.c Line File hello.c Line 8 Token 8 Token 41 Тext ) 9 Token 123 Text { 10 Token 410 Text return 10 Token 306 Text printf 40 Тext ( 10 Token 10 Token 305 Text "Hello, world!\n" 41 Тext ) 10 Token 10 Token 59 Text ; 11 Token 125 Теxt }
Value Lexeme
Value Lexeme
Value Lexeme
37 %
41 )
33
!
38 &
40
42
*
43
+
44
45
46
47
58
59
60
61
63
123 {
62
?
91
93 )
125 }
124 I
Operators with two characters
Value Lexeme
Value Lexeme
Value Lexeme
351
352
!=
353
>=
==
354
<=
355
++
356
--
357 ||
358
&&
361
+=
362
363
364
Keywords
Value Lexeme
401 const
Value Lexeme
402 struct
Value Lexeme
403 for
404 while
405 do
406 if
407 else
408 break
409
continue
410 return
411 switch
412 case
413 default
Lexemes with attributes
Value Lexeme
Definition
301 type
302 character literal a character enclosed in single quotes; escape sequences are extra credit
303 integer literal
304 real literal
void or char or int or float
a sequence of one or more digits
two sequences each of one or more digits, separated by .
a sequence of zero or more characters (including escape sequences,
except for \\ and \") enclosed in double quotes
a letter or underscore, followed by zero or more letters, underscores, or
digits, that is not a keyword or type
305 string literal
306 identifier
Table 1: Tokens to be recognized by the lexer.
Transcribed Image Text:Value Lexeme Value Lexeme Value Lexeme 37 % 41 ) 33 ! 38 & 40 42 * 43 + 44 45 46 47 58 59 60 61 63 123 { 62 ? 91 93 ) 125 } 124 I Operators with two characters Value Lexeme Value Lexeme Value Lexeme 351 352 != 353 >= == 354 <= 355 ++ 356 -- 357 || 358 && 361 += 362 363 364 Keywords Value Lexeme 401 const Value Lexeme 402 struct Value Lexeme 403 for 404 while 405 do 406 if 407 else 408 break 409 continue 410 return 411 switch 412 case 413 default Lexemes with attributes Value Lexeme Definition 301 type 302 character literal a character enclosed in single quotes; escape sequences are extra credit 303 integer literal 304 real literal void or char or int or float a sequence of one or more digits two sequences each of one or more digits, separated by . a sequence of zero or more characters (including escape sequences, except for \\ and \") enclosed in double quotes a letter or underscore, followed by zero or more letters, underscores, or digits, that is not a keyword or type 305 string literal 306 identifier Table 1: Tokens to be recognized by the lexer.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Operators
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education