Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a lexical analyzer in Python that accepts the following language and generates a report: Tokens SEMICOLON PRINT ID PLUS MINUS TIMES DIV POWER ASSIGN

Write a lexical analyzer in Python that accepts the following language and generates a report:

Tokens
SEMICOLON
PRINT
ID
PLUS
MINUS
TIMES
DIV
POWER
ASSIGN
INT_CONST
REAL_CONST
STRING
LPAREN
RPAREN
QUOTE

A Sample program:

a% = 5.5; b# = 3; c% = a% + b#; PRINT "the result is"; PRINT c%;

Sample Report:

ID a REAL ASSIGN REAL_CONST 5.5 SEMICOLON ID b INTEGER ASSIGN INT_CONST 3 SEMICOLON ID c REAL ASSIGN ID a REAL PLUS ID b INTEGER SEMICOLON PRINT STRING the result is SEMICOLON PRINT ID c REAL SEMICOLON

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

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions

Question

Know how to use reservations systems to inventory demand.

Answered: 1 week ago