%% 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
%% Brief author&year citation style with long author list
%% Version 1
%% --------------------------------------------------------------

ENTRY{
  address         % alias for location
  archivePrefix   % alias for eprinttype
  author
  booktitle
  chapter
  compiler
  date
  doi
  edition
  editor
  eid
  eprint
  eprinttype      % alias for archivePrefix
  eprintclass     % alias for primaryClass
  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
  note
  number
  organization    % alias for institution and school
  origlanguage
  pages
  primaryClass    % alias for eprintclass
  prioritydate
  prioritycountry
  publisher
  school          % alias for institution and organization
  series
  shorttitle
  title
  translator
  type
  url
  urldate
  volume
  year
  }{}{label extra.label sort.label short.list}

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{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"   = {" et~al."}
 {curlanguage "german"    = {" u~a."}
 {curlanguage "ukrainian" = {" та~ін."}
 {curlanguage "russian"   = {" и~др."}
 {"language is not defined: " curlanguage  " in bbl.etal" * * warning$ " et~al."}
 if$}if$}if$}if$}

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

FUNCTION{make.name.list}{
  type$ "book" = type$ "inbook" = or
    {author empty$
       {compiler empty$ not {compiler fmt.names.brief}
          {translator empty$ not {translator fmt.names.brief}
             {editor empty$ {""} {editor fmt.names.brief}
        if$}if$}if$}
       {author fmt.names.brief}
     if$}
    {type$ "proceedings" =
       {compiler empty$ not {compiler fmt.names.brief}
          {editor empty$ {""} {editor fmt.names.brief}
        if$}if$}
       {author empty$ {""} {author fmt.names.brief} if$}
  if$}if$}

