From 719197a407fd08bdd54d53dbd93f5949ebdb48e3 Mon Sep 17 00:00:00 2001 From: Kia <kia@special-circumstanc.es> Date: Tue, 2 Feb 2021 16:44:04 -0700 Subject: [PATCH] more work on parse tree --- unoptimized_lr/simple_parse_tree.py | 53 +++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/unoptimized_lr/simple_parse_tree.py b/unoptimized_lr/simple_parse_tree.py index 700af89..2e03063 100644 --- a/unoptimized_lr/simple_parse_tree.py +++ b/unoptimized_lr/simple_parse_tree.py @@ -1,20 +1,18 @@ # An example parse tree looks like: -# nonterminal A -# * | * -# * | * -# * terminal K * -# * * -# nonterminal B nonterminal D -# / * * -# / * * -# / nonterminal C * -# / \ * -# / \ terminal L -# terminal I \ -# terminal J - -MAKE VERTICAL SPACING GOOD and PROPER +# nonterminal A +# ** | ** +# ** | ** +# ** | ** +# * | * +# nonterminal B terminal K nonterminal D +# / * * +# / * * +# terminal I nonterminal C terminal L +# \ +# \ +# terminal J + # As it is parsed, we serialize it on the fly. The serialization scheme represents the tree # as a sequence of records, each of which corresponds to a reduction. In other words, each @@ -76,6 +74,31 @@ MAKE VERTICAL SPACING GOOD and PROPER # be stitched in this way. +# The parameters for instantiating the tree serializer are as follows: +# +# parameters dependent only on the language: +# * number of nonterminals +# * number of terminals +# * list of language rules +# +# parameters dependent on the use case: +# * bitwidth of parse tree memory +# * length of parse tree memory +# * maximum possible number of emitted records per parse +# +# If the latter is not provided, a pessimistic estimate will be calculated: +# (number of bits in memory) / (number of bits to represent the smallest possible record) + +# In general, the bitwidth of the record fields do not correspond to the bitwidth of memory available +# to the FPGA. In order to address this, we split up the records across multiple memory addresses as +# is necessary. This means that the records of the serialized parse tree won't necessarily be in any +# sort of alignment. If it is desired, we can add functionality to do alignment. But I do not think it +# is a big deal since this data structure anyway needs to be decoded from the start -- there's no random +# access possible. + + + + class TreeSerializer(Elaboratable): -- GitLab