Reader small image

You're reading from  Practical System Programming for Rust Developers

Product typeBook
Published inDec 2020
PublisherPackt
ISBN-139781800560963
Edition1st Edition
Tools
Right arrow
Author (1)
Prabhu Eshwarla
Prabhu Eshwarla
author image
Prabhu Eshwarla

Prabhu Eshwarla has been shipping high-quality, business-critical software to large enterprises and running IT operations for over 25 years. He is also a passionate teacher of complex technologies. Prabhu has worked with Hewlett Packard and has deep experience in software engineering, engineering management, and IT operations. Prabhu is passionate about Rust and blockchain and specializes in distributed systems. He considers coding to be a creative craft, and an excellent tool to create new digital worlds (and experiences) sustained through rigorous software engineering.
Read more about Prabhu Eshwarla

Right arrow

Modeling the system behavior

In the last section, we confirmed the system requirements. Let's now design the logic for processing the arithmetic expression. The components of the system are shown in Figure 2.1:

Figure 2.1 – Design of an arithmetic expression evaluator

Figure 2.1 – Design of an arithmetic expression evaluator

The components shown in the preceding figure work together as follows:

  1. The user enters an arithmetic expression at the command-line input and presses the Enter key.
  2. The user input is scanned in its entirety and stored in a local variable.
  3. The arithmetic expression (from the user) is scanned. The numbers are stored as tokens of the Numeric type. Each arithmetic operator is stored as a token of that appropriate type. For example, the + symbol will be represented as a token of type Add, and the number 1 will be stored as a token of type Num with a value of 1. This is done by the Lexer (or Tokenizer) module.
  4. An Abstract Syntax Tree (AST) is constructed from the...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Practical System Programming for Rust Developers
Published in: Dec 2020Publisher: PacktISBN-13: 9781800560963

Author (1)

author image
Prabhu Eshwarla

Prabhu Eshwarla has been shipping high-quality, business-critical software to large enterprises and running IT operations for over 25 years. He is also a passionate teacher of complex technologies. Prabhu has worked with Hewlett Packard and has deep experience in software engineering, engineering management, and IT operations. Prabhu is passionate about Rust and blockchain and specializes in distributed systems. He considers coding to be a creative craft, and an excellent tool to create new digital worlds (and experiences) sustained through rigorous software engineering.
Read more about Prabhu Eshwarla