File: proto_parse.html

package info (click to toggle)
librnd 4.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,812 kB
  • sloc: ansic: 126,990; sh: 2,602; makefile: 2,145; awk: 7
file content (38 lines) | stat: -rw-r--r-- 1,523 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<html>
<body>
Protocol parser state machine of the reference implementation:
<img src="proto_parse.svg">
Legend:
<ul>
	<li> yellow boxes are states
	<li> blue arrows are optional features for a more tolerant parser
	<li> round nodes are actions that shall be taken
	<li> arrow with text: execute action or switch state if condition is true
	<li> arrow without text: do this if no other condition is met
</ul>
<h3>Notes on the reference implementation </H3>
The reference implementation builds a <b>tree of nodes</b> for the arguments.
Each node is either a list or a text. A node has a pointer to its parent, its
first child and its next sibling. While parsing list-of-lists, the parser
keeps a <i>current node</i>. A new node is either added as the last sibling of
the <i>current node</i> (new argument on a list) or as the first
child of the <i>current node</i> (first argument of a new list when the list is
open).
<p>
When a list is closed, the parent of the <i>current node</i> becomes the
new <i>current node</i>.
<p>
When parsing a new message, the current node is NULL until the argument list
is open; the new <i>current node</i> also becomes the argument tree root.
If the argument tree root is closed, a newline shall follow, because that's
how a message is terminated.
<p>
The <b>binary string</b> part of the state machine has 2 more internal
states:
<ul>
	<li> a boolean indicating whether we are parsing the length or the string (before or after the '=')
	<li> an integer string length
</ul>

</body>
</html>