Simple, Custom Parsing with c++
- by bradkovach
Hi! I have been reading SO for some time now, but I truly cannot find any help for my problem.
I have a c++ assignment to create an IAS simulator.
Here is some sample code...
0 1 a
1 2 b
2 c
3 1
10 begin
11 . load a, subtract b and offset by -1 for jump+
11 load M(0)
12 sub M(1)
13 sub M(3)
14 halt
Using c++, I need to be able to read these lines and store them in a "memory register" class that I already have constructed...
For example, the first line would need to store "1 a" in register zero.
How can I parse out the number at the line beginning and then store the rest as a string?
I have setup storage using a class that is called using mem.set(int, string);. int is the memory location at the beginning of the line and string is the stored instruction.