Port of schuchert.wikispaces.com


PowerShell5.TokenizeExpression

PowerShell5.TokenizeExpression

Overview

The next problem is an implementation of the The Shunting Yard Algorithm Kata. To implement this algorithm, we need to be able to break a complex expression into its logical parts. For example:

Expression                  
4+5 4 + 5            
a * 3 + 1 a * 3 + 1        
(4 + 5) * x ( 4 + 5 ) * x    
f(g(q^6)) f ( g ( q ^ 6 ) )

Here are some notes and observations from these examples:

Initially, we only want to break expressions into their logical parts. Notice, we should simply make sure everything uses whitespace, but since we’re practicing TDD, we can use this as a good place to start.

Getting Started

Create a directory into which we will store all of the test code and the production. Given that this example leads into the The Shunting Yard Algorithm Kata, I’ll create C:\Users\Brett\shunting_yard_algorithm.


Comments

" Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.