diff --git a/unoptimized_lr/simple_lr_automaton.py b/unoptimized_lr/simple_lr_automaton.py index e4dcaf7607299b364f33e3fd72c44bfd3bb02a5a..7207ece11d8f4a5784257976e87393459fa46f0d 100644 --- a/unoptimized_lr/simple_lr_automaton.py +++ b/unoptimized_lr/simple_lr_automaton.py @@ -163,9 +163,16 @@ from functools import reduce # (index out, data out, stack pointer) # WLongestParse # -# Serialization memory (or stream): -# -# max(WLongestRule, 1 + WNonterminal, 1 + WTerminal) +# Serialization memory (or stream). +# The record elements in the serialized parse tree have various widths, but the +# width of the overall stream is the maximum of all of those. +# Field 1: Nonterminal in the parse tree. Has length WNonterminal +# Field 2: Number of subnodes. Has length WLongestRule +# Fields for the subnodes: A subnode has a leading indicator bit, if it's 0, it's +# a literal terminal, so the length is (1+WTerminal). +# If the indicator bit is 1, it's a backreference to a nonterminal, so length (1+WLongestParse) +# +# max(WNonterminal, WLongestRule, 1 + WTerminal, 1+ WLongestParse) # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # / \ # /----------------------\ /---------------------\