%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% --------------------------------------------------------------
%% Based on the gost package styles by
%% Maksym Polyakov      © 1996-2005, 
%% Leonid Sinev         © 2017,
%% Igor A. Kotelnikov   © 2012-2021.
%% --------------------------------------------------------------
%% Alexey V. Kuznetsov: mailtokuznetsov@gmail.com
%% Detailed sorted citation style
%% Version 2026/09/06
%% --------------------------------------------------------------

ENTRY{
  address         % alias for location
  archivePrefix   % alias for eprinttype
  author
  authorcountry
  booktitle
  chapter
  compiler
  credits
  date
  doi
  edition
  editor
  eid
  eprint
  eprinttype      % alias for archivePrefix
  eprintclass     % alias for primaryClass
  holder
  howpublished
  institution     % alias for organization and school
  ipc
  isbn
  issn
  journal
  key
  language        % alias for langid
  langid          % alias for language
  location        % alias for address
  media
  month
  note
  number
  organization    % alias for institution and school
  origlanguage
  pages
  pagetotal
  primaryClass    % alias for eprintclass
  prioritycountry
  prioritydate   
  prioritynumber 
  publication    
  publicationdate
  publisher
  requestdate    
  requestnumber  
  school          % alias for institution and organization
  series
  specialitycode
  title
  titleaddon
  translator
  type
  url
  urldate
  volume
  year
  }{}{label}

INTEGERS{
  output.state
  before.all
  mid.sentence
  after.sentence
  after.block
  after.dblslash
  after.slash
  after.colon
  after.semicolon }

STRINGS{curlanguage}
STRINGS{s t}
STRINGS{y m d}

FUNCTION{init.state.consts}{
  #0 'before.all :=
  #1 'mid.sentence :=
  #2 'after.sentence :=
  #3 'after.block :=
  #4 'after.dblslash :=
  #5 'after.slash :=
  #6 'after.colon :=
  #7 'after.semicolon := }

FUNCTION {set.language}{
  langid empty$
    {language empty$ {"english" 'curlanguage :=} {language  'curlanguage :=} if$}
    {langid  'curlanguage :=}
  if$}

FUNCTION{output.nonnull}{
  swap$
  output.state mid.sentence    = {", " * write$}
 {output.state after.block     = {add.period$ write$ "~\BibDash " write$ newline$ "\newblock " write$}
 {output.state before.all      = 'write$
 {output.state after.dblslash  = {"~/\!/ " * write$}
 {output.state after.slash     = {"~/ " * write$}
 {output.state after.colon     = {"~: " * write$}
 {output.state after.semicolon = {"~; " * write$} {add.period$ " " * write$}
  if$}if$}if$}if$}if$}if$
  mid.sentence 'output.state := }
  if$}

FUNCTION{output}{duplicate$ empty$ 'pop$ 'output.nonnull if$}

FUNCTION{fin.entry}{add.period$ "\endgroup" * write$ newline$}
FUNCTION{add.blank}    {" " * before.all 'output.state :=}
FUNCTION{new.block}    {output.state before.all  = 'skip$ {after.block     'output.state :=} if$}
FUNCTION{new.dblslash} {output.state before.all  = 'skip$ {after.dblslash  'output.state :=} if$}
FUNCTION{new.slash}    {output.state before.all  = 'skip$ {after.slash     'output.state :=} if$}
FUNCTION{new.colon}    {output.state before.all  = 'skip$ {after.colon     'output.state :=} if$}
FUNCTION{new.semicolon}{output.state before.all  = 'skip$ {after.semicolon 'output.state :=} if$}
FUNCTION {new.sentence}{output.state after.block = 'skip$
  {output.state before.all = 'skip$ {after.sentence 'output.state :=} if$} if$}

