home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / sgml / unix / sgmlc / arclexrf.c next >
Encoding:
Text File  |  1991-07-03  |  31.8 KB  |  598 lines

  1. /******************************************************************************/
  2. /* ARCLEXRF: Lexical tables for reference concrete syntax.
  3. */
  4. /*lint -library                  Ignore failure to use library functions. */
  5. #include <stdio.h>            /* Stream I/O functions. */
  6. /*lint -restore                  End of library function declarations. */
  7. #include "entity.h"           /* Templates for entity control blocks. */
  8. #include "synxtrn.h"          /* Declarations for concrete syntax constants. */
  9. #include "action.h"           /* Action names for all parsing. */
  10. #include "adl.h"              /* Definitions for attribute list processing. */
  11. /******************************************************************************/
  12. /* LEXCNM: Lexical table for mixed content (PCBCONM) parse.
  13. */
  14. /* Symbols for SGML character set divisions and function characters. */
  15. #define FRE     0   /* FREECHAR that is not in a CON delimiter-in-context. */
  16. #define NU      1   /* NUMERAL            Numerals */
  17. #define NMC     2   /* LC/UCNMCHAR . -    Period and hyphen */
  18. #define NMS     3   /* LC/UCNMSTRT        Lower and uppercase letters */
  19. #define SPC     4   /* SPACE     32       Space */
  20. #define NON     5   /* NONSGML   0-31 127 255 Unused, except for: */
  21. #define EE      6   /* NONSGML   00 26    Entity end (end of file) */
  22. #define EOB     7   /* NONSGML   28       End disk buffer */
  23. #define RS      8   /* Function  10       Line feed */
  24. #define RE      9   /* Function  13       Carrier return */
  25. #define SEP    10   /* SEPCHAR   09       TAB: horizontal tab */
  26. #define CDE    11   /* NONSGML   delcdata CDATA/SDATA delimiter */
  27. #define NSC    12   /* NONSGML   delnonch Non-SGML character prefix */
  28.  
  29. /* Symbols for SGML delimiter roles in CON and CXT.
  30.    ETI and NET must be the same in LEXCNM and LEXCON.
  31.    FRE characters are changed to FCE if an FCE entity is declared.
  32.    They are changed back to FRE when the entity is canceled.
  33. */
  34. #define ERO    13   /* &    Also CRO[1] */
  35. #define NMRE   14   /* 08   Generated non-markup RE */
  36. #define COM    15   /* -    For MDO context; also SR19 and SR20. */
  37. #define ETI    16   /* /    Actually ETAGO[2] */
  38. #define NET    17   /* /    When enabled. */
  39. #define LIT1   18   /* "    SR10 */
  40. #define SPCR   19   /* Space in use as SR8. */
  41. #define MDO    20   /* !    Actually MDO[2] */
  42. #define MSC1   21   /* ]    Both MSC[1] and MSC[2]; also SR26. */
  43. #define MSO    22   /* [    For MDO context; also SR25. */
  44. #define PIO    23   /* ?    Actually PIO[2] */
  45. #define RNI    24   /* #    For CRO[2]; also SR11. */
  46. #define TGC1   25   /* >    For TAGO and MSC context; also MDC, PIC */
  47. #define TGO1   26   /* <    TAGO; also MDO[1], PIO[1] */
  48. #define FCE    27   /* FRE  Free character in use as an entity reference */
  49.  
  50. char    lexcnm[256] = { /*
  51. 000  001                          bs   tab  lf   home ff   cr   so   si   */
  52. EE,  NON, NON, NON, NON, NON, NON, NON, NMRE,SEP, RS,  NON, NON, RE,  NON, NON, /*
  53.                                         eof  esc  rt   left up   down */
  54. NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE,  NON, EOB, NON, NON, NON, /*
  55. 032  !    "    #    $    %    &    '    (    )    *    +    ,    -    .    /    */
  56. SPC, MDO, LIT1,RNI, FRE, FRE ,ERO, FRE, FRE, FRE, FRE, FRE, FRE, COM, NMC, ETI, /*
  57. 0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ?    */
  58. NU , NU , NU , NU , NU , NU , NU , NU , NU , NU , FRE, FRE, TGO1,FRE, TGC1,PIO, /*
  59. @    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O    */
  60. FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  61. P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _    */
  62. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, MSO, FRE, MSC1,FRE, FRE, /*
  63. `    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o    */
  64. FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  65. p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~    127  */
  66. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, FRE, FRE, FRE, FRE, NON,
  67. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  68. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  69. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  70. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  71. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  72. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  73. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  74. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, NON
  75. };
  76. /*      free nu   nmc  nms  spc  non  ee   eob  rs   re   sep  cde  nsc  ero
  77.         nmre com  eti  lit  spcr mdo  msc  mso  net  pio  rni  tagc tago fce   */
  78. #undef ERO
  79. #undef NMRE
  80. #undef COM
  81. #undef ETI
  82. #undef NET
  83. #undef LIT1
  84. /* def SPCR*/
  85. #undef MDO
  86. #undef MSC1
  87. #undef MSO
  88. #undef PIO
  89. #undef RNI
  90. #undef TGC1
  91. /* def TGO1*/
  92. /* def FCE*/
  93. /******************************************************************************/
  94. /* LEXCON: Lexical table for RCDATA and CDATA content (PCBCON?),
  95.            prolog (PCBPRO), and nested declaration set (PCBMDS) parses.
  96.    Note: NMC is same as FRE; kept for consistency with LEXCNM and LEXLMS.
  97. */
  98. /* Symbols for SGML character set divisions and function characters. */
  99. /* Same as for LEXCNM. */
  100.  
  101. /* Symbols for SGML delimiter roles in CON, CXT, and DS.
  102.    ETI and NET must be the same in LEXCNM and LEXCON.
  103.    FRE characters are changed to FCE if an FCE entity is declared.
  104.    They are changed back to FRE when the entity is canceled.
  105. */
  106. #define ERO    13   /* &    Also CRO[1] */
  107. #define NMRE   14   /* 08   Generated non-markup RE */
  108. #define COM    15   /* -    For MDO context. */
  109. #define ETI    16   /* /    Actually ETAGO[2] */
  110. #define NET    17   /* /    When enabled. */
  111. #define MDO    18   /* !    Actually MDO[2] */
  112. #define MSC2   19   /* ]    Both MSC[1] and MSC[2]. */
  113. #define MSO    20   /* [    For MDO context. */
  114. #define PERO   21   /* %    For prolog */
  115. #define PIO    22   /* ?    Actually PIO[2] */
  116. #define RNI    23   /* #    For CRO[2]. */
  117. #define TGC2   24   /* >    For TAGO and MSC context; also MDC, PIC */
  118. #define TGO2   25   /* <    TAGO; also MDO[1], PIO[1] */
  119.  
  120. char    lexcon[256] = { /*
  121. 000  001                          bs   tab  lf   home ff   cr   so   si   */
  122. EE,  NON, NON, NON, NON, NON, NON, NON, NMRE,SEP, RS,  NON, NON, RE,  NON, NON, /*
  123.                                         eof  esc  rt   left up   down */
  124. NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE,  NON, EOB, NON, NON, NON, /*
  125. 032  !    "    #    $    %    &    '    (    )    *    +    ,    -    .    /    */
  126. SPC, MDO, FRE, RNI, FRE, PERO,ERO, FRE, FRE, FRE, FRE, FRE, FRE, COM, NMC, ETI, /*
  127. 0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ?    */
  128. NU , NU , NU , NU , NU , NU , NU , NU , NU , NU , FRE, FRE, TGO2,FRE, TGC2,PIO, /*
  129. @    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O    */
  130. FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  131. P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _    */
  132. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, MSO, FRE, MSC2,FRE, FRE, /*
  133. `    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o    */
  134. FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  135. p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~    127  */
  136. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, FRE, FRE, FRE, FRE, NON,
  137. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  138. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  139. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  140. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  141. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  142. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  143. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  144. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, NON
  145. };
  146. /*      free nu   nmc  nms  spc  non  ee   eob  rs   re   sep  cde  nsc  ero
  147.         nmre com  eti  net  mdo  msc  mso  pero pio  rni  tagc tago  */
  148. #undef FRE
  149. #undef NU
  150. #undef NMC
  151. #undef NMS
  152. #undef SPC
  153. #undef NON
  154. #undef EE
  155. #undef EOB
  156. #undef RS
  157. #undef RE
  158. #undef SEP
  159. #undef CDE
  160. #undef NSC
  161. #undef ERO
  162. #undef NMRE
  163. #undef COM
  164. /* def ETI*/
  165. /* def NET*/
  166. #undef MDO
  167. #undef MSC2
  168. #undef MSO
  169. #undef PERO
  170. #undef PIO
  171. #undef RNI
  172. #undef TGC2
  173. /******************************************************************************/
  174. /* LEXGRP: Lexical table for group (PCBGR??) parses, including PCBREF.
  175. */
  176. /* Symbols for SGML character set divisions. */
  177. #define BIT     0   /* Bit combinations (not NONCHAR) not allowed in a group. */
  178. #define NMC     1   /* NAMECHAR  . -      Period, underscore, and numerals */
  179. #define NMS     2   /* NAMESTRT           Lower and uppercase letters */
  180. #define RE      3   /* Function  13       Carrier return */
  181. #define SPC     4   /* SPACE     32 09    Space; includes TAB */
  182. #define NON     5   /* NONCHAR   0-31 127 255 Unused, except for: */
  183. #define EE      6   /* Function  26 00    EE: entity end (end of file) */
  184. #define EOB     7   /* NONCHAR   28       End disk buffer. */
  185. #define RS      8   /* Function  10       RS: record start (line feed) */
  186.  
  187. /* Symbols for SGML delimiter roles in GRP. */
  188. #define AND1    9   /* &    */
  189. #define GRPC   10   /* )    */
  190. #define GRPO   11   /* (    */
  191. #define LIT2   12   /* "    For datatags. */
  192. #define LITA   13   /* '    For datatags. */
  193. #define DTGC   14   /* ]    For datatags. */
  194. #define DTGO   15   /* [    For datatags. */
  195. #define OPT1   16   /* ?    */
  196. #define OR1    17   /* |    */
  197. #define PERO   18   /* %    */
  198. #define PLUS   19   /* +    */
  199. #define REP1   20   /* *    */
  200. #define RNI    21   /* #    For #CHARS */
  201. #define SEQ1   22   /* ,    */
  202. #define REFC   23   /* ;    For references */
  203.  
  204. char lexgrp[256] = { /*
  205. 000  001                          bs   tab  lf   home ff   cr   so   si   */
  206. EE , NON, NON, NON, NON, NON, NON, NON, NON, SPC, RS,  NON, NON, RE,  NON, NON, /*
  207.                                         eof  esc  rt   left up   down */
  208. NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE , NON, EOB, NON, NON, NON, /*
  209. 032  !    "    #    $    %    &    '    (    )    *    +    ,    -    .    /    */
  210. SPC, BIT, LIT2,RNI, BIT, PERO,AND1,LITA,GRPO,GRPC,REP1,PLUS,SEQ1,NMC, NMC, BIT, /*
  211. 0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ?    */
  212. NMC, NMC, NMC, NMC, NMC, NMC, NMC, NMC, NMC, NMC, BIT, REFC,BIT, BIT, BIT, OPT1,/*
  213. @    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O    */
  214. BIT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  215. P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _    */
  216. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, DTGO,BIT, DTGC,BIT, BIT, /*
  217. `    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o    */
  218. BIT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  219. p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~    127  */
  220. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, BIT, OR1, BIT, BIT, NON,
  221. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  222. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  223. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  224. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  225. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  226. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  227. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  228. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, NON
  229. };
  230. /*      bit  nmc  nms  re   spc  non  ee   eob  rs   and  grpc grpo lit  lita
  231.         dtgc dtgo opt  or   pero plus rep  rni  seq  refc */
  232. #undef BIT
  233. #undef NMC
  234. #undef NMS
  235. #undef RE
  236. #undef SPC
  237. #undef NON
  238. #undef EE
  239. #undef EOB
  240. #undef RS
  241. #undef AND1
  242. #undef GRPC
  243. #undef GRPO
  244. #undef LIT2
  245. #undef LITA
  246. #undef DTGC
  247. #undef DTGO
  248. #undef OPT1
  249. #undef OR1
  250. #undef PERO
  251. #undef PLUS
  252. #undef REP1
  253. #undef RNI
  254. #undef SEQ1
  255. #undef REFC
  256. /******************************************************************************/
  257. /* LEXLMS: Lexical table for literal parses (PCBLIT?) and
  258.            marked sections (PCBMS??).
  259. */
  260. /* Symbols for SGML character set divisions and function characters.
  261. */
  262. #define FRE     0   /* Free char: not in a delimiter or minimum literal. */
  263. #define NU      1   /* Numeral            Numerals */
  264. #define MIN     2   /* Minimum literal    '()+,-./:?= */
  265. #define NMS     3   /* LC/UCNMSTRT        Lower and uppercase letters */
  266. #define SPC     4   /* SPACE     32       Space */
  267. #define NON     5   /* NONSGML   0-31 127 255 Unused, except for: */
  268. #define EE      6   /* NONSGML   00 26    Entity end (end of file) */
  269. #define EOB     7   /* NONSGML   28       End disk buffer */
  270. #define RS      8   /* Function  10       Line feed */
  271. #define RE      9   /* Function  13       Carrier return */
  272. #define SEP    10   /* SEPCHAR   09       TAB: horizontal tab */
  273. #define CDE    11   /* NONSGML   delcdata CDATA/SDATA delimiter */
  274. #define NSC    12   /* NONSGML   delnonch Non-SGML character prefix */
  275. /* Symbols for SGML delimiter roles in LIT, PI, and marked sections.
  276.    Either LIT, LITA, PIC, or EE, is changed to LITC when a literal is begun.
  277.    It is changed back when the LITC occurs (i.e., when the literal ends).
  278. */
  279. #define ERO    13   /* &    */
  280. #define MDO    14   /* !    Actually MDO[2] */
  281. #define MSC3   15   /* ]    Also MSC[2]. */
  282. #define MSO    16   /* [    For MDO context. */
  283. #define PERO   17   /* %    For prolog. */
  284. #define RNI    18   /* #    For CRO[2] */
  285. #define TGC3   19   /* >    Also MDC for MSC context. */
  286. #define TGO3   20   /* <    TAGO; also MDO[1] */
  287. #define LITC   21   /* LIT LITA PIC or EE in use as a literal terminator */
  288.  
  289. /* Room has been left in the parse tables in case re-parsing of text
  290.    is eventually supported (i.e., saved parsed text is used by the
  291.    application to create a new SGML document, but CDATA and SDATA
  292.    entities in literals, and non-SGML characters, are left in their
  293.    parsed state to avoid the overhead of reconstituting the original
  294.    markup).  In such a case, the two non-SGML characters specified by
  295.    the text processor in sw.delcdata and sw.delsdata are changed to CDE.
  296.    NOTE: The idea is a bad one, because the generated document would
  297.    be non-conforming, as it would contain non-SGML characters.
  298. */
  299. /* The character in sw.delnonch is changed to NSC in any event, so that
  300.    a resolved non-SGML character reference in the text of a general entity
  301.    can be handled as data in the content.
  302. */
  303.  
  304. char    lexlms[256] = { /*
  305. 000  001                          bs   tab  lf   home ff   cr   so   si   */
  306. EE,  NON, NON, NON, NON, NON, NON, NON, NON ,SEP, RS,  NON, NON, RE,  NON, NON, /*
  307.                                         eof  esc  rt   left up   down */
  308. NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE,  NON, EOB, NON, NON, NON, /*
  309. 032  !    "    #    $    %    &    '    (    )    *    +    ,    -    .    /    */
  310. SPC, MDO, FRE, RNI, FRE, PERO,ERO, MIN, MIN, MIN, FRE, MIN, MIN, MIN, MIN, MIN, /*
  311. 0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ?    */
  312. NU , NU , NU , NU , NU , NU , NU , NU , NU , NU , MIN, FRE, TGO3,MIN, TGC3,MIN, /*
  313. @    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O    */
  314. FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  315. P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _    */
  316. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, MSO, FRE, MSC3,FRE, FRE, /*
  317. `    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o    */
  318. FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  319. p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~    127  */
  320. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, FRE, FRE, FRE, FRE, NON,
  321. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  322. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  323. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  324. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  325. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  326. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  327. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  328. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, NON
  329. };
  330. /*      free nu   min  nms  spc  non  ee   eob  rs   re   sep  cde  nsc  ero
  331.         mdo  msc  mso  pero rni  tago tagc litc */
  332. /* def FRE*/
  333. #undef NU
  334. #undef MIN
  335. #undef NMS
  336. #undef SPC
  337. #undef NON
  338. #undef EE
  339. #undef EOB
  340. #undef RS
  341. #undef RE
  342. #undef SEP
  343. /* def CDE*/
  344. /* def NSC*/
  345. #undef ERO
  346. #undef MDO
  347. /* def MSC3*/
  348. #undef MSO
  349. #undef PERO
  350. #undef RNI
  351. #undef TGC3
  352. #undef TGO3
  353. /* def LITC*/
  354. /******************************************************************************/
  355. /* LEXMARK: Lexical scan table for markup: PCBMD? and PCB?TAG.
  356. */
  357. /* Symbols for SGML character set divisions. */
  358. #define BIT     0   /* Bit combinations not allowed; includes ESC SO SI */
  359. #define NMC     1   /* NAMECHAR  . _      Period and underscore */
  360. #define NU      2   /* NUMERAL            Numerals */
  361. #define NMS     3   /* NAMESTRT           Lower and uppercase letters */
  362. #define SPC     4   /* SPACE     32 13 09 Space; includes RE TAB */
  363. #define NON     5   /* NONCHAR   0-31 127 255 Unused, except for: */
  364. #define EE      6   /* Function  26 00    EE: entity end (end of file) */
  365. #define EOB     7   /* NONCHAR   28       End disk buffer. */
  366. #define RS      8   /* Function  10       RS: record start (line feed) */
  367.  
  368. /* Symbols for SGML delimiter roles in MD and TAG. */
  369. #define COM1    9   /* -    Actually COM[1]; also COM[2], MINUS. */
  370. #define ETIB   10   /* /    ETI; actually ETAGO[2]. */
  371. #define GRPO   11   /* (    */
  372. #define LIT3   12   /* "    */
  373. #define LITA   13   /* '    */
  374. #define DSO    14   /* [    */
  375. #define PERO   15   /* %    */
  376. #define PLUS   16   /* +    */
  377. #define REFC   17   /* ;    For references */
  378. #define RNI    18   /* #    Also CRO[2] */
  379. #define TGC4   19   /* >    Also MDC, PIC */
  380. #define TGO4   20   /* <    TAGO; also MDO[1] */
  381. #define VI     21   /* =    */
  382.  
  383. char lexmark[256] = { /*
  384. 000  001                          bs   tab  lf   home ff   cr   so   si   */
  385. EE , NON, NON, NON, NON, NON, NON, NON, NON, SPC, RS,  NON, NON, SPC, NON, NON, /*
  386.                                         eof  esc  rt   left up   down */
  387. NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE , NON, EOB, NON, NON, NON, /*
  388. 032  !    "    #    $    %    &    '    (    )    *    +    ,    -    .    /    */
  389. SPC, BIT, LIT3,RNI, BIT, PERO,BIT, LITA,GRPO,BIT, BIT, PLUS,BIT, COM1,NMC ,ETIB,/*
  390. 0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ?    */
  391. NU,  NU,  NU,  NU,  NU,  NU,  NU,  NU,  NU,  NU,  BIT, REFC,TGO4,VI,  TGC4,BIT, /*
  392. @    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O    */
  393. BIT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  394. P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _    */
  395. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, DSO, BIT, BIT, BIT, BIT, /*
  396. `    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o    */
  397. BIT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  398. p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~    127  */
  399. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, BIT, BIT, BIT, BIT, NON,
  400. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  401. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  402. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  403. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  404. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  405. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  406. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  407. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, NON
  408. };
  409. /*      bit  nmc  nu   nms  spc  non  ee   eob  rs   com  eti  grpo lit  lita
  410.         dso  pero plus refc rni  tagc tago vi   */
  411. #undef BIT
  412. #undef NMC
  413. #undef NU
  414. #undef NMS
  415. #undef SPC
  416. #undef NON
  417. #undef EE
  418. #undef EOB
  419. #undef RS
  420. #undef COM1
  421. #undef ETIB
  422. #undef GRPO
  423. #undef LIT3
  424. #undef LITA
  425. #undef DSO
  426. #undef PERO
  427. #undef PLUS
  428. #undef REFC
  429. #undef RNI
  430. #undef TGC4
  431. #undef TGO4
  432. #undef VI
  433. /******************************************************************************/
  434. /* LEXTRAN: Translation table for SGML names.
  435. */
  436. char lextran[256] = { /*
  437. 000  001                          bs   tab  lf  home  ff   cr   so   si   */
  438. 0  , 1  , 2  , 3  , 4  , 5  , 6  , 7  , 8  , 9  , 10 , 11 , 12 , 13 , 14 , 15 , /*
  439.                                         eof  esc  rt   left up   down */
  440. 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , /*
  441. space!    "    #    $    %    &    '    (    )    *    +    ,    -    .    /    */
  442. 32 , 33 , 34 , 35 , 36 , 37 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 , /*
  443. 0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ?    */
  444. 48 , 49 , 50 , 51 , 52 , 53 , 54 , 55 , 56 , 57 , 58 , 59 , 60 , 61 , 62 , 63 , /*
  445. @    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O    */
  446. 64 , 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , /*
  447. P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _    */
  448. 80 , 81 , 82 , 83 , 84 , 85 , 86 , 87 , 88 , 89 , 90 , 91 , 92 , 93 , 94 , 95 , /*
  449. `    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o    */
  450. 96 , 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', /*
  451. p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~    127  */
  452. 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
  453. 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
  454. 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
  455. 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 173, 173, 174, 175,
  456. 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
  457. 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
  458. 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
  459. 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
  460. 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
  461. };
  462. /******************************************************************************/
  463. #include "lextoke.h"          /* Symbols for tokenization lexical classes. */
  464. /******************************************************************************/
  465. /* LEXTOKE: Lexical class table for tokenization scan.
  466. */
  467. char lextoke[256] = { /*
  468.  
  469. 000  001                          bs   tab  lf  home  ff   cr           */
  470. INV, INV, INV, INV, INV, INV, INV, INV, INV, SEP, REC, INV, INV, REC, INV, INV, /*
  471.                                         eof  esc  rt   left up   down */
  472. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, EOB, INV, INV, INV, /*
  473. space!    "    #    $    %    &    '    (    )    *    +    ,    -    .    /    */
  474. SEP, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, NMC, NMC, INV, /*
  475. 0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ?    */
  476. NU , NU , NU , NU , NU , NU , NU , NU , NU , NU , INV, INV, INV, INV, INV, INV, /*
  477. @    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O    */
  478. INV, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  479. P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _    */
  480. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, INV, INV, INV, INV, INV, /*
  481. `    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o    */
  482. INV, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  483. p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~    127  */
  484. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, INV, INV, INV, INV, INV,
  485. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
  486. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
  487. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
  488. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
  489. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
  490. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
  491. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
  492. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
  493. };
  494. /******************************************************************************/
  495. struct lexical lex = {        /* Delimiter set constants for parser use. */
  496.      {                        /* Markup strings for text processor use. */
  497.           "\4&#",                  /* LEXCON markup string: CRO        */
  498.           "[",                     /* LEXCON markup string: DSO        */
  499.           "\3&",                   /* LEXCON markup string: ERO        */
  500.           "\4</",                  /* LEXMARK markup string: end-tag   */
  501.           "\3\"",                  /* LEXMARK markup string: LIT       */
  502.           "\3'",                   /* LEXMARK markup string: LITA      */
  503.           "\3>",                   /* LEXCON markup string: MDC        */
  504.           "\4<!",                  /* LEXCON markup string: MDO        */
  505.           "\5]]>",                 /* LEXCON markup string: mse        */
  506.           "\5<![",                 /* LEXCON markup string: mss        */
  507.           "\13<![CDATA[",          /* LEXCON markup string: mss CDATA  */
  508.           "\14<![RCDATA[",         /* LEXCON markup string: mss RCDATA */
  509.           "\3>",                   /* LEXCON markup string: PIC        */
  510.           "\4<?",                  /* LEXCON markup string: PIO        */
  511.           "\3;",                   /* LEXGRP markup string: ref close. */
  512.           "\3<",                   /* LEXMARK markup string: start-tag */
  513.           "\3>",                   /* LEXMARK markup string: TAGC      */
  514.           "\3=",                   /* LEXMARK markup string: VI        */
  515.           3,                       /* LEXMARK: length of null end-tag. */
  516.           2                        /* LEXMARK: length of null start-tag. */
  517.      },
  518.      {                        /* Short reference delimiters. */
  519.           {                        /* Short reference delimiter table. */
  520.                {"",       SRCT},        /* Dummy entry to store SR count. */
  521.                {"\t",     1},           /* TAB */
  522.                {"\r",     2},           /* RE */
  523.                {"\n",     3},           /* RS */
  524.                {"\nB",    4},           /* Leading blanks */
  525.                {"\n\r",   5},           /* Null record */
  526.                {"\nB\r",  6},           /* Blank record */
  527.                {"B\r",    7},           /* Trailing blanks */
  528.                {" ",      8},           /* Space */
  529.                {"BB",     9},           /* Two or more blanks */
  530.                {"\"",    10},           /* Quotation mark (first data character) */
  531.                {"#",     11},           /* Number sign */
  532.                {"%",     12},           /* FCE CHARACTERS start here */
  533.                {"'",     13},
  534.                {"(",     14},
  535.                {")",     15},
  536.                {"*",     16},
  537.                {"+",     17},
  538.                {",",     18},
  539.                {"-",     19},           /* Hyphen */
  540.                {"--",    20},           /* Two hyphens */
  541.                {":",     21},
  542.                {";",     22},
  543.                {"=",     23},
  544.                {"@",     24},
  545.                {"[",     25},
  546.                {"]",     26},
  547.                {"^",     27},
  548.                {"_",     28},           /* Low line */
  549.                {"{",     29},
  550.                {"|",     30},
  551.                {"}",     31},
  552.                {"~",     32},
  553.                {NULL,     0}
  554.           },
  555.           {                        /* Printable form of unprintable SR delims.*/
  556.                "",                      /* Dummy entry to balance s.dtb. */
  557.                "&#TAB;",                /* TAB */
  558.                "&#RE;",                 /* RE */
  559.                "&#RS;",                 /* RS */
  560.                "&#RS;B",                /* Leading blanks */
  561.                "&#RS;&#RE;",            /* Null record */
  562.                "&#RS;B&#RE;",           /* Blank record */
  563.                "B&#RE;",                /* Trailing blanks */
  564.                "&#SPACE;"               /* Space */
  565.           },
  566.           12,                      /* LEXCNM: Index of first FCE in srdeltab. */
  567.           20,                      /*LEXCNM:Index of "two hyphens" in srdeltab*/
  568.           10,                      /* LEXCNM: Index of first SR with data char. */
  569.           19,                      /* LEXCNM: Index of hyphen in srdeltab. */
  570.           SRNPRT+1,                /* LEXCNM: Index of 1st printable SR. */
  571.           8,                       /* LEXCNM: Index of space in srdeltab. */
  572.      },                       /* End of short reference delimiters. */
  573.      {                        /* General delimiter characters. */
  574.           '\b',                    /*LEXCNM:(BS)Generated RE; can't be markup.*/
  575.           '"',                     /* LEXMARK: Char used as LIT delimiter.*/
  576.           '\'',                    /* LEXMARK: Char used as LITA delimiter.*/
  577.           '>',                     /* LEXLMS: Char used as MDC delimiter.*/
  578.           ']',                     /* LEXLMS: Char used as MSC when enabled.*/
  579.           '/',                     /* LEXCON: Char used as NET when enabled.*/
  580.           '%',                     /* LEXMARK: Char used as PERO delimiter. */
  581.           '>',                     /* LEXCON: Char used as PIC delimiter.*/
  582.           '<'                      /* LEXCON: Char used as TAGO when enabled.*/
  583.      },
  584.      {                        /* Lexical table code assignments. */
  585.           FCE,                    /* LEXCNM: FRE char as entity reference.*/
  586.           FRE,                    /* LEXLMS: Free character not an entity ref.*/
  587.           LITC,                   /* LEXLMS: Literal close delimiter enabled. */
  588.           NSC,                    /* LEXLMS: Non-SGML character prefix. */
  589.           MSC3,                   /* LEXLMS: Marked section close delim enabled. */
  590.           NET,                    /* LEXCON: Null end-tag delimiter enabled. */
  591.           ETI,                    /* LEXCON: NET disabled; still used as ETI. */
  592.           SPCR,                   /* LEXCNM: Space in use as SHORTREF delim. */
  593.           TGO2,                   /* LEXCON: Tag open delimiter enabled. */
  594.           CDE                     /* LEXLMS: CDATA/SDATA delimiters. */
  595.      }
  596. };
  597. /******************************************************************************/
  598.