#!/usr/bin/env icarus
# DSMZ Literature Catalogue - Syntax file
# Version 2004.12.17.01
# Last Updated December 17, 2004
# Author: Domenico Marra & Francesca Piersigilli & Paolo Romano
# (c) CABRI 1999-2023

$fn={
  DSM_lit_no:dsm_lit_no
  Authors:authors
  Title:title
  Journal:journal
  Volume:volume
  Pages:pages
  Year:year
  Editor:editor
  Publisher:publisher
  PubMed_ID:pubmedid
}

$rules={
  entry:	~ {$In:[file:text] $Out pre $Skip:0}
		  ('DSM_lit_no' {$Not} ln)*
		  ('DSM_lit_no' {$entryFip=$Fip $Wrt} ln {$App}
		  ('DSM_lit_no' {$Not} ln {$App})*)?
		~

# fields
  fields:	~ {$In:entry $Out $Skip:1}
                  (/\/[^\n]+\n/ {$Wrt} |
                  word {$Wrt:$fn.$Ct} 
                  (/[\/A-Z]/ {$Not} ln {$App})+)+ ~
 
#indexing
  dsm_lit_no:	~ {$In:[fields c:dsm_lit_no] $Out}
		  	word (str{$Wrt} |punct)* ~
  
  strX:		~ {$In:[fields c:{authors title journal 
				  volume pages year 
				  editor publisher pubmedid}] $Out}
		  word (str{$Uniq:$Itc}| /./ |punct)* ~
 
#HTML stuff...
 h_top:      ~ {$In:[fields c:dsm_lit_no t:html] pre if:$ParInt:isTable $Fail}
               word {$Rep:
                     |</TR><TR VALIGN=TOP>
                     |<TD colspan=2 bgcolor=\"#ffffff\">
                     |<font color=\"#000066\">
                     |<B>CABRI:($entry.libName)</B></TD>
                     |</TR>
		     |<TR VALIGN=TOP><TD bgcolor=\"#ffffff\">
                     |<font color=\"#000066\"><b><i>$Ct</i></b></font></TD>
                     |<TD bgcolor=\"#ffffff\">
		    } ':'? {$Rep:""} /.*/ {$Rep:"$Ct</TD></TR>"}  ~

 h_pubmedid:    ~ {$In:[fields c:pubmedid t:html] pre if:$ParInt:isTable $Fail}
                  'PubmedId' {if:$isTable==0
                        $Rep:
                        |<TR valign=top><TD bgcolor=\"#ffffff\">
                        |<font color=\"#000066\">
                        |<b><i>$Ct</i></b></font></TD>
                        |<TD bgcolor=\"#ffffff\">
                      }
                      ' '* pmid {$Rep:$Hlink:[pubmedCabriR p:{$Ct $Ct}]} ~

 h_fields:      ~ {$In:[fields t:html] pre if:$ParInt:isTable $Fail}
                   word {if:$isTable==0
                     $Rep:
                       |<TR VALIGN=TOP><TD bgcolor=\"#ffffff\">
                       |<font color=\"#000066\"><b><i>$Ct</i></b></font></TD>
                       |<TD bgcolor=\"#ffffff\">
                     } ':'? {$Rep:""} /.*/ {$Rep:"$Ct</TD></TR>"}  ~

 t_fields:     ~ {$In:[fields] $Out} tag /.*/ {$Wrt:$Itc} ~

# definitions
  tag:          ~ word ':'?~
  ln:		~/[^\n]*\n/ ~
  word:		~/[0-9a-zA-Z_\/]+/ ~
  str:		~/[a-zA-Z0-9&.'=\/\\%_-]+/ ~
  punct:	~ /[ \t]+/ ~
  pmid:		~/[0-9]+/ ~
}