<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.3 20210610//EN" "https://jats.nlm.nih.gov/publishing/1.3/JATS-journalpublishing1-3.dtd">
<article article-type="research-article" dtd-version="1.3" xml:lang="en">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>Computing, Telecommunication and Control</journal-title>
        <trans-title-group xml:lang="ru">
          <trans-title>Информатика, телекоммуникации и управление</trans-title>
        </trans-title-group>
      </journal-title-group>
      <issn pub-type="epub">2687-0517</issn>
    </journal-meta>
    <article-meta>
      <article-id pub-id-type="publisher-id">4</article-id>
      <article-id pub-id-type="doi">10.5862/JCSTCS.224.4</article-id>
      <title-group>
        <article-title>A Language-Independent Code Formatting by Syntactic Matching and Templates</article-title>
        <trans-title-group xml:lang="ru">
          <trans-title>Языконезависимое форматирование текстов программ на основе сопоставления с образцом и синтаксических шаблонов</trans-title>
        </trans-title-group>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <name>
            <surname>Podkopaev</surname>
            <given-names>Anton</given-names>
          </name>
          <xref ref-type="aff" rid="aff1"/>
        </contrib>
        <contrib contrib-type="author">
          <name>
            <surname>Korovianskii</surname>
            <given-names>Aleksei</given-names>
          </name>
          <email>aleksei.korovianskii@student.spbu.ru</email>
        </contrib>
        <contrib contrib-type="author">
          <name>
            <surname>Ozernykh</surname>
            <given-names>Igor</given-names>
          </name>
          <email>st011628@student.spbu.ru</email>
        </contrib>
      </contrib-group>
      <aff id="aff1">Saint Petersburg State University</aff>
      <pub-date publication-format="electronic" date-type="pub" iso-8601-date="2015-08-10">
        <day>10</day>
        <month>08</month>
        <year>2015</year>
      </pub-date>
      <issue>4</issue>
      <issue-id pub-id-type="publisher-id">224</issue-id>
      <fpage>37</fpage>
      <lpage>50</lpage>
      <abstract xml:lang="en">
        <p>In paper we consider a code-formatting problem. A novel concept of declarative printers is introduced. These devices can perform formatting in accordance with the style of the rest of the source code. For this purpose, declarative formatters extract syntactic templates from the sample code and use them to construct a new representation of the input program. A proposed solution produces optimal program presentation in polynomial time. It is achieved by using polynomial-time pretty-printer combinators and introducing a partial order on text representations. We also present the results of evaluating the approach in the Java and Haskell languages. The development of a declarative printer for simple imperative language While is described. A comparison with modern IDEs code formatters is also presented.</p>
      </abstract>
      <kwd-group xml:lang="en">
        <kwd>formatting</kwd>
        <kwd>template</kwd>
        <kwd>combinators</kwd>
      </kwd-group>
    </article-meta>
  </front>
</article>
