#!/usr/local/bin/perl
# -*-Perl-*-
# lsl2html
# $Id: lsl2html,v 1.6 2001/02/02 21:03:18 connolly Exp $
#
# based on
# http://www.ececs.uc.edu/~kbse/lsl2html/
# by John Penix
# University of Cincinnati KBSE Lab
# jpenix@ece.uc.edu
#
#
# Given Trait.lsl as an argument, the program creates the file
# Trait.html in the current directory. There is also an option (-I) to
# create an index for a directory.
#
#
# Trait Names
#
# The current version of the program uses a brute force method for
# determining trait names, as opposed to the syntax of the language.
# The directories in the LARCH_PATH environment variable are searched to
# find all visible trait names. The When one of these names is found in
# the file, it is turned into a hyperlink.
#
#
# URLs
#
# Each directory in LARCH_PATH has a URL associated with it. There
# are three case for determining the URL for a directory:
#
# 1. The first line of the file .lsl2htmlURL in each LARCH_PATH
# directory is checked for a URL. The URL should end in a slash,
# without quotes:
#
# http://www.aaa.bbb/ddd/eee/fff/
# or
# file:/www.aaa.bbb/ddd/eee/fff/
#
# 2. For the current directory ("." must be in LARCH_PATH) then
# relative referenceing is used, i.e. the URL is just the filename.
# This assumes that all of the HTML files created for the LSL files in
# the current directory will also be kept together in one directory.
#
# 3. If there is no .lsl2htmlURL file in the directory, then the URL
# becomes file:DIRECTORY/, there DIRECTORY is the entry from
# LARCH_PATH.
#
#
# Examples
#
# % lsl2html Trait.lsl
#
# Trait.html is created in the current directory.
#
# % lsl2html *.lsl
#
# HTML file is created for every .lsl file in the current directory.
#
# % lsl2html -I
#
# Creates an index referencing all of the HTML files for all
# of the .lsl files in the directory. Notice that the .lsl files must
# be present for a trait to be recognized.
#
# % lsl2html -I *.lsl
#
# Creates HMTL files and an index for all .lsl files in the
# directory.
#
# keyword regular expression
# note: putting \ before forall causes problem with word boundary match
$keyword = "forall|trait|includes|assumes|introduces|asserts|implies|converts|partitioned by|generated by|for|if|then|else|tuple of|union of|exempting|equations";
# makepretty
# make keyword boldface
sub makepretty {
local ($out) = @_;
# boldface keywords
$out =~ s#\b($keyword)\b#$1#g;
$out;
}
sub generateINDEX {
@_ = sort(@_);
open(INDEX,"> index.html");
print INDEX "