#!/usr/bin/env icarus
# CBS Bacteria Synonyms 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={
  Name:name
  Synonyms:synonyms
}

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

# fields
  fields:	~ {$In:entry $Out $Skip:1}
                  (/\/[^\n]+\n/ {$Wrt} |
                  word {$Wrt:$fn.$Ct} 
                  (/[\/A-Z]/ {$Not} ln {$App})+)+ ~
 
#indexing
  name:		~ {$In:[fields c:name] $Out}
		  word / /? (word2{$Wrt} | /,.*;/)* ~

  concat: 	~ {$In:[fields c:synonyms] $Out}
                  /[^\n]+/ {$Wrt} '\n' (/[^\n]+/ {$App} '\n')* ~

  synonyms:	~ {$In:concat $Out}
		  word / /? (/;/? / /? word2{$Wrt} | /,/ /[^;]/+)* ~
 
#HTML stuff...
 h_top:      ~ {$In:[fields c:name 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_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_\/]+/ ~
  word2:	~/[ 0-9a-zA-Z_\/.]+/ ~ 
}