A run through using numpy.
Numpy has a nice little method fromstring to very quickly get our string data into an array of floats. Didn't bother with the bracket, hyphen BS, simply made it comma separated list of values, with an expectation of an even amount. There are zillions of ways to string a cat, using python, seek on stackoverflow.
Get flat list from string
>>> import numpy as np
>>> cmd = "2, 90, 5, 0, 4, -90"
>>> data = np.fromstring(cmd, sep=",", dtype=float)
>>> data
array([ 2., 90., 5., 0., 4., -90.])
Reshape into length, angle pairs
>>> data = data.reshape((-1, 2))
>>> data
array([[ 2., 90.],
[ 5., 0.],
[ 4., -90.]])
Or transposed such that lengths in row 0, angles in next
>>> data.T
array([[ 2., 5., 4.],
[ 90., 0., -90.]])
Radians are required in blender, so convert
>>> data.T[1] = np.radians(data.T[1])
>>> data
array([[ 2. , 1.57079633],
[ 5. , 0. ],
[ 4. , -1.57079633]])
Next our starting vert, and direction vector. In the question you have used the $y=0$ or $XZ$ plane, with the origin as starting point. No rotation steps in $X$ axis direction
>>> v0 = (0, 0, 0)
>>> v = Vector((1, 0, 0))
>>> verts = [v0]
Then to get our verts, we scalar multiply our direction vector rotated by angle about $Y$ axis, and add result to the previous, till exhausted
>>> for d, angle in data:
... R = Matrix.Rotation(angle, 3, 'Y')
... verts.append(verts[-1] + d * R @ v)
...
The result
>>> np.array(verts)
array([[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
[ 1.50995803e-07, 0.00000000e+00, -2.00000000e+00],
[ 5.00000015e+00, 0.00000000e+00, -2.00000000e+00],
[ 4.99999998e+00, 0.00000000e+00, 2.00000000e+00]])
Note if looking at plane from above, this will rotate clockwise. To rotate the other way negate one of the axis, or the angle.
edges
>>> edges = [(i - 1, i) for i in range(1, len(verts))]
>>> edges
[(0, 1), (1, 2), (2, 3)]
Now as an operator property
Here is a minor edit to the simple operator template to add a string property, which is converted as above. Since any rubbish can be typed in will require a try except clause.

import bpy
from bpy.props import StringProperty
import numpy as np
def main(context, cmd):
try:
data = np.fromstring(cmd, sep=",", dtype=float)
print(data)
except:
print("Error with cmd")
return False
# use as above check it has even length etc
class SimpleOperator(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.simple_operator"
bl_label = "Simple Object Operator"
bl_options = {'REGISTER', 'UNDO'}
cmd : StringProperty()
def execute(self, context):
main(context, self.cmd)
return {'FINISHED'}
def register():
bpy.utils.register_class(SimpleOperator)
def unregister():
bpy.utils.unregister_class(SimpleOperator)
if name == "main":
register()
# test call
bpy.ops.object.simple_operator('INVOKE_DEFAULT')
which prints to console
[]
[ 1. 0. 3. 90. 5. 45.]