prefix code system

Table of Contents

A prefix code systems involves a set of code in which no whole word of code is prefix of another code.

For example {1,22,23} is a prefix code system, and {1,12,3} is not, as 1’s whole word is 12’s prefix.

This property1 of code system is refered to as prefix property.

1. usefulness of prefix property

This property is useful as and thus is deterministic, require no compilation, and is easy to .

Backlinks

Intuitively, a parse tree could be draw for a parser, and the following psudo code could be used for the parser

(defun parse (parse-tree code)
  ;; code "abc" is stored as '("a" "b" "c") in CODE
  ;; parse-tree-get-children PARSE-TREE KEY return children of PARSE-TREE associated with character.
  ;; leaf nodes of PARSE-TREE is code's binded value is
  (parse (parse-tree-get-children parse-tree (car code)) (cdr code))
  )

In the whole recursion, no part of the code is used twice, therefore with prefix property, such code system is LR(0) parsable.

Backlinks

Intuitively, a parse tree could be draw for a parser, and the following psudo code could be used for the parser

(defun parse (parse-tree code)
  ;; code "abc" is stored as '("a" "b" "c") in CODE
  ;; parse-tree-get-children PARSE-TREE KEY return children of PARSE-TREE associated with character.
  ;; leaf nodes of PARSE-TREE is code's binded value is
  (parse (parse-tree-get-children parse-tree (car code)) (cdr code))
  )

In the whole recursion, no part of the code is used twice, therefore with prefix property, such code system is LR(0) parsable.

Footnotes:

1

in other words, prefix code system is code system (set of code) with prefix property

Author: Linfeng He

Created: 2024-04-03 Wed 20:21