#!/usr/bin/env icarus
# BCCM/IHEM 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:syn
Alternate_state:alt_st
}
$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} | punct2) ~
concat: ~ {$In:[fields c:syn] $Out}
/[^\n]+/ {$Wrt} '\n' (/[^\n]+/ {$App} '\n')* ~
concat2: ~ {$In:[fields c:alt_st] $Out}
/[^\n]+/ {$Wrt} '\n' (/[^\n]+/ {$App} '\n')* ~
syn: ~ {$In:concat $Out}
word / /?
(/;/? / /? word2{$Wrt:[s:$StrRep:[s:$Ct r:"[\/|\.|-]" to:""]]}
| /,/ /[^;]/+)* ~
alt_st: ~ {$In:concat2 $Out}
word / /? ('-' | (/;/? / /? word1{$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_\/]+/ ~
word1: ~/[ 0-9a-zA-Z]+/ ~
word2: ~/[ 0-9a-zA-Z_:\\.\\(\\)\/-]+/ ~
word3: ~/[ 0-9a-zA-Z]+/ ~
num: ~/[0-9.]+/ ~
str: ~/[a-zA-Z0-9&.'=\/\\%_-]+/ ~
punct: ~ /[ \t]+/ ~
punct2: ~ /[ \t,;:\\(\\)\\.\\+\\*]+/ ~
}