/* Copyright (C) 2003, 2004 Dave Bayer. Subject to the terms and conditions of the MIT License. */
#include "root.h"
#include "file.h"
#include "filter.h"
#include "rules.h"
/*. sourceTable */
filterRules *sourceTable[docNStates][NCHARS];
/*. sourceRules */
filterRules sourceRules[] =
{
/* leading blank states */
{ " ", 0, docStart, docStart },
{ "\t", 0, docStart, docStart },
{ "\n", 0, docStart, docStart, mergeBlank },
{ "\n", 0, docPrint, docStart },
{ "", 0, docStart, docPrint },
/* comment states */
{ "//.", 0, docStart, docPrint, mergeGlobal },
{ "/*.", 0, docStart, docPrint, mergeGlobal },
{ "//,", 0, docStart, docPrint, mergeLocal },
{ "/*,", 0, docStart, docPrint, mergeLocal },
{ "//", 0, docStart, docPrint, mergeTag },
{ "/*", 0, docStart, docPrint, mergeTag },
{ 0 }
};
/*. docTable */
filterRules *docTable[docNStates][NCHARS];
/*. docRules */
filterRules docRules[] =
{
/* command states */
{ "//@", 0, docStart, docCmd },
{ " ", 0, docCmd, docCmd },
{ "\t", 0, docCmd, docCmd },
{ "", 0, docCmd, docFile, mergeCmd },
{ "\n", 0, docFile, docStart },
{ ".html\n", 0, docFile, docStart, mergeHtml },
/* quote states */
{ "\"", "", docStart, docQuote },
{ "\"", "", docPrint, docQuote },
{ "\"", "", docQuote, docPrint },
{ "\\\"", "\"", docStart, docPrint },
{ "\\\"", "\"", docPrint, docPrint },
{ "\\\"", "\"", docQuote, docQuote },
{ "\\\\", "\\", docStart, docPrint },
{ "\\\\", "\\", docPrint, docPrint },
{ "\\\\", "\\", docQuote, docQuote },
/* pre states */
{ " \n", parStart, parPar },
{ " ", 0, parPar, parPar },
{ "\t", 0, parPar, parPar },
{ "\n", "", 0, docStart, docPre },
{ "", 0, dictSampSQuote, dictStart },
{ "", 0, dictSampDQuote, dictStart },
{ "", 0, dictSamp, dictSamp },
{ "", 0, dictSamp, dictSamp },
{ "'", 0, dictSamp, dictSampSQuote },
{ "'", 0, dictSampSQuote, dictSamp },
{ "\"", 0, dictSamp, dictSampDQuote },
{ "\"", 0, dictSampDQuote, dictSamp },
{ "\\'", 0, dictSamp, dictSamp },
{ "\\'", 0, dictSampSQuote, dictSampSQuote },
{ "\\'", 0, dictSampDQuote, dictSampDQuote },
{ "\\\"", 0, dictSamp, dictSamp },
{ "\\\"", 0, dictSampSQuote, dictSampSQuote },
{ "\\\"", 0, dictSampDQuote, dictSampDQuote },
/* pre rules */
{ "", 0, docStart, docPre },
{ "", 0, docStart, docPre },
{ "", 0, docPrint, docPre },
{ "", 0, docPrint, docPre },
{ "", 0, docPrint, docPre },
{ "", 0, docPre, docPrint },
/* HTML delimiter states */
{ "<", 0, docPrint, docHtml },
{ ">", 0, docHtml, docPrint },
{ "\"", 0, docHtml, docHtmlQuote },
{ "\"", 0, docHtmlQuote, docHtml },
{ 0 }
};
/*. htmlTable */
filterRules *htmlTable[htmlNStates][NCHARS];
/*. htmlRules */
filterRules htmlRules[] =
{
/* leading blank states */
{ " ", 0, htmlDocStart, htmlDocStart },
{ "\t", 0, htmlDocStart, htmlDocStart },
{ "\n", 0, htmlDocStart, htmlDocStart },
{ "\n", 0, htmlDoc, htmlDocStart },
{ "", 0, htmlDocStart, htmlDoc },
{ " ", 0, htmlPreStart, htmlPreStart },
{ "\t", 0, htmlPreStart, htmlPreStart },
{ "\n", 0, htmlPreStart, htmlPreStart },
{ "\n", 0, htmlPre, htmlPreStart },
{ "", 0, htmlPreStart, htmlPre },
/* code, samp, pre elements */
{ "", 0, htmlDoc, htmlCode },
{ "", 0, htmlCode, htmlDoc },
{ "", 0, htmlDoc, htmlSamp },
{ "", 0, htmlSamp, htmlDoc },
{ "", 0, htmlDocStart, htmlPreStart },
{ "", 0, htmlDocStart, htmlPreStart },
{ "", 0, htmlDocStart, htmlPreStart },
{ "\n", 0, htmlPre, htmlDocStart },
/* allow strong element to enclose lines within pre elements */
{ "", 0, htmlPreStart, htmlPreStrong },
{ "\n", 0, htmlPreStrong, htmlPreStart },
/* html escape sequences */
{ "<", "<", htmlCode, htmlCode },
{ ">", ">", htmlCode, htmlCode },
{ "&", "&", htmlCode, htmlCode },
{ "<", "<", htmlSamp, htmlSamp },
{ ">", ">", htmlSamp, htmlSamp },
{ "&", "&", htmlSamp, htmlSamp },
{ "<", "<", htmlPre, htmlPre },
{ ">", ">", htmlPre, htmlPre },
{ "&", "&", htmlPre, htmlPre },
{ "<", "<", htmlPreStrong, htmlPreStrong },
{ ">", ">", htmlPreStrong, htmlPreStrong },
{ "&", "&", htmlPreStrong, htmlPreStrong },
{ 0 }
};
/*. parTable */
filterRules *parTable[parNStates][NCHARS];
/*. parRules */
filterRules parRules[] =
{
{ "", 0, parStart, parOff },
{ "", 0, parOff, parStart },
{ " ", 0, parStart, parStart },
{ "\t", 0, parStart, parStart },
{ "\n", 0, parStart, parStart },
{ "", "
", 0, parStart, parStart },
/* rules for entering block-level elements */
{ "\n
\n
\n
\n
", 0, parSkip, parStart },
{ "", 0, parSkip, parStart },
{ "", 0, parSkip, parStart },
{ "
", 0, parSkip, parStart },
{ "", 0, parSkip, parStart },
{ "", 0, parSkip, parStart },
{ "", 0, parSkip, parStart },
{ "", 0, parSkip, parStart },
{ "", 0, parSkip, parStart },
{ "", 0, parSkip, parStart },
{ 0 }
};
/*. dictTable */
filterRules *dictTable[dictNStates][NCHARS];
/*. dictRules */
filterRules dictRules[] =
{
/* code rules */
{ "", 0, dictStart, dictCode },
{ "", 0, dictCode, dictStart },
{ "", 0, dictCodeSQuote, dictStart },
{ "", 0, dictCodeDQuote, dictStart },
{ "", 0, dictCode, dictCode },
{ "", 0, dictCode, dictCode },
{ "'", 0, dictCode, dictCodeSQuote },
{ "'", 0, dictCodeSQuote, dictCode },
{ "\"", 0, dictCode, dictCodeDQuote },
{ "\"", 0, dictCodeDQuote, dictCode },
{ "\\'", 0, dictCode, dictCode },
{ "\\'", 0, dictCodeSQuote, dictCodeSQuote },
{ "\\'", 0, dictCodeDQuote, dictCodeDQuote },
{ "\\\"", 0, dictCode, dictCode },
{ "\\\"", 0, dictCodeSQuote, dictCodeSQuote },
{ "\\\"", 0, dictCodeDQuote, dictCodeDQuote },
/* samp rules */
{ "", 0, dictStart, dictSamp },
{ "", 0, dictSamp, dictStart },
{ "
", 0, dictStart, dictPre },
{ "", 0, dictStart, dictPre },
{ "", 0, dictStart, dictPre },
{ "", 0, dictPre, dictStart },
{ "", 0, dictPreSQuote, dictStart },
{ "", 0, dictPreDQuote, dictStart },
{ "", 0, dictPre, dictPre },
{ "", 0, dictPre, dictPre },
{ "'", 0, dictPre, dictPreSQuote },
{ "'", 0, dictPreSQuote, dictPre },
{ "\"", 0, dictPre, dictPreDQuote },
{ "\"", 0, dictPreDQuote, dictPre },
{ "\\'", 0, dictPre, dictPre },
{ "\\'", 0, dictPreSQuote, dictPreSQuote },
{ "\\'", 0, dictPreDQuote, dictPreDQuote },
{ "\\\"", 0, dictPre, dictPre },
{ "\\\"", 0, dictPreSQuote, dictPreSQuote },
{ "\\\"", 0, dictPreDQuote, dictPreDQuote },
{ 0 }
};