Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello! Need help in C++, C, or Java. I need to open a .txt file and have the program read and tokenize each character. The

Hello! Need help in C++, C, or Java.

I need to open a .txt file and have the program read and tokenize each character. The program should be able to parse the file and then print out each char the file has, say what type of token it is, the lexeme, and which line and column the lexeme is found.

for example: file.txt has: image text in transcribed and the output should look like: start reading to scan file: file.txt keyword, symbol: import line:1 string literal, symbol: "scl.h" line 1 keyword, symbol: function line: 3 keyword, symbol: main line: 3 keyword, symbol: return line: 3 keyword, symbol: type line: 3 keyword, symbol: integer line: 3 keyword, symbol: is line: 3 keyword, symbol: variables line: 4 keyword, symbol: define line: 5 identifier, symbol: x line: 5 keyword, symbol: of line: 5 keyword, symbol: type line: 5 keyword, symbol: double line: 5 keyword, symbol: begin line: 6 keyword, symbol: display line: 7 string literal, symbol: "Welcome to the world of SCL" line 7 keyword, symbol: set line: 8 identifier, symbol: x line: 8 assignment, symbol: = line: 8 real constant, symbol: 45.95 line: 8 etc

import "scl.h" implementations function main return type integer is variables define x of type double // a variable declaration begin display "Welcome to the world of SCL" set x = 45.95 // assigns a value to variable x display "Value of x: , X exit // execution terminates OK endfun main

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions