<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  <!ENTITY % general-entities SYSTEM "../general.ent">
  %general-entities;
]>

<sect1 id="ch-system-flex" role="wrap">
  <?dbhtml filename="flex.html"?>

  <sect1info condition="script">
    <productname>flex</productname>
    <productnumber>&flex-version;</productnumber>
    <address>&flex-url;</address>
  </sect1info>

  <title>Flex-&flex-version;</title>

  <indexterm zone="ch-system-flex">
    <primary sortas="a-Flex">Flex</primary>
  </indexterm>

  <sect2 role="package">
    <title/>

    <para>Flex 软件包包含一个工具，用于生成在文本中识别模式的程序。</para>

    <segmentedlist>
      <segtitle>&buildtime;</segtitle>
      <segtitle>&diskspace;</segtitle>

      <seglistitem>
        <seg>&flex-ch6-sbu;</seg>
        <seg>&flex-ch6-du;</seg>
      </seglistitem>
    </segmentedlist>

  </sect2>

  <sect2 role="installation">
    <title>安装 Flex</title>

    <para>首先修正一个 glibc-2.26 引入的问题：</para>

<screen><userinput remap="pre">sed -i "/math.h/a #include &lt;malloc.h&gt;" src/flexdef.h</userinput></screen>

    <para>构建过程假设 <application>help2man</application>
		程序存在，以根据可执行文件的 --help 选项创建一个 man 页面。
		然而它并不存在，因此我们使用一个环境变量，跳过这一过程。
		现在，准备编译 Flex：</para>

<screen><userinput remap="configure">HELP2MAN=/tools/bin/true \
./configure --prefix=/usr --docdir=/usr/share/doc/flex-&flex-version;</userinput></screen>

    <para>编译该软件包：</para>

<screen><userinput remap="make">make</userinput></screen>

    <para>如果要测试编译结果（需要约 0.5 SBU）, 执行：</para>

<screen><userinput remap="test">make check</userinput></screen>

    <para>安装该软件包：</para>

<screen><userinput remap="install">make install</userinput></screen>

    <para>个别程序还不知道 <command>flex</command> ，
    并试图去运行它的前身 <command>lex</command>。为了支持这些程序，
	创建一个名为 <filename>lex</filename> 的符号链接，它以
	<command>lex</command> 仿真模式运行 <filename>flex</filename>：</para>

<screen><userinput remap="install">ln -sv flex /usr/bin/lex</userinput></screen>

  </sect2>

  <sect2 id="contents-flex" role="content">
    <title>Flex 的内容</title>

    <segmentedlist>
      <segtitle>安装的程序</segtitle>
      <segtitle>安装的库</segtitle>
      <segtitle>安装的目录</segtitle>

      <seglistitem>
        <seg>flex, flex++ (到 flex 的链接), 以及 lex (到 flex 的链接)</seg>
        <seg>libfl.so</seg>
        <seg>/usr/share/doc/flex-&flex-version;</seg>
      </seglistitem>
    </segmentedlist>

    <variablelist>
      <bridgehead renderas="sect3">简要描述</bridgehead>
      <?dbfo list-presentation="list"?>
      <?dbhtml list-presentation="table"?>

      <varlistentry id="flex">
        <term><command>flex</command></term>
        <listitem>
          <!--para>A tool for generating programs that recognize patterns in text;
          it allows for the versatility to specify the rules for pattern-finding,
          eradicating the need to develop a specialized program</para-->
          <para>一个用于生成在文本文件中识别模式的程序的工具，
			  它允许灵活地指定查找模式的规则，消除了开发专用程序的需要。
		  </para>
          <indexterm zone="ch-system-flex flex">
            <primary sortas="b-flex">flex</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="flexpp">
        <term><command>flex++</command></term>
        <listitem>
          <para>flex 的扩展，用于生成 C++ 代码和类。它是一个指向
          <command>flex</command> 的符号链接</para>
          <indexterm zone="ch-system-flex flexpp">
            <primary sortas="b-flex++">flex++</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="lex">
        <term><command>lex</command></term>
        <listitem>
          <para>一个以 <command>lex</command> 仿真模式运行
          <command>flex</command> 的符号链接</para>
          <indexterm zone="ch-system-flex lex">
            <primary sortas="b-lex">lex</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libfl">
        <term><filename class="libraryfile">libfl</filename></term>
        <listitem>
          <para><filename class="libraryfile">flex</filename> 库</para>
          <indexterm zone="ch-system-flex libfl">
            <primary sortas="c-libfl">libfl</primary>
          </indexterm>
        </listitem>
      </varlistentry>

    </variablelist>

  </sect2>

</sect1>