FUNCTION {output.bibitem}{
  set.language
  newline$
  "\bibitem[" write$ label write$ ")" make.name.list * "]{" * write$ cite$ write$ "}" write$
  newline$ "\begingroup\selectlanguageifdefined" curlanguage bracify * write$
  newline$ ""
  before.all 'output.state :=}

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{format.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.authors}{author empty$ {""}  {author format.names emphasize} if$}

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

FUNCTION{format.date}{get.year empty$ {""}   {get.year extra.label *} if$}
FUNCTION{add.year}{format.date empty$ 'skip$ {" " format.date paranthesify * *} if$}

FUNCTION{bbl.vol}{
  curlanguage "english"   = {"Vol."}
 {curlanguage "german"    = {"Bd."} 
 {curlanguage "ukrainian" = curlanguage "russian" = 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.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{bbl.pages}{
  curlanguage "english" = {"P."} 
 {curlanguage "german"  = {"S."}
 {curlanguage "russian" = curlanguage "ukrainian" = or {"С."}
 {"language is not defined: " curlanguage " in bbl.pages" * * 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$ "inbook" = type$ "incollection" = or 'chapter.type {""} if$}
    {pages multi.page.check {pages n.dashify} 'pages if$
     bbl.pages swap$  thinspace.connect}
  if$}

FUNCTION{format.eid.pages}{
  eid empty$ not 'eid {pages empty$ {""} 'format.pages if$} if$}

INTEGERS{link.exists}
  
FUNCTION{open.link}{
  #0 'link.exists :=
  doi  empty$ not {#1 'link.exists := "\href{https://doi.org/" doi "}{" * *}
 {url  empty$ not {#1 'link.exists := "\href{" url "}{" * *}
 {type$ "book" = type$ "inbook" = type$ "incollection" = type$ "booklet" =
  type$ "proceedings" = type$ "inproceedings" = or or or or or isbn empty$ not and
    {#1 'link.exists := "\href{https://isbnsearch.org/isbn/" isbn "}{" * *}
 {type$ "article" = type$ "proceedings" = type$ "inproceedings" = or or issn empty$ not and
    {#1 'link.exists := "\href{https://portal.issn.org/search?search=" issn "}{" * *} {""}
 if$}if$}if$}if$}

FUNCTION{close.link}{link.exists #0 > {"}"} {""} if$}

FUNCTION{author.or.title.year}{
  author empty$ title empty$ and {""}
    {author empty$ {title add.year 's :=} {format.authors add.year 's :=} if$
     type$ "article" = {open.link s close.link * *} 's 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.or.title.year output new.dblslash
  journal              output
  series               output new.sentence
  format.volume        output       
  format.number        output new.sentence       
  format.eid.pages     output fin.entry}

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

FUNCTION{bbl.compiler}{
  curlanguage "english"   = {org.inst.school empty$ {"Comp. "} {"comp. "} if$}
 {curlanguage "german"    = {org.inst.school empty$ {"Hrsg. "} {"hrsg. "} 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$ {"Comp. "} {"comp. "}
 if$}if$}if$}if$}if$}

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

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

FUNCTION{bbl.ucedby}{
  curlanguage "english"   = {"Ed.~by "}
 {curlanguage "german"    = {"Ed.~"}
 {curlanguage "ukrainian" = {"За~ред. "}
 {curlanguage "russian"   = {"Под ред. "}
 {"language is not defined: " curlanguage " in bbl.ucedby" * * warning$ {"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{print.editor}     {editor     empty$ {""} {bbl.ucedby editor     format.names *} if$}
FUNCTION{format.translator}{
  translator empty$ 'bbl.trans {bbl.trans " " translator format.names * *} if$}

FUNCTION{comp.trans.edit}{
  author empty$ not type$ "book" = type$ "inbook" = or and {""}
    {compiler empty$ {"" 's :=} {format.compiler 's :=} if$
    translator empty$ '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}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{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.num.series}{
  volume empty$
    {number empty$ {""}
       {series empty$ not {series "~; " number * *}
          {"there's a number but no series in " cite$ * warning$ 
            bbl.No number thinspace.connect}
     if$}if$}
    {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{format.title}{
  title empty$ {""}
    {title 's :=
     media      empty$ 'skip$ {s "~; " * media bracketise * 's :=} if$
     type$ "online" = type$ "patent" = or {s} {open.link s close.link * *} if$}
  if$}

FUNCTION{add.title}{title empty$ 'skip$ {add.period$ " " format.title * *} if$}

FUNCTION{author.title.year}{
  author empty$ title empty$ and  {""}
    {author empty$ not {format.authors add.year add.title} {format.title add.year}
 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.year output new.slash
  comp.trans.edit   output new.block
  address.publisher output new.sentence 
  volume.num.series output fin.entry}

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$}if$}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.year output new.slash
  comp.trans.edit   output new.block
  address.publisher output new.sentence 
  volume.series     output new.sentence
  format.pages      output new.sentence 
  series.number     output fin.entry}

FUNCTION{format.booktitle}{
  booktitle empty$ {""}
    {booktitle 's :=
     media      empty$ 'skip$ {s "~: " * media bracketise * 's :=} if$
     open.link s close.link * *}
  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.or.title.year output new.dblslash
  format.booktitle     output new.slash
  comp.trans.edit      output new.sentence
  address.publisher    output new.sentence
  volume.series        output new.sentence
  format.pages         output new.sentence 
  series.number        output fin.entry}

FUNCTION{title.year}{
    title empty$ {""} {format.title add.year} if$}

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

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

FUNCTION{proceedings}{
  output.bibitem    check.proceedings
  title.year        output new.slash
  creator           output new.block
  address.publisher output new.sentence 
  volume.num.series output fin.entry}

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

FUNCTION{inproceedings}{
  output.bibitem       check.inproceedings
  author.or.title.year output new.dblslash
  format.booktitle     output new.slash
  creator              output new.block
  address.publisher    output new.sentence
  volume.series        output new.sentence
  format.pages         output new.sentence 
  series.number        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 {""} if$}

FUNCTION{booklet}{
  output.bibitem       check.title
  author.title.year    output new.slash
  booklet.creator      output new.block
  address.howpublished output fin.entry}

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

FUNCTION{format.edition}{edition empty$ {""} 'edition if$}

FUNCTION{manual}{
  output.bibitem        check.title
  author.org.title.year output new.block
  address.or.location   output new.sentence
  format.edition        output fin.entry}

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{eprint.or.howpublished}{eprint empty$ 'howpublished 'format.eprint if$}

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.year      output new.block
  eprint.or.howpublished output new.sentence
  note                   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.year output new.block
  note              output fin.entry}

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{doi.url.eprint}{
  doi empty$ url empty$ eprint empty$ and and {""}
    {doi empty$ url empty$ and 'format.eprint 'doi.url if$}
  if$}

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.year output new.block
  doi.url.eprint    output fin.entry}

FUNCTION{internet}  {online}
FUNCTION{www}       {online}
FUNCTION{webpage}   {online}
FUNCTION{electronic}{online}

FUNCTION{format.patent}{
  type            empty$  {"" 's :=}  {type 's :=} if$
  number          empty$ 'skip$ {s " " number * * 's :=} if$
  prioritycountry empty$ 'skip$ {s " " prioritycountry * * 's :=} if$
  open.link s close.link * *}

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
  author.title.year output new.sentence
  format.patent     output
  ipc               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{format.org.inst.school}{
  org.inst.school empty$ {"empty institution in " cite$ * warning$ ""} 'org.inst.school if$}

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
  author.title.year      output new.sentence
  techreport.type        output add.blank
  number                 output new.slash
  format.org.inst.school output new.block
  address.or.location    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{mastersthesis}{
  output.bibitem    check.thesis
  author.title.year output new.colon
  type              output new.slash
  org.inst.school   output new.block
  address.publisher output fin.entry}

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

FUNCTION{default.type}{misc}

READ

FUNCTION{sortify}{purify$}

INTEGERS{len}

FUNCTION{format.names.label}{
  's :=
  set.language
  s #1 "{vv~}{ll}" format.name$
  s num.names$ duplicate$ #2 > {pop$ bbl.etal *}
    {#2 < 'skip$
       {s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
          {bbl.etal *}
          {", " * s #2 "{vv~}{ll}" format.name$ *}
  if$}if$}if$}

FUNCTION{proc.label}{
  shorttitle      empty$ not {shorttitle " \dots~" *}
 {title           empty$ not 'title
 {org.inst.school empty$ not 'org.inst.school
 {key             empty$ not 'key {cite$ #1 entry.max$ substring$}
 if$}if$}if$}if$}

FUNCTION{booklet.label}{author empty$ 'proc.label {author format.names.label} if$}

FUNCTION{book.label}{
  author     empty$ not {author     format.names.label}
 {shorttitle empty$ not {shorttitle " \dots~" *}
 {title      empty$ not 'title
 {compiler   empty$ not {compiler   format.names.label}
 {translator empty$ not {translator format.names.label}
 {editor     empty$ not {editor     format.names.label}
 {key        empty$ not 'key {cite$ #1 entry.max$ substring$}
 if$}if$}if$}if$}if$}if$}if$}

FUNCTION{author.title.label}{
  author     empty$ not {author format.names.label}
 {shorttitle empty$ not {shorttitle " \dots~" *}
 {title      empty$ not 'title
 {key        empty$ not 'key {cite$ #1 entry.max$ substring$}
 if$}if$}if$}if$}

FUNCTION{author.title.type.label}{
  author          empty$ not {author format.names.label}
 {shorttitle      empty$ not {shorttitle " \dots~" *}
 {title           empty$ not 'title
 {type empty$ not {number empty$ 'type {type number thinspace.connect} if$}
 {number          empty$ not 'number
 {key             empty$ not 'key {cite$ #1 entry.max$ substring$}
 if$}if$}if$}if$}if$}if$}

FUNCTION{make.label}{
  type$ "proceedings" = 'proc.label 
 {type$ "book"   = type$ "inbook"      = or 'book.label
 {type$ "patent" = type$ "techreport"  = type$ "report" = or or 'author.title.type.label
 {type$ "booklet" = type$ "manual" = or 'booklet.label 'author.title.label
 if$}if$}if$}if$
  "(" * get.year * 'label :=}

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 {"zzzzz" *}
       {numnames #2 > nameptr #2 = and {"zz" * get.year * "   " *} 'skip$ if$
        t sortify *}
     if$}
    {t sortify *}
  if$
  nameptr #1 + 'nameptr :=
  namesleft #1 - 'namesleft :=}
  while$}

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

FUNCTION{author.title.type.sort}{
  author          empty$ not {author sort.format.names}
 {title           empty$ not {title            sortify}
 {type empty$ not {type number empty$ 'skip$ {" " number * *} if$  sortify}
 {number          empty$ not {number           sortify}
 {key             empty$ not {key              sortify}
 {"to sort, need authot or title or type and number or key in " cite$ * warning$ "яяяяяя"}
 if$}if$}if$}if$}if$}

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

FUNCTION{author.title.org.sort}{
  author          empty$ not {author sort.format.names}
 {title           empty$ not {title            sortify}
 {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$}if$}

FUNCTION{entry.sort}{
  type$ "proceedings" = 'title.org.sort  
 {type$ "patent" = type$ "techreport"  = type$ "report" = or or 'author.title.type.sort
 {type$ "booklet" = type$ "manual" = or 'author.title.org.sort 'author.title.sort
 if$}if$}if$}
  
FUNCTION{presort}{
  set.language
  make.label
  label sortify "    " *
  entry.sort "    " * get.year sortify * "    " * cite$ sortify *
  #1 entry.max$ substring$
  'sort.label :=
  sort.label *
  #1 entry.max$ substring$
  'sort.key$ :=}

ITERATE{presort}
SORT
STRINGS {longest.label       last.label     next.extra}
INTEGERS{longest.label.width last.extra.num number.label}

FUNCTION{initialize.longest.label}{
  "" 'longest.label :=
  #0 int.to.chr$ 'last.label :=
  "" 'next.extra :=
  #0 'longest.label.width :=
  #0 'last.extra.num :=
  #0 'number.label :=}

FUNCTION{forward.pass}{
  last.label label =
    {last.extra.num #1 +        'last.extra.num :=
     last.extra.num int.to.chr$ 'extra.label    :=}
    {"1" chr.to.int$            'last.extra.num :=
     ""                         'extra.label    :=
     label 'last.label :=}
  if$
  number.label #1 + 'number.label :=}

FUNCTION{reverse.pass}{
  next.extra "2" = {"1" 'extra.label :=} 'skip$ if$
  extra.label 'next.extra :=
  extra.label duplicate$ empty$ 'skip$ {"{\natexlab{:" swap$ * "}}" *} if$ 'extra.label :=
  label extra.label * 'label :=}

FUNCTION {bib.sort.order}{sort.label 'sort.key$ :=}

EXECUTE{initialize.longest.label}
ITERATE{forward.pass}
REVERSE{reverse.pass}
ITERATE{bib.sort.order}
SORT

FUNCTION{begin.bib}{
  "\begin{thebibliography}{"  longest.label  * "}" *            write$ newline$
  "\providecommand*{\href}[2]{{\small #2}}"                     write$ newline$
  "\providecommand*{\url}[1]{{\small #1}}"                      write$ newline$
  "\providecommand{\natexlab}[1]{#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 `gostlns.bst'.
