Pochi Doc

Serialization / Deserialization of Pochi source code

When editing Pochi source code we usually want to work with an editor that deals with the pre-parsed nature of the source code, this present many benefits but one of the “drawback” is that we are not dealing directly with plain text. Thus a solution to convert the source code to and from plain text is needed if we want to still be able to view and edit source code without a special editor or if we want to put our source under version control management solutions such as Git or CVS.

Pre-parsed form

The pre-parsed form is relatively simple, a string of character not containing spaces (a word) has a color which indicates its function. The different colors are described in the Assembly document. Besides that the pre-parsed format can also already try to convert the string to a number and if it succeeds, it can also remember that the word is a literal number.

That’s all there is to the pre-parsing of words.

Converting to text

Ultimately what serialization / deserialization achieve is convert from/to the pre-parsed to/from plain text. The textual format is extremely simple, we prepend a letter representing the color followed by an underscore.

The only exception is blue words that are used for text formatting, those are translated directly to their textual representation:

blue word ASCII
cr \n
> \t
. ‘ ‘

Let’s illustrate with a little example, if we have a red “Pochi” and a green “forth” the textual format will look like so:

r_Pochi g_forth

Color tags

Here is a table of the colors with their tags:

color tag
red r_
magenta m_
magenta string s_
green g_
yellow y_
white w_
gray a_