Summing? That's my forte! Introduction

Forte is a very peculiar esoteric language based on the concept of modifying the values of numbers. In Forte numbers are not constants but variables, you can use the LET instruction to assign new values to them.

For example, after executing LET 2=4-1 from now on 2 assumes the value of 3, which means that whenever the value 2 comes up in an expression it is instead "replaced" by 3. The expression (1+1)*2 would now evaluate to 9.

This instruction in Forte is used both for storing information and for flow control (lines are numbered and by changing the value of their numbers you can determine the order of their execution). In this challenge we will not deal with this second aspect.

The challenge

You are required to write an interpreter for a simplified subset of Forte's LET expressions.

You will receive as input a series of lines following this grammar:

&lt;line&gt;::= &lt;number&gt;=&lt;expression&gt;

&lt;expression&gt;::= &lt;number&gt;|&lt;expression&gt;+&lt;number&gt;


Note: this grammar is not valid Forte because it lacks line numbers, LET, and parentheses (which are always mandatory)

That is, you will only need to deal with computing summations and assigning values to numbers. Parentheses won't be present in the input, and each expression will need to be evaluated from left to right: beware that partial results are affected by redefinitions!

Numbers will always be non-negative integers, up to the limit of your language's native integer type (or 2^32, whichever is higher).

For each line you should output the result of the expression and assign this result to the (possibly reassigned) value of the first number, which will affect how the following lines will be interpreted.

This is code-golf, the shortest code (in bytes) wins!

Other rules


The input format is flexible, you can for example take a single string with newlines, a list of strings, a list of lists of numbers... The same goes for the output, as long as it's clear what's the result of each expression in the input.
You may submit either a function, a full program, or a solution to be run in a REPL environment calling it once for each line.
Standard loopholes are forbidden, in particular you can't call an external Forte interpreter in your code.


Examples

These are all part of the same input. After each line the expected output relative to that line is shown, sometimes with a comment indicating relevant reassignments (not part of the required output).

5=4
4
6=5
4        # 5 -&gt; 4
7=1+2+5
7
7=5+2+1
4        # Order of operations matters! 5+2 -&gt; 4+2 -&gt; 6 -&gt; 4
18=5+6+7
12
5=3
3        # Remember: 5 -&gt; 4
10=6+4
3        # 6 -&gt; 4 -&gt; 3, 3+3 = 6 -&gt; 3
Perl 5, 92 bytes

90 bytes of code + -pl flags.



sub f{($b=$h{$a=pop}//$a)!=$a?f($b):$a}s%(\d+)\+(\d+)%f($1)+f$2%e&amp;&amp;redo;/=/;$_=$h{f$`}=f$'


Try it online!

I use the hashtable %h to store the mapping between numbers.
The function (sub) f returns the number to which its input map (or its input if it's mapped to no number): $h{$a=pop} retrieves the number toward which the input maps. If it's none, thanks to //$a, the value of ($b=$h{$a=pop}//$a) is the input ($a). We make sure that this values isn't the input itself to not loop infinitely (!=$a). Then, we either recursively call f or return the input.
The main program consists of two steps:
  - s%(\d+)\+(\d+)%f($1)+f$2%e&amp;&amp;redo evaluates the first addition on the right side, while there is still an addition: it replaces x+y by the result of the evaluation of f(x)+f(y).
  - /=/;$_=$h{f$`}=f$' does the assignment: /=/ allows to access the left side with $` and the right side with $', then $h{f$`}=f$' does the assignment. And we also assign it to $_ that is implicitly printed after each line.