FUNCTION{not}{{#0} {#1} if$}
FUNCTION{and}{'skip$ {pop$ #0} if$}
FUNCTION{or} {{pop$ #1} 'skip$ if$}

FUNCTION{bracify}      {duplicate$ empty$ {pop$ ""} {"{" swap$ * "}" *}      if$}
FUNCTION{bracketise}   {duplicate$ empty$ {pop$ ""} {"[" swap$ * "]" *}      if$}
FUNCTION{paranthesify} {duplicate$ empty$ {pop$ ""} {"(" swap$ * ")" *}      if$}
FUNCTION{emphasize}    {duplicate$ empty$ 'skip$ {"\emph{" swap$ * "}" *} if$}

FUNCTION{thinspace.connect}{"\," swap$ * *}

FUNCTION{bbl.jan}{
  curlanguage "english"   = curlanguage "german" = or {"Jan."}
 {curlanguage "ukrainian" =                           {"січ."} % Січень
 {curlanguage "russian"   =                           {"янв."}
 {"language is not defined: bbl.jan for " curlanguage * warning$ "Jan."}
 if$}if$}if$}

FUNCTION{bbl.feb}{
  curlanguage "english"   = curlanguage "german" = or {"Feb."}
 {curlanguage "ukrainian" =                           {"лют."} % Лютий
 {curlanguage "russian"   =                           {"фев."}
 {"language is not defined: bbl.feb for " curlanguage * warning$ "Feb."}
 if$}if$}if$}

FUNCTION{bbl.mar}{
  curlanguage "english"   = {"Mar."}
 {curlanguage "ukrainian" = {"бер."} % Березень
 {curlanguage "russian"   = {"март"}
 {curlanguage "german"    = {"März"}
 {"language is not defined: bbl.mar for " curlanguage * warning$ "Mar."}
 if$}if$}if$}if$}

FUNCTION {bbl.apr}{
  curlanguage "english"   = curlanguage "german" = or {"Apr."}
 {curlanguage "ukrainian" =                           {"квіт."} % Квітень
 {curlanguage "russian"   =                           {"апр."}
 {"language is not defined: bbl.apr for " curlanguage * warning$ "Apr."}
 if$}if$}if$}

FUNCTION{bbl.may}{
  curlanguage "english"   = {"May"}
 {curlanguage "ukrainian" = {"трав."} % Травень
 {curlanguage "russian"   = {"май"}
 {curlanguage "german"    = {"Mai"}
 {"language is not defined: bbl.may for " curlanguage * warning$ "May"}
 if$}if$}if$}if$}

FUNCTION{bbl.jun}{
  curlanguage "english"   = {"June"}
 {curlanguage "ukrainian" = {"чер."} % Червень
 {curlanguage "russian"   = {"июнь"}
 {curlanguage "german"    = {"Juni"}
 {"language is not defined: bbl.jun for " curlanguage * warning$ "June"}
 if$}if$}if$}if$}

FUNCTION{bbl.jul}{
  curlanguage "english"   = {"July"}
 {curlanguage "ukrainian" = {"лип."} %Лип.
 {curlanguage "russian"   = {"июль"}
 {curlanguage "german"    = {"Juli"}
 {"language is not defined: bbl.jul for " curlanguage * warning$ "July"}
 if$}if$}if$}if$}

FUNCTION{bbl.aug}{
  curlanguage "english"   = curlanguage "german" = or {"Aug."}
 {curlanguage "ukrainian" =                           {"серп."} % Серп.
 {curlanguage "russian"   =                           {"авг."}
 {"language is not defined: bbl.aug for " curlanguage * warning$ "Aug."}
 if$}if$}if$}

FUNCTION{bbl.sep}{
  curlanguage "english"   =  curlanguage "german" = or {"Sep."}
 {curlanguage "ukrainian" =                            {"вер."} % Вересень
 {curlanguage "russian"   =                            {"сент."}
 {"language is not defined: bbl.sep for " curlanguage * warning$ "Sep."}
 if$}if$}if$}

FUNCTION{bbl.oct}{
  curlanguage "english"   = {"Oct."}
 {curlanguage "ukrainian" = {"жов."} % Жовтень
 {curlanguage "russian"   = {"окт."}
 {curlanguage "german"    = {"Okt."}
 {"language is not defined: bbl.oct for " curlanguage * warning$ "Oct."}
 if$}if$}if$}if$}

FUNCTION{bbl.nov}{
  curlanguage "english"   = curlanguage "german" = or {"Nov."}
 {curlanguage "ukrainian" =                           {"лис."} % Листопад
 {curlanguage "russian"   =                           {"нояб."}
 {"language is not defined: bbl.nov for " curlanguage * warning$ "Nov."}
 if$}if$}if$}

FUNCTION{bbl.dec}{
  curlanguage "english"   = {"Dec."}
 {curlanguage "ukrainian" = {"груд."} % Грудень
 {curlanguage "russian"   = {"дек."}
 {curlanguage "german"    = {"Dez."}
 {"language is not defined: bbl.dec for " curlanguage * warning$ "Dec."}
 if$}if$}if$}if$}

FUNCTION{format.month}
{ month empty$ { "" }
    {month "Jan." = month "Jan" = or month "January"   = or month "jan." = or month "jan" = or month "january"   = or {bbl.jan}
    {month "Feb." = month "Feb" = or month "February"  = or month "feb." = or month "feb" = or month "february"  = or {bbl.feb}
    {month "Mar." = month "Mar" = or month "March"     = or month "mar." = or month "mar" = or month "march"     = or {bbl.mar}
    {month "Apr." = month "Apr" = or month "April"     = or month "apr." = or month "apr" = or month "april"     = or {bbl.apr}
    {month "May"  = month "may" = or                                                                                  {bbl.may}
    {month "Jun." = month "Jun" = or month "June"      = or month "jun." = or month "jun" = or month "june"      = or {bbl.jun}
    {month "Jul." = month "Jul" = or month "July"      = or month "jul." = or month "jul" = or month "july"      = or {bbl.jul}
    {month "Aug." = month "Aug" = or month "August"    = or month "aug." = or month "aug" = or month "august"    = or {bbl.aug}
    {month "Sep." = month "Sep" = or month "September" = or month "sep." = or month "sep" = or month "september" = or {bbl.sep}
    {month "Oct." = month "Oct" = or month "October"   = or month "oct." = or month "oct" = or month "october"   = or {bbl.oct}
    {month "Nov." = month "Nov" = or month "November"  = or month "nov." = or month "nov" = or month "november"  = or {bbl.nov}
    {month "Dec." = month "Dec" = or month "December"  = or month "dec." = or month "dec" = or month "december"  = or {bbl.dec}
    {"unknown month in " cite$ * warning$ month }
  if$}if$}if$}if$}if$}if$}if$}if$}if$}if$}if$}if$} if$}

FUNCTION{n.dashify}{
  't := ""
  {t empty$ not}
    {t #1 #1 substring$ "-" =
       {t #1 #2 substring$ "--" = not
          {"--" * t #2 global.max$ substring$ 't :=}
          {{t #1 #1 substring$ "-" =}
              {"-" * t #2 global.max$ substring$ 't :=}
           while$}
        if$}
       {t #1 #1 substring$ * t #2 global.max$ substring$ 't :=}
     if$}
  while$}

INTEGERS{multiresult nameptr namesleft numnames}

FUNCTION{bbl.etal}{
  curlanguage "english"   = {" \textup{[et al.]}"}
 {curlanguage "german"    = {" \textup{[u. a.]}"}
 {curlanguage "ukrainian" = {" \textup{[та ін.]}"}
 {curlanguage "russian"   = {" \textup{[и др.]}"}
 {"language is not defined: " curlanguage  " in bbl.etal" * * warning$ " \textup{[et al.]}"}
 if$}if$}if$}if$}

FUNCTION{bbl.and}{
  curlanguage "english"   = {" and "}
 {curlanguage "german"    = {" und "}
 {curlanguage "ukrainian" = {"~i "}
 {curlanguage "russian"   = {author empty$ {"~и "} {s author = not {"~и "} {", "} if$} if$}
 {"language is not defined: " curlanguage  " in bbl.and" * * warning$ " and "}
 if$}if$}if$}if$}

FUNCTION{fmt.names.three}{
  's :=
  #1 'nameptr :=
  s num.names$ 'numnames :=
  numnames 'namesleft :=
  {namesleft #0 >}
     {s nameptr "{vv~}{ll}{~jj}{~ff}"
      format.name$ 't :=
      nameptr #1 >
        {nameptr #4 = numnames #4 > and {"others" 't :=  #1 'namesleft :=} 'skip$ if$
         namesleft #1 >
           {", " * t *} {t "others" = t "~others" = or {bbl.etal *} {bbl.and t * *} if$}
         if$}
        't
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=}
  while$}

FUNCTION{fmt.names}{
  's :=
  #1 'nameptr :=
  s num.names$ 'namesleft :=
  {namesleft #0 >}
     {s nameptr "{vv~}{ll}{~jj}{~ff}"
      format.name$ 't :=
      nameptr #1 > not 't {namesleft #1 > {", " * t *} {bbl.and t * *} if$} if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=}
  while$}

FUNCTION{format.names}{
  's :=
  s empty$ {""}
    {s num.names$ #4 > {s fmt.names.three} {s fmt.names} if$}
  if$}

FUNCTION{format.authors}   {author     empty$ {""} {author     format.names} if$} 

FUNCTION{output.bibitem}{
  set.language
  newline$ "\bibitem" write$
  cite$ bracify write$
  newline$ "\begingroup\selectlanguageifdefined" curlanguage bracify * write$
  newline$ ""
  before.all 'output.state :=}

FUNCTION{format.date}{
  date empty$ not 'date 
    {year empty$ {""} {month empty$ 'year {year ", " format.month * *} if$} if$}
  if$}

FUNCTION{bbl.vol}{
  curlanguage "english" = {"Vol."}
 {curlanguage "german"  = {"Bd."} 
 {curlanguage "russian" = curlanguage "ukrainian" = or {"Т."}
 {"language is not defined: " curlanguage " in bbl.vol" * * warning$ "Vol."}
 if$}if$}if$}

FUNCTION{format.volume}{volume empty$ {""} {bbl.vol volume thinspace.connect} if$}

FUNCTION {bbl.nr}{
  curlanguage "english" = {"no."}
 {curlanguage "german"  = {"nr."} 
 {curlanguage "russian" = curlanguage "ukrainian" = or {"№"}
 {"language is not defined: " curlanguage " in bbl.no" * * warning$ "no."}
 if$}if$}if$}

FUNCTION {bbl.No}{
  curlanguage "english" = {"No."}
 {curlanguage "german"  = {"Nr."} 
 {curlanguage "russian" = curlanguage "ukrainian" = or {"№"}
 {"language is not defined: " curlanguage " in bbl.No" * * warning$ "No."}
 if$}if$}if$}

FUNCTION{format.number}{
  number empty$ {""} 
    {volume empty$ 'bbl.No 'bbl.nr if$ number thinspace.connect}
  if$}

FUNCTION{bbl.lcpages}{
  curlanguage "english" = {"p."} 
 {curlanguage "german"  = {"s."}
 {curlanguage "russian" = curlanguage "ukrainian" = or {"с."}
 {"language is not defined: " curlanguage " in bbl.lcpages" * * warning$ "p."}
 if$}if$}if$}

FUNCTION{bbl.ucpages}{
  curlanguage "english" = {"P."} 
 {curlanguage "german"  = {"S."}
 {curlanguage "russian" = curlanguage "ukrainian" = or {"С."}
 {"language is not defined: " curlanguage " in bbl.ucpages" * * warning$ "P."}
 if$}if$}if$}

FUNCTION{multi.page.check}{
  't :=
  #0 'multiresult :=
  {multiresult not t empty$ not and}
     {t #1 #1 substring$
      duplicate$ "-" = swap$ duplicate$ "," = swap$ "+" = or or
        {#1 'multiresult :=} {t #2 global.max$ substring$ 't :=} if$}
  while$
  multiresult}

FUNCTION{format.pages}{
  pages empty$ {""} 
    {type$ "article" = type$ "inbook" = or type$ "incollection" = or type$ "inproceedings" = or
       {pages multi.page.check {pages n.dashify} 'pages if$
        chapter empty$ 'bbl.ucpages 'bbl.lcpages if$
        swap$ thinspace.connect}
       {pages multi.page.check {pages n.dashify} 'pages if$ bbl.lcpages thinspace.connect}
  if$}if$}

FUNCTION{format.eid.pages}{
   eid empty$ 'format.pages 
     {type empty$ 'eid {type " " eid * *} if$
      pages empty$ 'skip$ 
        {pages multi.page.check
          {", " bbl.lcpages * * pages n.dashify thinspace.connect} 
          {", " pages * * bbl.lcpages thinspace.connect} 
  if$}if$}if$}

FUNCTION{bbl.urldate}{
  curlanguage "english"   = {"online; accessed "}
 {curlanguage "german"    = {"online; abgerufen "}
 {curlanguage "ukrainian" = {"дата звернення: "}
 {curlanguage "russian"   = {"дата обращения: "}
 {"language is not defined: " curlanguage " in bbl.urldate" * * warning$ "online; accessed "}
 if$}if$}if$}if$}

FUNCTION{doi.url}{
  doi empty$
    {url empty$ {""}
       {urldate empty$ {"URL: \url{" url "}" * *}
          {"URL: \url{" url "} (" bbl.urldate urldate ")" * * * * *}
     if$}if$}
    {"DOI: \href{https://doi.org/" doi "}{" doi "}" * * * *}
  if$}

FUNCTION{eprintclass.or.primaryClass}{
  eprintclass empty$ {primaryClass empty$ {""} 'primaryClass if$} 'eprintclass if$}

FUNCTION{eprinttype.or.archivePrefix}{
  eprinttype empty$ {archivePrefix empty$ {""} 'archivePrefix if$} 'eprinttype if$}

FUNCTION{format.eprint}{
  eprint empty$ {""}
    {eprint 's :=
     eprintclass.or.primaryClass empty$ 'skip$ {eprintclass.or.primaryClass "\,/ " s * * 's :=} if$
     eprinttype.or.archivePrefix  empty$ 'skip$  {eprinttype  "\,: " s * * 's :=} if$
     eprinttype.or.archivePrefix "arXiv" = eprinttype.or.archivePrefix "arxiv" = or 
       {"\href{https://arxiv.org/abs/" eprint "}{" s "}" * * * *}
    {doi empty$ not {"\href{https://doi.org/" doi "}{" s "}" * * * *}
    {url empty$ 's  {"\href{" url "}{" s "}" * * * *}
  if$}if$}if$}if$}

FUNCTION{format.issn}{
  issn empty$ {""}
    {"ISSN: \href{https://portal.issn.org/search?search=" issn "}{" issn "}" * * * *} 
  if$}

FUNCTION{format.isbn}{
  isbn empty$ {""}
    {"ISBN: \href{https://isbnsearch.org/isbn/" isbn "}{" isbn "}" * * * *} 
  if$}

FUNCTION{doi.url.other}{
   issn empty$ {"" 's :=} {format.issn 's :=} if$
   isbn empty$    'skip$ 
     {s empty$ {format.isbn   's :=} {s "~; " format.isbn * *   's :=} if$} if$
   doi.url empty$ 'skip$ 
     {s empty$ {doi.url       's :=} {s "~; " doi.url * *       's :=} if$} if$
   eprint empty$  'skip$ 
     {s empty$ {format.eprint 's :=} {s "~; " format.eprint * * 's :=} if$} if$
   s }

FUNCTION{format.title}{
  title empty$ {""}
    {title
     type$ "article" = type$ "inproceedings" = type$ "incollection" = or or 'skip$
       {titleaddon empty$ 'skip$ {"~: "   titleaddon * *    } if$
        media      empty$ 'skip$ {"~: " * media bracketise *} if$}
  if$}if$}

FUNCTION{author.title}{
  author empty$ 'format.title
    {author num.names$ #4 <
       {format.authors emphasize
        title empty$ 'skip$ {add.period$ " " format.title * *} if$}
       {format.title
        type$ "article" = type$ "incollection" = type$ "inproceedings" = or or not 'skip$
          {title empty$ {format.authors emphasize *}
          {add.period$ " " format.authors emphasize * *}
  if$}if$}if$}if$}

FUNCTION{check.author}   {author      empty$ {"empty author in "    cite$ * warning$} 'skip$ if$}
FUNCTION{check.title}    {title       empty$ {"empty title in "     cite$ * warning$} 'skip$ if$}
FUNCTION{check.year}     {format.date empty$ {"empty year in "      cite$ * warning$} 'skip$ if$}
FUNCTION{check.publisher}{publisher   empty$ {"empty publisher in " cite$ * warning$} 'skip$ if$}  
FUNCTION{check.booktitle}{booktitle   empty$ {"empty booktitle in " cite$ * warning$} 'skip$ if$}
FUNCTION{check.type}     {type        empty$ {"empty type in "      cite$ * warning$} 'skip$ if$}

FUNCTION{check.journal}{
  journal empty$ {"empty journal in " cite$ * warning$} 'skip$ if$
  check.author check.year} 

FUNCTION{article}{
  output.bibitem   check.journal
  author.title     output new.dblslash
  journal          output
  series           output new.sentence
  format.date      output new.sentence
  format.volume    output       
  format.number    output new.sentence       
  format.eid.pages output new.sentence  
  note             output new.block
  doi.url.other    output fin.entry}

FUNCTION{bbl.edition}{
  curlanguage "english"   = {"ed."}
 {curlanguage "german"    = {"aus."} 
 {curlanguage "ukrainian" = {"вид."}
 {curlanguage "russian"   = {"изд."}
 {"language is not defined: " curlanguage " in bbl.edition" * * warning$ "ed."}
 if$}if$}if$}if$}

FUNCTION{format.edition}{
  edition empty$ {""}
    {type$ "manual" = 'edition {edition bbl.edition thinspace.connect} if$}
  if$}

FUNCTION{address.or.location}{
  address empty$ {location empty$ {""} 'location if$} 'address if$}

FUNCTION{address.publisher}{
  publisher empty$ 'address.or.location 
    {address.or.location empty$ 'publisher {address.or.location ": " publisher * *} if$}
  if$}

FUNCTION{org.inst.school}{
  organization empty$ {institution empty$ 'school 'institution if$} 'organization if$}

FUNCTION{check.auth.org}{
  type$ "book" = type$ "book" = or
    {author empty$ {""} {author num.names$ #4 < {""} {"no"} if$} if$}
 {type$ "booklet"  = not 'org.inst.school
    {author empty$ 'org.inst.school {author num.names$ #4 < 'org.inst.school {"no"}
  if$}if$}if$}if$}

FUNCTION{bbl.compiler}{
  curlanguage "english"   = {check.auth.org empty$ {"Comp. "} {"comp. "} if$}
 {curlanguage "german"    = {check.auth.org empty$ {"Hrsg. "} {"hrsg. "} if$}
 {curlanguage "ukrainian" = {check.auth.org empty$ {"Укл. "} {"укл. "} if$}
 {curlanguage "russian"   = {check.auth.org empty$ {"Сост. "} {"сост. "} if$}
 {"language is not defined: " curlanguage  " in bbl.compiler" * * warning$ 
                             check.auth.org empty$ {"Comp. "} {"comp. "}
 if$}if$}if$}if$}if$}

FUNCTION{bbl.trans}{
  curlanguage "english" = 
              {check.auth.org empty$ compiler empty$ and {"Transl. "} {"transl. "} if$}
 {curlanguage "german"  = 
              {check.auth.org empty$ compiler empty$ and {"Übersetz. "} {"übersetz. "} if$}
 {curlanguage "ukrainian" = curlanguage "russian" = or
              {check.auth.org empty$ compiler empty$ and {"Пер. "} {"пер. "} if$}
 {"language is not defined: " curlanguage  " in bbl.trans" * * warning$ 
               check.auth.org empty$ compiler empty$ and {"Transl. "} {"transl. "}
 if$}if$}if$}if$
 origlanguage empty$ 'skip$ {origlanguage *} if$}

FUNCTION{bbl.edby}{
  curlanguage "english"   = {check.auth.org empty$ compiler empty$ and translator empty$ and
                               origlanguage empty$ and {"Ed.~by "} {"ed.~by "} if$}
 {curlanguage "german"    = {check.auth.org empty$ compiler empty$ and translator empty$ and
                               origlanguage empty$ and {"Ed.~"} {"ed.~"} if$}
 {curlanguage "ukrainian" = {check.auth.org empty$ compiler empty$ and translator empty$ and
                               origlanguage empty$ and {"За~ред. "} {"за~ред. "} if$}
 {curlanguage "russian"   = {check.auth.org empty$ compiler empty$ and translator empty$ and
                               origlanguage empty$ and {"Под ред. "} {"под ред. "} if$}
 {"language is not defined: " curlanguage " in bbl.edby" * * warning$ 
                             check.auth.org empty$ compiler empty$ translator empty$ and and 
                               origlanguage empty$ and {"Ed.~by "} {"ed.~by "}
 if$}if$}if$}if$}if$}

FUNCTION{format.compiler}  {compiler empty$ {""} {bbl.compiler compiler format.names *} if$}
FUNCTION{format.editor}    {editor   empty$ {""} {bbl.edby     editor   format.names *} if$}
FUNCTION{format.translator}{
  translator empty$ 'bbl.trans {bbl.trans " " translator format.names * *} if$}

FUNCTION{comp.trans.edit}{
  compiler empty$ {"" 's :=} {format.compiler 's :=} if$
  translator empty$ origlanguage empty$ and 'skip$ 
    {s empty$ {format.translator 's :=} {s "~; " format.translator * * 's :=} if$}
  if$
  editor empty$ 'skip$ 
    {s empty$ {format.editor 's :=} {s "~; " format.editor * * 's :=} if$}
  if$ s}

FUNCTION{bbl.of}{
  curlanguage "english" = {" of "}
 {curlanguage "german"  = {" von "}
 {curlanguage "russian" = curlanguage "ukrainian" = or {"~; "}
 {"language is not defined: " curlanguage " in bbl.of" * * warning$ " of "}
  if$}if$}if$}

FUNCTION{volume.series}{
  volume empty$ {""}
    {bbl.vol volume thinspace.connect
      series empty$ 'skip$ {bbl.of series * *} if$
      number empty$ 'skip$ {"can't use both volume and number fields in " * cite$ * warning$}
  if$}if$}

FUNCTION{series.number}{
  volume empty$ not {""}
    {series empty$ 
       {number empty$ {""} 
          {"there's a number but no series in " cite$ * warning$ 
            bbl.No number thinspace.connect} if$}
       {series "~; " *
        number empty$ 'skip$ {number *} if$
        paranthesify}
  if$}if$}

FUNCTION{book.creator}{
  author empty$ 'comp.trans.edit
    {author num.names$ #4 < 'comp.trans.edit 
       {format.authors
        comp.trans.edit empty$ 'skip$ {"~; " comp.trans.edit * *}
  if$}if$}if$}

FUNCTION{check.book}{
  author empty$ editor empty$ compiler empty$ translator empty$ and and and
    {"empty author, compiler, editor and translator in " cite$ * warning$} 'skip$ if$
  check.title check.publisher check.year}

FUNCTION{book}{
  output.bibitem    check.book
  author.title      output new.slash
  book.creator      output new.block
  address.publisher output  
  format.date       output new.semicolon
  format.edition    output new.sentence
  volume.series     output new.sentence
  format.pages      output new.sentence
  series.number     output new.sentence
  note              output new.block
  doi.url.other     output fin.entry}

FUNCTION{bbl.chapter}{
  curlanguage "english" = {"Сh."}
 {curlanguage "german"  = {"Kap."}
 {curlanguage "russian" = curlanguage "ukrainian" = or {"Гл."}
 {"language is not defined: " curlanguage " in bbl.chapter" * * warning$ "Ch."}
 if$}if$}if$}

FUNCTION{chapter.type}{
  chapter empty$ {""}
    {type empty$ 'bbl.chapter 'type if$ chapter thinspace.connect}
  if$}

FUNCTION{check.inbook}{
  pages empty$ chapter empty$ and not 'skip$
    {"empty pages and chapter in " cite$ * warning$} if$
  check.book}

FUNCTION{inbook}{
  output.bibitem    check.inbook
  author.title      output new.slash
  book.creator      output new.block
  address.publisher output  
  format.date       output new.semicolon
  format.edition    output new.sentence
  volume.series     output new.sentence
  chapter.type      output
  format.pages      output new.sentence
  series.number     output new.sentence
  note              output new.block
  doi.url.other     output fin.entry}

FUNCTION{format.booktitle}{
  booktitle empty$ {""}
    {booktitle
     titleaddon empty$ 'skip$ {"~: "   titleaddon * *    } if$
     media      empty$ 'skip$ {"~: " * media bracketise *} if$}
  if$}

FUNCTION{check.incollection}{
  editor empty$ compiler empty$ translator empty$ and and not 'skip$
    {"empty compiler, editor and translator in " cite$ * warning$} if$
  check.booktitle check.author check.publisher check.year}

FUNCTION{incollection}{
  output.bibitem    check.incollection
  author.title      output new.dblslash
  format.booktitle  output new.slash
  comp.trans.edit   output new.block
  address.publisher output   
  format.date       output new.semicolon
  format.edition    output new.sentence
  volume.series     output new.sentence
  chapter.type      output
  format.pages      output new.sentence
  series.number     output new.sentence
  note              output new.block
  doi.url.other     output fin.entry}

FUNCTION{creator}{
  org.inst.school empty$ 'format.editor
    {org.inst.school
     editor empty$ 'skip$ {"~; " format.editor * *} 
  if$}if$}

FUNCTION{check.proceedings}{check.title check.year} 

FUNCTION{proceedings}{
  output.bibitem    check.proceedings
  format.title      output new.slash
  creator           output new.block
  address.publisher output         
  format.date       output new.sentence
  volume.series     output new.sentence
  format.pages      output new.sentence  
  series.number     output new.sentence
  note              output new.block
  doi.url.other     output fin.entry}

FUNCTION{check.inproceedings}{check.proceedings check.booktitle check.author} 

FUNCTION{inproceedings}{
  output.bibitem    check.inproceedings
  author.title      output new.dblslash
  format.booktitle  output new.slash
  creator           output new.block
  address.publisher output       
  format.date       output new.sentence
  volume.series     output new.sentence
  format.pages      output new.sentence  
  series.number     output new.sentence
  note              output new.block
  doi.url.other     output fin.entry}

FUNCTION{conference}{inproceedings}

FUNCTION{address.howpublished}{
  howpublished empty$ 'address.or.location 
    {address.or.location empty$ 'howpublished {address.or.location ": " howpublished * *} if$}
  if$}

FUNCTION{booklet.creator}{
  author empty$ 'creator
    {author num.names$ #4 < 'creator
       {format.authors 
        creator empty$ 'skip$ {"~; " creator * *}
  if$}if$}if$}

FUNCTION{booklet}{
  output.bibitem       check.title
  author.title         output new.slash
  booklet.creator      output new.block
  address.howpublished output
  format.date          output new.sentence
  format.pages         output new.sentence
  note                 output new.block
  doi.url.other        output fin.entry}

FUNCTION{author.title.org}{
  author.title empty$ 'org.inst.school
   {author.title
    org.inst.school empty$ 'skip$ {"~/ " org.inst.school * *} 
  if$}if$}

FUNCTION{manual}{
  output.bibitem      check.title
  author.title.org    output new.block
  address.or.location output
  format.date         output new.semicolon
  format.edition      output new.sentence
  format.pages        output new.sentence
  note                output new.block
  doi.url.other       output fin.entry}

FUNCTION{check.misc}{
  author        empty$ title empty$ date empty$ and and 
  howpublished  empty$ year  empty$ note empty$ and and and
    {"all relevant fields are empty in " cite$ * warning$} 'skip$
  if$}

FUNCTION{misc}{
  output.bibitem check.misc
  author.title   output new.block
  format.date    output new.sentence
  howpublished   output new.sentence
  note           output new.block
  doi.url.other  output fin.entry}

FUNCTION{check.unpublished}{
  note empty$ {"empty note in " cite$ * warning$} 'skip$ if$
  check.author} 

FUNCTION{unpublished}{
  output.bibitem check.unpublished
  author.title   output new.block
  format.date    output new.sentence
  note           output new.block 
  doi.url.other  output fin.entry}

FUNCTION{check.online}{
  doi empty$ url empty$ eprint empty$ and and not 'skip$ 
    {"empty doi, url and eprint in " cite$ * warning$}
  if$}

FUNCTION{online}{
  output.bibitem check.online
  author.title   output new.block
  format.date    output new.sentence
  note           output new.block
  doi.url.other  output fin.entry}
  
FUNCTION{internet}  {online}
FUNCTION{www}       {online}
FUNCTION{webpage}   {online}
FUNCTION{electronic}{online}

FUNCTION{bbl.req}{
  curlanguage "english" = {"req. "}
 {curlanguage "german"  = {"ang. "}
 {curlanguage "russian" = curlanguage "ukrainian" = or {"заявл. "}
 {"language is not defined: " curlanguage " in bbl.req" * * warning$ "req. "}
 if$}if$}if$}

FUNCTION{format.type.number}{type        empty$ {""} {type " " number * *}  if$}
FUNCTION{format.requestdate}{requestdate empty$ {""} {bbl.req requestdate *} if$}
FUNCTION{format.pagetotal}  {pagetotal   empty$ {""} {pagetotal bbl.lcpages thinspace.connect} if$}

FUNCTION {bbl.publ}{
  curlanguage "english" = {"publ. "}
 {curlanguage "german"  = {"ausg. "}
 {curlanguage "russian" = curlanguage "ukrainian" = or {"опубл. "}
 {"language is not defined: " curlanguage " in bbl.publ" * * warning$ "publ. "}
 if$}if$}if$}

FUNCTION{format.publication}{
   publicationdate empty$ {""}
     {publication empty$
        {bbl.publ publicationdate *}
        {bbl.publ publicationdate * ", " * publication *}
   if$}if$}

FUNCTION {bbl.priority}{
  curlanguage "english"   = curlanguage "german" = or {"prior. "}
 {curlanguage "ukrainian" = {"прiор. "}
 {curlanguage "russian"   = {"приор. "}
 {"language is not defined: " curlanguage " in bbl.priority" * * warning$ "Prior. "}
 if$}if$}if$}

FUNCTION{format.priority}{
  prioritynumber  empty$ prioritydate empty$ and {""}
    {prioritydate empty$ 
       {bbl.priority prioritynumber *}
       {bbl.priority prioritydate ", " prioritynumber * * *}
  if$}if$}

FUNCTION{format.requestnumber}{requestnumber empty$ {""} {bbl.No requestnumber thinspace.connect} if$}

FUNCTION{authors.country}{
  author empty$ {""}
    {authorcountry empty$ 'format.authors
       {format.authors " " * authorcountry paranthesify *}
  if$}if$}

FUNCTION{format.patent}{
  type            empty$  {""}  {type} if$
  number          empty$ 'skip$ {" " number * *} if$
  prioritycountry empty$ 'skip$ {" " prioritycountry * *} if$}

FUNCTION{check.patent}{
  number          empty$ {"empty number in "           cite$ * warning$} 'skip$ if$
  prioritycountry empty$ {"empty priority country in " cite$ * warning$} 'skip$ if$
  check.type}

FUNCTION{patent}{
  output.bibitem       check.patent
  format.patent        output
  ipc                  output new.block
  format.title         output new.colon
  format.requestnumber output new.colon
  format.requestdate   output new.colon
  format.publication   output new.colon
  format.priority      output new.slash
  authors.country      output new.semicolon           
  holder               output new.semicolon
  address.or.location  output new.semicolon
  credits              output new.block
  format.pagetotal     output new.sentence
  note                 output new.block
  doi.url.other        output fin.entry }

FUNCTION{bbl.techreport}{
  curlanguage "english"   = {"Rep. "}
 {curlanguage "german"    = {"Bericht "}
 {curlanguage "ukrainian" = {"Звіт "}
 {curlanguage "russian"   = {"Отчет "}
 {"language is not defined: " curlanguage " in bbl.techreport" * * warning$ "Rep. "}
 if$}if$}if$}if$}

FUNCTION{techreport.type}{type empty$ 'bbl.techreport 'type if$}

FUNCTION{bbl.chief}{
  curlanguage "english"   = {org.inst.school empty$ {"Chief "} {"chief "} if$}
 {curlanguage "german"    = {org.inst.school empty$ {"Führ. "} {"führ. "} if$}
 {curlanguage "ukrainian" = {org.inst.school empty$ {"Укл. "} {"укл. "} if$}
 {curlanguage "russian"   = {org.inst.school empty$ {"Рук. "} {"рук. "} if$}
 {"language is not defined: " curlanguage  " in bbl.compiler" * * warning$ 
  org.inst.school empty$ {"Chief "} {"chief "}
 if$}if$}if$}if$}if$}

FUNCTION{bbl.executor}{
  curlanguage "english"   = {org.inst.school empty$ editor empty$ and 
                               {"Exec. "} {"exec. "} if$}
 {curlanguage "german"    = {org.inst.school empty$ editor empty$ and 
                               {"Exek. "} {"exek. "} if$}
 {curlanguage "ukrainian" = {org.inst.school empty$ editor empty$ and 
                               {"Викон. "} {"викон. "} if$}
 {curlanguage "russian"   = {org.inst.school empty$ editor empty$ and 
                               {"Исполн. "} {"исполн. "} if$}
 {"language is not defined: " curlanguage  " in bbl.executor" * * warning$ 
                             org.inst.school empty$ editor empty$ and 
                               {"Exec. "} {"exec. "}
 if$}if$}if$}if$}if$}

FUNCTION{format.chief}   {editor empty$ {""} {bbl.chief    editor format.names *} if$}
FUNCTION{format.executor}{author empty$ {""} {bbl.executor author format.names *} if$}

FUNCTION{inst.chief.exec}{
  org.inst.school empty$ {"" 's :=} {org.inst.school 's :=} if$
  editor empty$ 'skip$ 
    {s empty$ {format.chief 's :=} {s "~; " format.chief * * 's :=} if$}
  if$
  author empty$ 'skip$ 
    {s empty$ {format.executor 's :=} {s "~; " format.executor * * 's :=} if$}
  if$ s}

FUNCTION{check.report}{
  org.inst.school empty$ {"empty institution in " cite$ * warning$} 'skip$ if$
  check.type check.title check.year}

FUNCTION{report}{
  output.bibitem      check.report
  format.title        output new.sentence
  techreport.type     output add.blank
  number              output new.slash
  inst.chief.exec     output new.block
  address.or.location output   
  format.date         output new.sentence
  format.pages        output new.sentence
  note                output new.block
  doi.url.other       output fin.entry}

FUNCTION{techreport}{report}

FUNCTION{check.thesis}{
  school empty$ publisher empty$ and
    {"empty school and publisher in " cite$ * warning$} 'skip$ if$
  check.author check.title check.type check.year}

FUNCTION{thesis}{
  output.bibitem    check.thesis
  format.authors emphasize output new.sentence
  format.title      output new.colon
  type              output new.colon
  specialitycode    output new.slash
  org.inst.school   output new.block
  address.publisher output   
  format.date       output new.sentence
  format.pages      output new.sentence
  note              output new.block
  doi.url.other     output fin.entry}

FUNCTION{mastersthesis}{thesis}
FUNCTION{phdthesis}    {thesis}
FUNCTION{docthesis}    {thesis}

FUNCTION{default.type}{misc}

MACRO{jan}{"Jan."}
MACRO{feb}{"Feb."}
MACRO{mar}{"Mar."}
MACRO{apr}{"Apr."}
MACRO{may}{"May"}
MACRO{jun}{"Jun."}
MACRO{jul}{"Jul."}
MACRO{aug}{"Aug."}
MACRO{sep}{"Sep."}
MACRO{oct}{"Oct."}
MACRO{nov}{"Nov."}
MACRO{dec}{"Dec."}

READ

FUNCTION{sortify}{purify$}

FUNCTION{get.year}{
  year empty$
    {date empty$ {""}
       {date text.length$ #4 < 
         {"wrong format of date in " cite$ * ": date=" * date * warning$ date}
         {curlanguage "russian" = 
            {date date text.length$ #3 - date text.length$ substring$}
            {date #1 #4 substring$}
     if$}if$}if$}
    'year
  if$}

FUNCTION{sort.format.names}{
 's :=
  #1 'nameptr := ""
  s num.names$ 'numnames :=
  numnames 'namesleft :=
 {namesleft #0 >}
 {s nameptr "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}" format.name$ 't :=
  nameptr #1 >
    {"   "  *
     namesleft #1 = t "others" = and {"яяяяя" *}
       {numnames #2 > nameptr #2 = and {"яя" * get.year * "   " *} 'skip$ if$
        t sortify *}
     if$}
    {t sortify *}
  if$
  nameptr #1 + 'nameptr :=
  namesleft #1 - 'namesleft :=}
  while$}

FUNCTION{author.title.sort}{
  author empty$ {title sortify}
 {author num.names$ #4 < {author sort.format.names} 
 {title empty$ {author sort.format.names} {title sortify} 
  if$}if$}if$}

FUNCTION{entry.sort}{
  author  empty$ title empty$ and not 'author.title.sort
 {key empty$ not {key sortify}
 {"to sort, need author or title, or key in " cite$ * warning$ "яяяяя"}
 if$}if$}

FUNCTION{book.sort}{
  author     empty$ title empty$ and not 'author.title.sort
 {compiler   empty$ not {compiler   sort.format.names}
 {translator empty$ not {translator sort.format.names}
 {editor     empty$ not {editor     sort.format.names}
 {key        empty$ not {key sortify}
 {"to sort, need author, or title, or compiler, or translator, or editor, or key in " cite$ * warning$ "яяяяя"}
  if$}if$}if$}if$}if$}

FUNCTION{booklet.sort}{
  author     empty$ title empty$ and not 'author.title.sort
 {org.inst.school empty$ not {org.inst.school sortify}
 {key      empty$ not {key sortify}
 {"to sort, need author or title, or organization, or key in " cite$ * warning$ "яяяяя"}
 if$}if$}if$}

FUNCTION{patent.sort}{
  type empty$ not {type number empty$ 'skip$ {" " number * *} if$  sortify}
 {number          empty$ not {number          sortify}
 {prioritycountry empty$ not {prioritycountry sortify}
 {key             empty$ not {key             sortify}
 {"to sort, need type and number or key in " cite$ * warning$ "яяяяяя"}
 if$}if$}if$}if$}

FUNCTION{report.sort}{
  title  empty$ not {title  sortify}
 {type   empty$ not {type   sortify}
 {number empty$ not {number sortify}
 {key    empty$ not {key    sortify}
 {"to sort, need  title, or type, or number, or key in " cite$ * warning$ "яяяяя"}
 if$}if$}if$}if$}

FUNCTION{proceedings.sort}{
  title  empty$          not {title           sortify}
 {org.inst.school empty$ not {org.inst.school sortify}
 {compiler empty$ not {compiler sort.format.names}
 {editor   empty$ not {editor   sort.format.names}
 {key      empty$ not {key sortify}
 {"to sort, need  title, or series, or compiler, or editor, or key in " cite$ * warning$ "яяяяя"}
 if$}if$}if$}if$}if$}

FUNCTION{presort}{
  type$ "book"        = 'book.sort
 {type$ "booklet"     = 'booklet.sort
 {type$ "patent"      = 'patent.sort
 {type$ "proceedings" = 'proceedings.sort
 {type$ "techreport"  = type$ "report" = or 'report.sort 'entry.sort
 if$}if$}if$}if$}if$
  #1 entry.max$ substring$
  'sort.key$ :=}

ITERATE{presort}
SORT

STRINGS{longest.label}
INTEGERS{number.label longest.label.width}
FUNCTION{initialize.longest.label}{
  "" 'longest.label :=
  #1 'number.label :=
  #0 'longest.label.width :=}

EXECUTE{initialize.longest.label}

FUNCTION{forward.pass}{
  number.label int.to.str$ 'label :=
  number.label #1 + 'number.label :=
  label width$ longest.label.width >
    {label 'longest.label :=
     label width$ 'longest.label.width :=}
    'skip$
  if$}

ITERATE{forward.pass}

FUNCTION{begin.bib}{
  "\begin{thebibliography}{"  longest.label  * "}" *            write$ newline$
  "\providecommand*{\href}[2]{{\small #2}}"                     write$ newline$
  "\providecommand*{\url}[1]{{\small #1}}"                      write$ newline$
  "\let\newblock\ignorespaces"                                  write$ newline$
  "\def\selectlanguageifdefined#1{%"                            write$ newline$
  "\expandafter\ifx\csname date#1\endcsname\relax"              write$ newline$
  "\else\selectlanguage{#1}\fi}"                                write$ newline$
  "\ProvideTextCommandDefault{\cyrdash}{%"                      write$ newline$
  "\iflanguage{russian}{\hbox to.8em{--\hss--}}{\textemdash}}"  write$ newline$
  "\providecommand*{\BibDash}{%"                                write$ newline$
  "\ifdim\lastskip>0pt\unskip\nobreak\hskip.2em plus 0.1em\fi%" write$ newline$
  "\cyrdash\hskip.2em plus 0.1em\ignorespaces}"                 write$ newline$
  preamble$ empty$ 'skip$ {preamble$ write$ newline$}  if$ }

FUNCTION{end.bib}{newline$ "\end{thebibliography}" write$ newline$}

EXECUTE{begin.bib}
EXECUTE{init.state.consts}
ITERATE{call.type$}
EXECUTE{end.bib}

%% End of file `gostds.bst'.
