78 lines
2.7 KiB
XML
78 lines
2.7 KiB
XML
<!-- $NetBSD: chap.statemachines.xml,v 1.4 2009/04/26 11:00:17 rillig Exp $ -->
|
|
|
|
<chapter id="statemachines">
|
|
<title>State machines</title>
|
|
|
|
<para>This chapter explains the various state machines that are
|
|
used in &pkglint;. It also provides graphical representations of
|
|
them that are much easier to read than the source code.</para>
|
|
|
|
<para>The opaque arrows in the figures represent transitions
|
|
that have a regular expression as condition. The hollow arrows
|
|
are the default transitions if nothing else matches. When
|
|
multiple regular expressions match in a state, the one that
|
|
appears first in the source code is chosen.</para>
|
|
|
|
<sect1 id="statemachines.shellword">
|
|
<title>The state machine for shell words</title>
|
|
|
|
<para>The state machine for single shell words is pretty simple,
|
|
and I think it can be understood from the source code alone. So
|
|
no graphical representation is provided.</para>
|
|
|
|
</sect1>
|
|
|
|
<sect1 id="statemachines.shellcommand">
|
|
<title>The state machine for shell commands</title>
|
|
|
|
<figure id="statemachine.shellcommand">
|
|
<title>The state transitions for shell commands</title>
|
|
<mediaobject>
|
|
<imageobject>
|
|
<imagedata fileref="statemachine.shellcmd.png" format="PNG"/>
|
|
</imageobject>
|
|
<textobject><para>(Here should be a drawing of the state transitions.)</para></textobject>
|
|
</mediaobject>
|
|
</figure>
|
|
|
|
<para>The punch card symbols provide a means to go to a certain
|
|
state whenever the input matches the text on the punch
|
|
card.</para>
|
|
|
|
</sect1>
|
|
|
|
<sect1 id="statemachines.patch">
|
|
<title>The state machine for patch files</title>
|
|
|
|
<para>The state machine for patch files is the newest of the
|
|
state machines. Here, the state transitions are separated from
|
|
the code, which makes the code itself pretty small. I don't know
|
|
yet if this programming style is elegant or not. Time will
|
|
show.</para>
|
|
|
|
<figure id="statemachine.patch">
|
|
<title>The state transitions for patch files</title>
|
|
<mediaobject>
|
|
<imageobject>
|
|
<imagedata fileref="statemachine.patch.png" format="PNG"/>
|
|
</imageobject>
|
|
<textobject><para>(Here should be a drawing of the state transitions.)</para></textobject>
|
|
</mediaobject>
|
|
</figure>
|
|
|
|
<para>The states on the left side are for parsing context diffs,
|
|
the ones on the right side are for unified diffs. Some of the
|
|
state names are highly abbreviated as follows. The first letter
|
|
gives the format of the patch, which is <quote>c</quote> for
|
|
context diffs and <quote>u</quote> for unified diffs. The second
|
|
letter gives the current syntactical level, which is
|
|
<quote>f</quote> for a file header, <quote>h</quote> for a hunk
|
|
header, or <quote>l</quote> for the hunk lines. The third letter
|
|
describes the action that belongs to the line, which is
|
|
<quote>a</quote> for an addition, and <quote>d</quote> for a
|
|
deletion.</para>
|
|
|
|
</sect1>
|
|
|
|
</chapter>
|