comparison doc/misc/html/examples/mpp/ct.html @ 0:13d2b8934445

Import AnaGram (near-)release tree into Mercurial.
author David A. Holland
date Sat, 22 Dec 2007 17:52:45 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:13d2b8934445
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>Token Classifier - Macro preprocessor and C Parser </TITLE>
5 </HEAD>
6
7
8 <BODY BGCOLOR="#ffffff" BACKGROUND="tilbl6h.gif"
9 TEXT="#000000" LINK="#0033CC"
10 VLINK="#CC0033" ALINK="#CC0099">
11
12 <P>
13 <IMG ALIGN="right" SRC="../../images/agrsl6c.gif" ALT="AnaGram"
14 WIDTH=124 HEIGHT=30 >
15 <BR CLEAR="all">
16 Back to :
17 <A HREF="../../index.html">Index</A> |
18 <A HREF="index.html">Macro preprocessor overview</A>
19 <P>
20
21
22 <IMG ALIGN="bottom" SRC="../../images/rbline6j.gif" ALT="----------------------"
23 WIDTH=1010 HEIGHT=2 >
24 <P>
25
26 <H1>Token Classifier - Macro preprocessor and C Parser </H1>
27
28 <IMG ALIGN="bottom" SRC="../../images/rbline6j.gif" ALT="----------------------"
29 WIDTH=1010 HEIGHT=2 >
30 <P>
31 <BR>
32 <H2>Introduction</H2>
33 <P>
34 The token classifier module, <tt>ct.syn</tt>, exists only to deal
35 with one very specific problem: When two tokens are spliced
36 together in accordance with the "##" operator during a macro
37 expansion, it is necessary to determine the syntactic type
38 of the resulting token. Although it is conceivable that the
39 token scanner could accomplish the job, it was felt that it
40 would be simpler to simply extract the appropriate syntax
41 from <tt>ts.syn</tt> and create a separate
42 module. <tt>ct.syn</tt> is the
43 result.
44
45 The parser for the token classifier is <tt>ct()</tt>. It uses pointer
46 mode input. The interface function for the token classifier,
47 <tt>classify_token</tt>, takes a string pointer as an argument and
48 returns a <tt>token_id</tt>:
49 <PRE>
50 token_id classify_token(char *);
51 </PRE>
52 <BR>
53
54 <H2> Theory of Operation </H2>
55
56 The syntax found in <tt>ct.syn</tt> is simply the token recognition
57 syntax of <tt>ts.syn</tt>. The reduction procedures are limited to
58 those necessary to identifying the type of token presented.
59 <P>
60 The parser is set up to use pointer input, since the string
61 to be scanned is always in memory. The address of the input
62 is saved in <tt>input_string</tt> in case it is necessary to check
63 for a reserved word.
64 <P>
65 There are no error diagnostics. If the token is not
66 recognizable, it is given a token_id of <tt>UNRECOGNIZED</tt>.
67 <P>
68 The default token type parameter is set to <tt>token_id</tt> in order
69 to avoid specifying a type for each relevant token. Note
70 that "name" is set to type <tt>void</tt> in order to avoid a compiler
71 error. Since the return value of the reduction procedures
72 is <tt>character_sink</tt>, without the void declaration, the
73 compiler will try to convert <tt>character_sink</tt> to
74 <tt>token_id</tt>.
75
76 <P>
77 <BR>
78
79
80 <IMG ALIGN="bottom" SRC="../../images/rbline6j.gif" ALT="----------------------"
81 WIDTH=1010 HEIGHT=2 >
82 <P>
83 <IMG ALIGN="right" SRC="../../images/pslrb6d.gif" ALT="Parsifal Software"
84 WIDTH=181 HEIGHT=25>
85 <BR CLEAR="right">
86
87 <P>
88 Back to :
89 <A HREF="../../index.html">Index</A> |
90 <A HREF="index.html">Macro preprocessor overview</A>
91
92 <P>
93 <ADDRESS><FONT SIZE="-1">
94 AnaGram parser generator - examples<BR>
95 Token Classifier - Macro preprocessor and C Parser <BR>
96 Copyright &copy; 1993-1999, Parsifal Software. <BR>
97 All Rights Reserved.<BR>
98 </FONT></ADDRESS>
99
100 </BODY>
101 </HTML>