rzel / mini-java

Automatically exported from code.google.com/p/mini-java
0 stars 0 forks source link

use !isRunning() as the indication of the reduction #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Current solution is by using the AcceptableState as the indication for a
reduction. The problem is that we need to reduce the longest possible
production rule in order to avoid the ambiguous rules.

AcceptableState doesn't necessarily mean an "END" state. It just means some
production rules can be reduced.

Original issue reported on code.google.com by lemontree.cool on 1 Oct 2008 at 3:12

GoogleCodeExporter commented 9 years ago
Flow Chart:

1. more tokens?
Y: goto 2
N: goto ERROR

1.5 if the symbolType.equals(START), return the symbol

2.1 feed the symbolType to the simulator
2.2 push the symbol onto the stack
2.3 push the dfaState onto the stack

3. isRunning?
Y: goto 1
N: goto 4

4.1 go back one step
4.1.1 pop symbol from the stack
4.1.2 pop dfaState from the stack
4.1.3 unshift the symbol back to the symbol list
4.2 call reduce()
4.3 unshift the new symbol to the symbol list

Original comment by lemontree.cool on 1 Oct 2008 at 3:30

GoogleCodeExporter commented 9 years ago

Original comment by lemontree.cool on 2 Oct 2008 at 9:39

GoogleCodeExporter commented 9 years ago
append an "END" symbol to the symbol list. so no need to test isEmpty().

Original comment by lemontree.cool on 2 Oct 2008 at 10:32

GoogleCodeExporter commented 9 years ago

Original comment by lemontree.cool on 2 Oct 2008 at 11:10